Explorer Shell extensions are here!

R.Marquez ny_r_marquez at yahoo.com
Tue Dec 9 21:32:28 CET 2003


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 <usenet at soraia.com> wrote in message news:<k85Bb.2630449$Of.400994 at news.easynews.com>...
> 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




More information about the Python-list mailing list