Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a shell extension context menu in Python (like dropbox)

I would like to create a context menu shell extension, to go with a program I write in Python.

I tried to work with a the demo in \Lib\site-packages\win32comext\shell\demos\servers\context_menu.py from pywin32 (here is the file) but it didn't work on my Win7 x64: It registered alright and added the registry keys, but the context menu didn't show up (even after a reboot). So I searched some more, and remembering that Dropbox saying that use only Python for development, I looked at their context menu registry keys. I found that they used: DropboxExt64.15.dll in their InProcServer32 (although I've read this and some other resources, I still don't know much about shell extensions). So it looks like they compiled a c/c++ code to a dll and use it to invoke python code.

My question is how did they do it? Where can I find resources (examples, guides, etc.) on how to use this method? What are the flaws of using the method in context_menu.py?

like image 996
zenpoy Avatar asked Oct 06 '12 11:10

zenpoy


1 Answers

Your extension needs to be 64 bit to show up in Explorer on Windows 7 x64. So you need to use 64 bit Python and 64 bit pywin32.

Most applications with shell extensions, like Dropbox, install two separate shell extensions, one for 32 bit processes and one for 64 bit processes.

Using 32-bit shell extensions in Windows 7 64-bit

like image 129
Meh Avatar answered Oct 19 '22 05:10

Meh