Registering an extension
-
Wednesday, October 08, 2008 3:07 PMHey guys,
I want to register a file extension so that it opens in my application in my richtextbox.
ALSO: It can't just load text into the richtextbox! My extension needs to load text into the RTB, several different parts will load into several differing labels. I have the code and I can open my extension that certian way from within my app using the openfiledialog, I just need to know to to register my file, while accomedating my "certian way".
I'm using the 2005 express of VB.NET.
I hope I explained myself well and thank you in advance,
Dylan
DylanT
All Replies
-
Wednesday, October 08, 2008 3:45 PM
If you are asking how to create a file association for your application then you will need some code to write to the registry.
you may want to look into the My.Computer.Registry object, check out this link MSDN .
this code may help you on your way.
My.Computer.Registry.ClassesRoot.CreateSubKey(".ext").SetValue("", "ext", Microsoft.Win32.RegistryValueKind.String) 'where ext is your extension
My.Computer.Registry.ClassesRoot.CreateSubKey("ext\shell\open\command").SetValue("", Application.ExecutablePath & _
" ""%l"" ", Microsoft.Win32.RegistryValueKind.String)
'"" tells the application to set the key's default value.
'Application.ExecutablePath tells the code to associate your running app with this file type.
Hope this helps a little
Kind regards
TSB- Marked As Answer by Martin Xie - MSFT Tuesday, October 14, 2008 10:54 AM
-
Saturday, October 11, 2008 3:10 AM
Thanks Tony,
I'm not very good with reg editing.. and the sample you gave me sadly didn't work.
I've heard about a File Types Editor.. but I can't find it anywhere in VB2005. Is it only for visual studio?
Microsoft you guys just make us pay for everything :D
Anyways I'm still wondering,,how to I open a register file type (.wrf) in VB.NET?
Dylan
DylanT -
Tuesday, October 14, 2008 10:54 AM
Hi Dylan,
Question: How to create a file extension and associate the extension with your application?
TSB is right. Thank you TSB for your friendly help.
Please check the following example and tutorial:
1. How To Associate a File Extension with Your Application
http://support.microsoft.com/kb/185453
Call the RegCreateKey& and RegSetValue& application programming interface (API) functions.2. File Association in VB.NET (using the third-part component: Registry Actions.dll)
http://www.codeproject.com/useritems/VBFileAssociation.asp
(Good sample including demo, source code, detailed steps and instruction.)E.g. creating file extension .Hello
My.Computer.Registry.ClassesRoot.CreateSubKey(".Hello").SetValue("", "Hello", Microsoft.Win32.RegistryValueKind.String)
My.Computer.Registry.ClassesRoot.CreateSubKey("Hello\shell\open\command").SetValue("", Application.ExecutablePath & " ""%l"" ", Microsoft.Win32.RegistryValueKind.String)You can also create file extension in Windows Explorer:
Trackback to this similar issue:
Tools menu -> Folder Options -> File Types
You can create New Extension by specifying File Extension and Associated File Type.
http://forums.microsoft.com:80/MSDN/ShowPost.aspx?PostID=2256837&SiteID=1
Best regards,
Martin Xie- Marked As Answer by Martin Xie - MSFT Wednesday, October 15, 2008 12:07 PM
-
Tuesday, October 14, 2008 11:17 AMCodePackage said:
I've heard about a File Types Editor.. but I can't find it anywhere in VB2005. Is it only for visual studio?
1. http://msdn.microsoft.com/en-us/library/ytsyfc3d(VS.80).aspx
To access the File Types Editor (which is available in Visual Studio full Editions), on the View menu, point to Editor, and then click File Types when a deployment project is selected in Solution Explorer.
2. http://msdn.microsoft.com/en-us/library/9k643651.aspx
If File Types Editor is missing from IDE menu, you can restore it like this:
-
With a project open, on the Tools menu, click Customize.
-
In the Customize dialog box, click the Commands tab.
-
In the Categories box, select View.
-
In the Commands box, select the command File Types Editor, and drag it to the View menu.
CodePackage said:
Anyways I'm still wondering,,how to I open a register file type (.wrf) in VB.NET?As far as I know, the register file type should be .reg. Right?
The .reg type is text file, you can open and read it using StreamReader Class in VB.NET.
StreamReader Class and code sample
http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx -
-
Wednesday, October 15, 2008 6:31 PMThank you both very very much. My file extension has been registered and is working.
TSB, your code actually worked fine, that is once I actually published and installed the actual app, I kept getting errors when I was debugging, though.
But it works now and the extension is registered, thanks to both of you.
Thank you again both of you!
Dylan
DylanT- Edited by CodePackage Wednesday, October 15, 2008 7:37 PM
-
Thursday, October 16, 2008 2:14 AM
Hi DylanT,
You're welcome. We are glad to hear that you got it working.
Thank you for your feedback and active participation in MSDN forums.
Regards,
Martin

