Posted: Tue Dec 23, 2003 2:45 pm
Writing a shell extension handler is not the easiest task, even if you do it
in a language that makes it easier to create COM objects than PB.
As you can read in the documentation, you'll have to export several
Interfaces, which in PB is quite a lot of work. (just look at my COM-downlaod
tutorial in the tips&tricks section, and you'll see.)
A context menu handler is only needed, if you need to dynamically add
menu items, depending on each individual file. If you only want an item
for all files of a type, it should be possible by just adding
some registry entrys.
See here for more details:
http://msdn.microsoft.com/library/defau ... ontext.asp
The PureBasic editor for example does that to add the standart "Open" item:
As you see, it adds the subkey "PureBasic.exe\shell\open\command", and
the default value is the action to take when the 'Open' menuitem is clicked.
If you add something like "PureBasic.exe\shell\execute\command", and
set the default value to "C:\PureBasic\Compilers\pbcompiler.exe %1", and
set the default value of the "PureBasic.exe\shell\execute" key to "Execute",
you get another popupmenu item called "Execute", which will runn the
source file directly.
Timo
in a language that makes it easier to create COM objects than PB.
As you can read in the documentation, you'll have to export several
Interfaces, which in PB is quite a lot of work. (just look at my COM-downlaod
tutorial in the tips&tricks section, and you'll see.)
A context menu handler is only needed, if you need to dynamically add
menu items, depending on each individual file. If you only want an item
for all files of a type, it should be possible by just adding
some registry entrys.
See here for more details:
http://msdn.microsoft.com/library/defau ... ontext.asp
The PureBasic editor for example does that to add the standart "Open" item:
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
EndIfthe default value is the action to take when the 'Open' menuitem is clicked.
If you add something like "PureBasic.exe\shell\execute\command", and
set the default value to "C:\PureBasic\Compilers\pbcompiler.exe %1", and
set the default value of the "PureBasic.exe\shell\execute" key to "Execute",
you get another popupmenu item called "Execute", which will runn the
source file directly.
Timo