News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

IContextMenu

Started by donkey, November 18, 2007, 10:28:43 PM

Previous topic - Next topic

donkey

Here is a demo of the IContextMenu interface written in GoAsm. I will be uploading it to my website after testing but am posting it here so any bugs can be reported and fixed. The DLL is an astonishingly small 7KB, much smaller than the 12KB example that some companies are selling.. and with this one you can modify it all you like without restrictions, source is included and as usual I only require that it not be used in conjunction with any GPL licensed application.

Enjoy


I have decided to upload the example to my website, a few hours of testing here found no problems, I have also removed external dependancies and made it easier to modify the file types

http://www.assembler.ca/

You will find the example in GoAsm projects
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

I guess I should note that if you are changing the example to meet your needs, you can change the file types that will trigger the menu item by modifying the registry keys in DllUnregisterServer and DllRegisterServer


for example to have only folders trigger the extension change :

invoke RegCreateKey,HKEY_CLASSES_ROOT,"exefile\shellex\ContextMenuHandlers\IContextMenu",offset hKey

to

invoke RegCreateKey,HKEY_CLASSES_ROOT,"Folder\shellex\ContextMenuHandlers\IContextMenu",offset hKey

Don't forget to make the appropriate changes to DllUnregisterServer.

For cases where there are multiple files selected, you can loop DragQueryFile in order to get all of the file/folder names.

It is also possible to have multiple handlers in the same DLL by assigning each a different IID then coding a different IContextMenu handler for each or parsing them in ContextMenuQueryContextMenu.

Also, I used Ernest Murphy's COM examples for parts of the example so credit where credit is due, all the exported DLL functions were adapted from his MyCom example (DllGetClassObject, DllCanUnloadNow, DllUnregisterServer and DllRegisterServer)

If you have a bug report or need to know how to make a change don't hesitate to post here...
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

Oh Well,

I thought there would be more interest in this project but there are very few responses, thanks to all who have tested the example code. As I said it is available on my website under GoAsm projects. I will be modifying it occasionally so if you can use the code look in from time to time to see if there are any updates.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

I have modified the the IContextMenu example to add a context menu item for WinExplorer, with it you can open a folder in WinExplorer directly from Explorer. It is included in the WinExplorer zip file.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Mark Jones

Donkey, perhaps COM scares some people. :wink
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

donkey

Quote from: Mark Jones on November 25, 2007, 12:06:19 AM
Donkey, perhaps COM scares some people. :wink

Hi Mark,

Perhaps you're right, the levels of indirection are a bit confusing and documentation at a low enough level to make it useful to ASM programmers is virtually non-existant but that is why I occasionally put out a COM example.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

Hi jdoe,

I did include the code to dynamically create the objects but never really used it, I could not forsee a way that I could possibly have two menus open simultaneously so there was no chance of the data overlapping as it were. Also the reference counter is sort of pointless as well, there can only ever be one reference to the interface since again there is only one Explorer that uses it. I did not implement ContextMenuGetCommandString, it was not implemented in the MSDN example, I just translated the code and left it as such.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable