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
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
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
-Ruben
Joe Francia <use...@soraia.com> wrote in message news:<k85Bb.2630449$Of.4...@news.easynews.com>...
> 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