Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Feb 24, 2020 12:01 pm

All times are UTC - 5 hours

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Create a Windows file association
PostPosted: Sat Jan 23, 2010 8:33 pm 
User avatar

Joined: Thu Mar 05, 2009 1:03 pm
Posts: 1786
Location: USA
The question "How do I create a file association on Windows?" comes up with some degree of regularity; hopefully this function will be useful for those people.

Function CreateWindowsFileAssociation(Extension As String, LongName As String, Description As String) As Boolean

//Extension: the file extension, including a period; for example, .doc
//LongName: the application's long name. For example, Microsoft Word
//Description: the file type's description. For example, Word document

#if TargetWin32 then
dim RegItem As RegistryItem, sApplicationPath As String, sIconIndex As String
//Write associations into registry
RegItem=new RegistryItem("HKEY_CLASSES_ROOT\" + Extension)
RegItem=new RegistryItem("HKEY_CLASSES_ROOT\" + LongName)
RegItem=new RegistryItem("HKEY_CLASSES_ROOT\" + LongName + "\shell\open\command")
RegItem.DefaultValue=app.ExecutableFile.AbsolutePath + " %1"
RegItem=new RegistryItem("HKEY_CLASSES_ROOT\" + LongName + "\DefaultIcon")
RegItem.DefaultValue=app.ExecutableFile.AbsolutePath + ",0"
Return True
Return False

With great power comes great responsibility.
Learn something new every day, and the rest will take care of itself.
Life is a journey, not a destination. Enjoy the trip! :D

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group