Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Explorer Shell extensions are here!

0 views
Skip to first unread message

R.Marquez

unread,
Dec 8, 2003, 2:37:00 PM12/8/03
to
I just happened to bump into this today when I went to the Win32
Python Extensions page. I think the M.H. and his team are a bit too
modest.

Quote:
"win32com.shell grows many more interfaces, allowing Python to operate
as a nearly complete shell extension, and to interact with the shell
interfaces. See the win32comext\shell\demos\server directory for
examples."

This is something I had been waiting for a while, and even submited a
"feature request" about it. So, since I hadn't heard any thing about
it, I figure there may be a few more like me that would enjoy knowing
about this.

(Now, if I could only figure out how to make a context menu that would
show up for any file of folder... ;)

-Ruben

Joe Francia

unread,
Dec 8, 2003, 3:26:57 PM12/8/03
to
R.Marquez wrote:
> I just happened to bump into this today when I went to the Win32
> Python Extensions page. I think the M.H. and his team are a bit too
> modest.
>
> Quote:
> "win32com.shell grows many more interfaces, allowing Python to operate
> as a nearly complete shell extension, and to interact with the shell
> interfaces. See the win32comext\shell\demos\server directory for
> examples."
>
> This is something I had been waiting for a while, and even submited a
> "feature request" about it. So, since I hadn't heard any thing about
> it, I figure there may be a few more like me that would enjoy knowing
> about this.

I _do_ enjoy knowing about this ;>) Thanks for the tip.

> (Now, if I could only figure out how to make a context menu that would
> show up for any file of folder... ;)

In the demo "context_menu.py", replace the register and unregister bits
with the code below. Run context_menu.py with either the --register or
--unregister switch, as appropiate.

def DllRegisterServer():
import _winreg
folder_key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
"Folder\\shellex")
folder_subkey = _winreg.CreateKey(folder_key, "ContextMenuHandlers")
folder_subkey2 = _winreg.CreateKey(folder_subkey, "PythonSample")
_winreg.SetValueEx(folder_subkey2, None, 0, _winreg.REG_SZ,
ShellExtension._reg_clsid_)

file_key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
"*\\shellex")
file_subkey = _winreg.CreateKey(file_key, "ContextMenuHandlers")
file_subkey2 = _winreg.CreateKey(file_subkey, "PythonSample")
_winreg.SetValueEx(file_subkey2, None, 0, _winreg.REG_SZ,
ShellExtension._reg_clsid_)

print ShellExtension._reg_desc_, "registration complete."

def DllUnregisterServer():
import _winreg
try:
folder_key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,

"Folder\\shellex\\ContextMenuHandlers\\PythonSample")
file_key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,

"*\\shellex\\ContextMenuHandlers\\PythonSample")
except WindowsError, details:
import errno
if details.errno != errno.ENOENT:
raise
print ShellExtension._reg_desc_, "unregistration complete."

Peace,
Joe

John J. Lee

unread,
Dec 9, 2003, 11:58:31 AM12/9/03
to
ny_r_m...@yahoo.com (R.Marquez) writes:
[...]

> (Now, if I could only figure out how to make a context menu that would
> show up for any file of folder... ;)

You can do shell extension stuff quite easily with ctypes, too.
There's a good O'Reilly book on the subject (based on VB, but that
doesn't matter). Use the CVS version, not the tarball, there's at
least one important COM bug fixed there.

One tip: some common COM interfaces don't have type libraries, but
it's easy to write your own interface specifications for ctypes, just
by following the very readable output of the ctypes script (equivalent
of gen_py in win32com) that usually does this job for you.


John

R.Marquez

unread,
Dec 9, 2003, 3:32:28 PM12/9/03
to
Great! That is just what I needed. Thank you, M.H. and all other
Pythonistas for all your great work and generous spirit.

-Ruben

Joe Francia <use...@soraia.com> wrote in message news:<k85Bb.2630449$Of.4...@news.easynews.com>...

R.Marquez

unread,
Dec 10, 2003, 9:01:29 AM12/10/03
to
j...@pobox.com (John J. Lee) wrote in message news:<87brqis...@pobox.com>...
> ny_r_m...@yahoo.com (R.Marquez) writes:

> You can do shell extension stuff quite easily with ctypes, too.
> There's a good O'Reilly book on the subject (based on VB, but that
> doesn't matter). Use the CVS version, not the tarball, there's at
> least one important COM bug fixed there.
>
> One tip: some common COM interfaces don't have type libraries, but
> it's easy to write your own interface specifications for ctypes, just
> by following the very readable output of the ctypes script (equivalent
> of gen_py in win32com) that usually does this job for you.

John,

I appreciate the tip. I'll have to take a deeper look at ctypes as well.

-Ruben

0 new messages