2010-07-08 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System / System.Diagnostics / ProcessStartInfo.cs
index a5376fad6814d0e78592670e377f5214b44d226c..41936f479e53b85b667046fffa0421e658abe8b5 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using Microsoft.Win32;
 using System.Collections;
 using System.Collections.Specialized;
 using System.ComponentModel;
+using System.IO;
 using System.Security;
 using System.Security.Permissions;
 using System.Text;
@@ -110,7 +112,6 @@ namespace System.Diagnostics
                        }
                }
 
-               [MonoTODO("Need to read the env block somehow")]
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Content), DefaultValue (null)]
                [Editor ("System.Diagnostics.Design.StringDictionaryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
                [MonitoringDescription ("Environment variables used for this process.")]
@@ -130,7 +131,7 @@ namespace System.Diagnostics
                }
                
                internal bool HaveEnvVars {
-                       get { return (envVars != null && envVars.Count > 0); }
+                       get { return (envVars != null); }
                }
                
                [DefaultValue (false)]
@@ -256,11 +257,43 @@ namespace System.Diagnostics
                        }
                }
 
-               [MonoTODO]
+               static readonly string [] empty = new string [0];
+
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden), Browsable (false)]
                public string[] Verbs {
                        get {
-                               return(null);
+                               string ext = filename == null | filename.Length == 0 ? 
+                                       null : Path.GetExtension (filename);
+                               if (ext == null)
+                                       return empty;
+
+#if MONOTOUCH
+                               return empty;
+#else
+
+                               switch (Environment.OSVersion.Platform) {
+                               case (PlatformID)4:
+                               case (PlatformID)6:
+                               case (PlatformID)128:
+                                       return empty; // no verb on non-Windows
+                               default:
+                                       RegistryKey rk = null, rk2 = null, rk3 = null;
+                                       try {
+                                               rk = Registry.ClassesRoot.OpenSubKey (ext);
+                                               string k = rk != null ? rk.GetValue (null) as string : null;
+                                               rk2 = k != null ? Registry.ClassesRoot.OpenSubKey (k) : null;
+                                               rk3 = rk2 != null ? rk2.OpenSubKey ("shell") : null;
+                                               return rk3 != null ? rk3.GetSubKeyNames () : null;
+                                       } finally {
+                                               if (rk3 != null)
+                                                       rk3.Close ();
+                                               if (rk2 != null)
+                                                       rk2.Close ();
+                                               if (rk != null)
+                                                       rk.Close ();
+                                       }
+                               }
+#endif
                        }
                }