Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Sep 21, 2019 2:11 pm
xojo

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 
Offline
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
sApplicationPath=app.ExecutableFile.AbsolutePath
sIconIndex=",0"
//Write associations into registry
RegItem=new RegistryItem("HKEY_CLASSES_ROOT\" + Extension)
RegItem.DefaultValue=LongName
RegItem=new RegistryItem("HKEY_CLASSES_ROOT\" + LongName)
RegItem.DefaultValue=Description
RegItem.Value("BrowserFlags")=8
RegItem.Value("EditFlags")=0
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
Exception
Return False
#endif

_________________
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


Top
 Profile  
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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group