Creating Explorer Menu Extensions
Creating Explorer Menu Extensions
Does anyone have any information on adding options to the (explorer?) menus that pop up when you right click on files?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Nope, that creates shorcuts.. I'd like to add options to the explorer menu so you can pass files directly to it from any explorer window (Windows Explorer, not Internet Explorer).. Like WinZip does..
Looks like there is information http://msdn.microsoft.com/library/defau ... ndlers.asp but it looks like I'd need to create a COM DLL, and AFAIK that's not possible in PB at the moment?
Looks like there is information http://msdn.microsoft.com/library/defau ... ndlers.asp but it looks like I'd need to create a COM DLL, and AFAIK that's not possible in PB at the moment?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
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
EndIf
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
quidquid Latine dictum sit altum videtur
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
Hmm, I've been trying freak's code on Vista but I don't get it to work :S
What I want to do is to add an item in the right click menu for .jpg images.
Edit; this seems to work on Vista:
What I want to do is to add an item in the right click menu for .jpg images.
Edit; this seems to work on Vista:
Code: 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"
I like logic, hence I dislike humans but love computers.
Is there anything that works for both XP and Vista?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
@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.
This is strange because the registry entries allowing for execution by double clicking reside within the HKEY_CLASSES_ROOT tree! I have checked and the relevant entries have been added automatically by the shell!
I have confirmed by manually removing all of these registry entries and running your Win 9x code again!
This is an unexpected side-effect. Not a bad one because I was just about to add the code to do this anyhow! I am just a little puzzled why the system should add these entries automatically?
Any idea?
Thanks.
I may look like a mule, but I'm not a complete ass.