I coded the next snippet long time back and I wish that it's still working
1- Use your own Exe file name , icon and extension
2- Run as ADMIN
Code: Select all
#SHCNE_ASSOCCHANGED = $08000000
#SHCNF_IDLIST = $0
Procedure AssociateFileEx(ext.s, ext_description.s, programm.s, Icon.s, prgkey.s, cmd_description.s, cmd_key.s)
If OSVersion() >= #PB_OS_Windows_2000
RegCreateKeyEx_(#HKEY_CLASSES_ROOT, ".pbc",0,0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, @lpSecurityAttributes, @hKey1, @createKey)
RegSetValueEx_(hKey1, "", 0, #REG_SZ, @"PureBasic.exe", Len("Purebasic.exe"))
RegCloseKey_(hKey1)
RegCreateKeyEx_(#HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pbc", 0,0,#REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, @lpSecurityAttributes, @hKey1, @createKey)
;RegSetValueEx_(hKey1, "", 0, #REG_SZ, @"PureBasic.exe", Len("Purebasic.exe"))
RegCloseKey_(hKey1)
EndIf
EndProcedure
Procedure AssociateFile(ext.s, ext_description.s, programm.s, Icon.s)
AssociateFileEx(ext, ext_description, programm, Icon, GetFilePart(programm), "open", "open")
EndProcedure
AssociateFile("pbc","Pure Basic Source","C:\PureBasic86\PureBasic.exe","g:\DB_Control_1.ico,0")
SHChangeNotify_(#SHCNE_ASSOCCHANGED, #SHCNF_IDLIST, 0, 0)