Getox Posted September 15, 2005 Posted September 15, 2005 How would i change what program or add an entry into the registry to set what program a file extension opens in? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
bri189a Posted September 15, 2005 Posted September 15, 2005 Set the registry setting I believe...under HKEY_CLASSES_ROOT Quote
Getox Posted September 15, 2005 Author Posted September 15, 2005 I mean setting it with my windows form.. Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Leaders snarfblam Posted September 15, 2005 Leaders Posted September 15, 2005 Google to the rescue! Quote [sIGPIC]e[/sIGPIC]
bri189a Posted September 16, 2005 Posted September 16, 2005 I mean use that registry hive using the Registry namespace. Quote
Diesel Posted September 21, 2005 Posted September 21, 2005 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/fileassociations/fa_intro.asp http://www.windowsitlibrary.com/Content/368/07/2.html?Ad=1& Imports Microsoft.Win32; Dim regClassRoot as RegistryKey = Registry.ClassesRoot; regClassRoot.CreateSubKey("applicationName"); regClassRoot.SetValue("whavever", "applicationpath"); Create two trees similar to the ones on the msdn page. The result will be that you will be creating a key to identify what program opens the file type and a key to describe the application and it's run path. It would be a better idea to use the Windows Installer to create the registry keys and register the file extension. Marble_eater, for being such a big proponent of 'googling' you sure do give crappy links. Quote
Leaders dynamic_sysop Posted September 23, 2005 Leaders Posted September 23, 2005 don't know about crappy links :rolleyes: the 2nd link in the list on that google search happens to be one of the best VB code sites on the net, nearly all of it may be pre - .NET, but just about all of that can be modded to work in .NET this section of code .... '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Copyright ©1996-2005 VBnet, Randy Birch, All Rights Reserved. ' Some pages may also contain other copyrights by the author. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Distribution: You can freely use this code in your own ' applications, but you may not reproduce ' or publish this code on any web site, ' online service, or distribute as source ' on any media without express permission. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Sub CreateAssociation() Dim sPath As String 'File Associations begin with a listing 'of the default extension under HKEY_CLASSES_ROOT. 'So the first step is to create that 'root extension item CreateNewKey ".xxx", HKEY_CLASSES_ROOT 'To the extension just added, add a 'subitem where the registry will look for 'commands relating to the .xxx extension '("MyApp.Document"). Its type is String (REG_SZ) SetKeyValue ".xxx", "", "MyApp.Document", REG_SZ 'Create the 'MyApp.Document' item under 'HKEY_CLASSES_ROOT. This is where you'll put 'the command line to execute or other shell 'statements necessary. CreateNewKey "MyApp.Document\shell\open\command", HKEY_CLASSES_ROOT 'Set its default item to "MyApp Document". 'This is what is displayed in Explorer against 'for files with a xxx extension. Its type is 'String (REG_SZ) SetKeyValue "MyApp.Document", "", "MyApp Document", REG_SZ 'Finally, add the path to myapp.exe 'Remember to add %1 as the final command 'parameter to assure the app opens the passed 'command line item. '(results in '"c:\LongPathname\Myapp.exe %1") 'Again, its type is string. sPath = "c:\LongPathname\Myapp.exe %1" SetKeyValue "MyApp.Document\shell\open\command", "", sPath, REG_SZ 'All done MsgBox "The file association has been made!" End Sub gives you a perfect insight into which key to create / set the shell\open\command section of RegKey is the part that you need to set the Default item of, using as Diesel said the Microsoft.Win32.Registry class. BTW: Diesel , you seem to be mixing and matching your VB & C# in that code ;) by the look of those ; ; ; Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.