示例#1
0
 public static void AddShellNewFilename(string extension, string filename)
 {
     try
     {
         RegistryKey rk = Registry.ClassesRoot.OpenSubKey(extension, true).CreateSubKey("ShellNew");
         rk.SetValue("FileName", filename);
         rk.Close();
         ShellNotification.NotifyOfChange();
     }
     catch { };
 }
示例#2
0
 public static bool AssociateMe(string extension, string progID, string description, int iicon, string applicationParams)
 {
     try
     {
         Assembly me   = Assembly.GetExecutingAssembly();
         string   path = me.Location;
         if (extension.StartsWith("*"))
         {
             extension = extension.Substring(1);
         }
         if (!extension.StartsWith("."))
         {
             extension = "." + extension;
         }
         if (IsAssociatedWithMe(extension))
         {
             return(true);
         }
         if (applicationParams == null)
         {
             applicationParams = "\"%1\"";
         }
         string icon;
         if (iicon == -1)
         {
             icon = "%1";
         }
         else
         {
             icon = path + "," + iicon;
         }
         string application = path + " " + applicationParams;
         Registry.ClassesRoot.CreateSubKey(extension).SetValue("", progID);
         if (progID != null && progID.Length > 0)
         {
             RegistryKey key = Registry.ClassesRoot.CreateSubKey(progID);
             if (description != null)
             {
                 key.SetValue("", description);
             }
             if (icon != null)
             {
                 key.CreateSubKey("DefaultIcon").SetValue("", icon);
             }
             if (application != null)
             {
                 key.CreateSubKey(@"Shell\Open\Command").SetValue("", application);
             }
         }
         ShellNotification.NotifyOfChange();
         return(true);
     }
     catch { return(false); }
 }
示例#3
0
 public static void AddShellNewFull(string extension, string command)
 {
     try
     {
         RegistryKey rk = Registry.ClassesRoot.OpenSubKey(extension, true).CreateSubKey("ShellNew");
         rk.SetValue("ItemName", command);
         rk.SetValue("NullFile", "");
         rk.Close();
         ShellNotification.NotifyOfChange();
     }
     catch { };
 }