Changeset 15 for Common/ExtTools.cs
- Timestamp:
- Jun 18, 2024, 12:15:33 PM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/ExtTools.cs
r13 r15 108 108 public static void SetFileAssociation(string extension, string progId, string openWith, string fileDescription) 109 109 { 110 RegistryKey BaseKey; 111 RegistryKey OpenMethod; 112 RegistryKey Shell; 113 RegistryKey CurrentUser; 110 RegistryKey baseKey = Registry.ClassesRoot.CreateSubKey(extension); 111 baseKey?.SetValue("", progId); 114 112 115 BaseKey = Registry.ClassesRoot.CreateSubKey(extension); 116 BaseKey?.SetValue("", progId); 113 RegistryKey openMethod = Registry.ClassesRoot.CreateSubKey(progId); 114 openMethod?.SetValue("", fileDescription); 115 openMethod?.CreateSubKey("DefaultIcon")?.SetValue("", "\"" + openWith + "\",0"); 116 RegistryKey shell = openMethod?.CreateSubKey("Shell"); 117 shell?.CreateSubKey("edit")?.CreateSubKey("command")?.SetValue("", "\"" + openWith + "\"" + " \"%1\""); 118 shell?.CreateSubKey("open")?.CreateSubKey("command")?.SetValue("", "\"" + openWith + "\"" + " \"%1\""); 119 shell?.Close(); 120 openMethod?.Close(); 121 baseKey?.Close(); 117 122 118 OpenMethod = Registry.ClassesRoot.CreateSubKey(progId); 119 OpenMethod?.SetValue("", fileDescription); 120 OpenMethod?.CreateSubKey("DefaultIcon")?.SetValue("", "\"" + openWith + "\",0"); 121 Shell = OpenMethod?.CreateSubKey("Shell"); 122 Shell?.CreateSubKey("edit")?.CreateSubKey("command")?.SetValue("", "\"" + openWith + "\"" + " \"%1\""); 123 Shell?.CreateSubKey("open")?.CreateSubKey("command")?.SetValue("", "\"" + openWith + "\"" + " \"%1\""); 124 Shell?.Close(); 125 OpenMethod?.Close(); 126 BaseKey?.Close(); 123 // Delete explorer override 124 RegistryKey currentUser = Registry.CurrentUser.OpenSubKey( 125 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\" + extension, true); 126 currentUser?.DeleteSubKey("UserChoice", false); 127 currentUser?.Close(); 127 128 128 // Delete explorer override 129 CurrentUser = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\" + extension, true); 130 CurrentUser?.DeleteSubKey("UserChoice", false); 131 CurrentUser?.Close(); 132 133 // Tell explorer the file association has been changed 134 SHChangeNotify(0x08000000, 0x0000, IntPtr.Zero, IntPtr.Zero); 129 // Tell explorer the file association has been changed 130 SHChangeNotify(0x08000000, 0x0000, IntPtr.Zero, IntPtr.Zero); 135 131 } 136 132
Note:
See TracChangeset
for help on using the changeset viewer.