/[cvs]/nfo/projects/mess/src/client/windows/context_menu.py
ViewVC logotype

Diff of /nfo/projects/mess/src/client/windows/context_menu.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Sat Jun 3 00:07:32 2006 UTC revision 1.2 by joko, Sat Jun 3 00:41:42 2006 UTC
# Line 18  IShellExtInit_Methods = ["Initialize"] Line 18  IShellExtInit_Methods = ["Initialize"]
18    
19  class ShellExtension:  class ShellExtension:
20      _reg_progid_ = "Python.ShellExtension.ContextMenu"      _reg_progid_ = "Python.ShellExtension.ContextMenu"
21      _reg_desc_ = "Python Sample Shell Extension (context menu)"      _reg_name_ = "MessClient"
22        _reg_desc_ = "Mess Shell Extension"
23      _reg_clsid_ = "{CED0336C-C9EE-4a7f-8D7F-C660393C381F}"      _reg_clsid_ = "{CED0336C-C9EE-4a7f-8D7F-C660393C381F}"
24      _com_interfaces_ = [shell.IID_IShellExtInit, shell.IID_IContextMenu]      _com_interfaces_ = [shell.IID_IShellExtInit, shell.IID_IContextMenu]
25      _public_methods_ = IContextMenu_Methods + IShellExtInit_Methods      _public_methods_ = IContextMenu_Methods + IShellExtInit_Methods
# Line 77  class ShellExtension: Line 78  class ShellExtension:
78      def GetCommandString(self, cmd, typ):      def GetCommandString(self, cmd, typ):
79          return "Hello from Python!!"          return "Hello from Python!!"
80    
81    
82  def DllRegisterServer():  def DllRegisterServer():
83      import _winreg      import _winreg
84      key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,      
85                              "Python.File\\shellex")      
86      subkey = _winreg.CreateKey(key, "ContextMenuHandlers")      
87      subkey2 = _winreg.CreateKey(subkey, "PythonSample")      # extended (via http://mail.python.org/pipermail/python-list/2003-December/198390.html)
88      _winreg.SetValueEx(subkey2, None, 0, _winreg.REG_SZ, ShellExtension._reg_clsid_)      
89        # for folders
90        folder_key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "Folder\\shellex")
91        folder_subkey = _winreg.CreateKey(folder_key, "ContextMenuHandlers")
92        folder_subkey2 = _winreg.CreateKey(folder_subkey, ShellExtension._reg_name_)
93        _winreg.SetValueEx(folder_subkey2, None, 0, _winreg.REG_SZ, ShellExtension._reg_clsid_)
94    
95        # for files
96        file_key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "*\\shellex")
97        file_subkey = _winreg.CreateKey(file_key, "ContextMenuHandlers")
98        file_subkey2 = _winreg.CreateKey(file_subkey, ShellExtension._reg_name_)
99        _winreg.SetValueEx(file_subkey2, None, 0, _winreg.REG_SZ, ShellExtension._reg_clsid_)
100    
101      print ShellExtension._reg_desc_, "registration complete."      print ShellExtension._reg_desc_, "registration complete."
102    
103    
104  def DllUnregisterServer():  def DllUnregisterServer():
105      import _winreg      import _winreg
106    
107        # extended (via http://mail.python.org/pipermail/python-list/2003-December/198390.html)
108    
109      try:      try:
110          key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,          # for folders
111                                  "Python.File\\shellex\\ContextMenuHandlers\\PythonSample")          folder_key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
112                                    "Folder\\shellex\\ContextMenuHandlers\\" + ShellExtension._reg_name_)
113            # for files
114            file_key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
115                                    "*\\shellex\\ContextMenuHandlers\\" + ShellExtension._reg_name_)
116      except WindowsError, details:      except WindowsError, details:
117          import errno          import errno
118          if details.errno != errno.ENOENT:          if details.errno != errno.ENOENT:

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed