Creating Explorer Menu Extensions
Posted: Fri Dec 19, 2003 7:41 am
Does anyone have any information on adding options to the (explorer?) menus that pop up when you right click on files?
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
; Now, update the registry to associate correctly the '.pb' with the editor.
;
If GetVersion_() & $ff0000 ; Windows NT/XP
If RegCreateKeyEx_(#HKEY_CLASSES_ROOT, "Applications\PureBasic.exe\shell\open\command", 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, 0, @NewKey, @KeyInfo) = #ERROR_SUCCESS
StringBuffer$ = Chr(34)+FullPath+"PureBasic.exe"+Chr(34)+" "+Chr(34)+"%1"+Chr(34)
RegSetValueEx_(NewKey, "", 0, #REG_SZ, StringBuffer$, Len(StringBuffer$)+1)
RegCloseKey_(NewKey)
EndIf
If RegCreateKeyEx_(#HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pb", 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, 0, @NewKey, @KeyInfo) = #ERROR_SUCCESS
RegSetValueEx_(NewKey, "Application", 0, #REG_SZ, "PureBasic.exe", Len("PureBasic.exe")+1)
RegCloseKey_(NewKey)
EndIf
Else ; The same for Win9x
If RegCreateKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Classes\PureBasic.exe\shell\open\command", 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, 0, @NewKey, @KeyInfo) = #ERROR_SUCCESS
StringBuffer$ = Chr(34)+FullPath+"PureBasic.exe"+Chr(34)+" "+Chr(34)+"%1"+Chr(34)
RegSetValueEx_(NewKey, "", 0, #REG_SZ, StringBuffer$, Len(StringBuffer$)+1)
RegCloseKey_(NewKey)
EndIf
If RegCreateKeyEx_(#HKEY_LOCAL_MACHINE, "Software\CLASSES\.pb", 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, 0, @NewKey, @KeyInfo) = #ERROR_SUCCESS
RegSetValueEx_(NewKey, "", 0, #REG_SZ, "PureBasic.exe", Len("PureBasic.exe")+1)
RegCloseKey_(NewKey)
EndIf
EndIfCode: Select all
[HKEY_CLASSES_ROOT\jpegfile\shell\Upload with ImageUploader]
@="Upload with ImageUploader"
[HKEY_CLASSES_ROOT\jpegfile\shell\Upload with ImageUploader\command]
@="\"C:\\Users\\Joakim\\Desktop\\PureBasic\\ImageUploader.exe" %1"@Timo : I have just added the win 9x variant of your code to a program of mine and it works fine on XP and Vista. Strangely though, on both of these systems, running the code results not only in being able to execute my 'default program' against the registered file extension through the shell/open menu, but also by double clicking any file with the appropriate extension!freak wrote:The Win9x part of my code above will work on XP and Vista if you change #HKEY_LOCAL_MACHINE to #HKEY_CURRENT_USER.