def get_control_panel_applets(use_categories=True): """ http://msdn.microsoft.com/en-us/library/cc144195(v=VS.85).aspx """ control_panel_applets = [] cpi = ControlPanelInfo() for clsid in registry.walk_keys( win32con.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace", key_filter_regex=r"\{[A-F0-9-]+\}"): try: canonical_name = registry.get_value(win32con.HKEY_CLASSES_ROOT, "CLSID\\%s" % clsid, "System.ApplicationName") except Exception, e: logging.error("Error opening registry entry %s: %s", "CLSID\\%s" % clsid, e) continue if canonical_name: canonical_name = canonical_name[1] else: continue try: display_name = registry.get_value(win32con.HKEY_CLASSES_ROOT, "CLSID\\%s" % clsid, "") except Exception, e: logging.error("Error opening registry entry %s: %s", "CLSID\\%s" % clsid, e) continue
def get_control_panel_applets(): """ http://msdn.microsoft.com/en-us/library/cc144195(v=VS.85).aspx """ control_panel_applets = [] cpi = ControlPanelInfo() for clsid in registry.walk_keys(win32con.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace", key_filter_regex=r"\{[A-F0-9-]+\}"): canonical_name = registry.get_value( win32con.HKEY_CLASSES_ROOT, "CLSID\\%s" % clsid, "System.ApplicationName") if canonical_name: canonical_name = canonical_name[1] display_name = registry.get_value( win32con.HKEY_CLASSES_ROOT, "CLSID\\%s" % clsid, "") if display_name and display_name[1].startswith("@"): display_name = read_mui_string_from_reg( win32con.HKEY_CLASSES_ROOT, "CLSID\\%s" % clsid, "") elif display_name: display_name = unicode(display_name[1]) try: localized_name = registry.get_value( win32con.HKEY_CLASSES_ROOT, "CLSID\\%s" % clsid, "LocalizedString") if localized_name[0] == win32con.REG_EXPAND_SZ: localized_name = localized_name[2] else: localized_name = localized_name[1] if localized_name.startswith("@"): localized_name = read_mui_string_from_reg( win32con.HKEY_CLASSES_ROOT, "CLSID\\%s" % clsid, "LocalizedString") except: localized_name = None try: command = registry.get_value( win32con.HKEY_CLASSES_ROOT, "CLSID\\%s\\Shell\\Open\\Command" % clsid, "") if command[0] == win32con.REG_EXPAND_SZ: command = command[2] else: command = command[1] except: command = None if localized_name: logging.error(u"%s: %s", canonical_name, unicodedata.normalize('NFKD', localized_name).encode('ascii', 'ignore')) #logging.error(u"name: %s", localized_name) else: logging.error(u"%s: %s", canonical_name, display_name) #print clsid, canonical_name, display_name, localized_name, command if not (localized_name or display_name): continue name = localized_name if localized_name else display_name name = unicodedata.normalize('NFKD', name).encode('ascii', 'ignore').lower() control_panel_applets.append( shortcuts.Shortcut( u"%s (control panel)" % name, shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, command if command else "control.exe /name %s" % canonical_name )) try: tasks_file = registry.get_value( win32con.HKEY_CLASSES_ROOT, "CLSID\\%s" % clsid, "System.Software.TasksFileUrl") if tasks_file: if tasks_file[0] == win32con.REG_EXPAND_SZ: tasks_file = tasks_file[2] else: tasks_file = tasks_file[1] if os.path.isfile(tasks_file) and os.path.splitext(tasks_file)[1].lower() == ".xml": control_panel_applets.extend(read_task_links_xml(tasks_file)) except: tasks_file = None # In Windows7 all *.cpl files in windows/system32 directory are disabled # by default due to different means of accessing their functionality # (see above code). However, we are going to process them anyway cpl_disabled_panels = [] for cplfile, _, _ in registry.walk_values(win32con.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\don't load", valuetypes = (win32con.REG_SZ,)): cpl_disabled_panels.append(cplfile.lower()) # List control-panel applets from system directory cpl_files = [cpl for cpl in glob.iglob(os.path.join(os.path.expandvars("${WINDIR}"), "system32", "*.cpl")) if os.path.basename(cpl).lower() not in cpl_disabled_panels] # Add control-panel applets from custom locations, read from registry for _, cplfile, _ in registry.walk_values( win32con.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls", valuetypes = (win32con.REG_EXPAND_SZ, win32con.REG_SZ), autoexpand = True): if not os.path.isfile(cplfile): continue if os.path.basename(cplfile).lower() in cpl_disabled_panels: continue cpl_files.append(cplfile) # Read descriptions of control-panel applets from the .cpl files directly for cplfile in cpl_files: for file, name, desc, index in cpi.get_cplinfo(cplfile): name = unicodedata.normalize('NFKD', name).encode('ascii', 'ignore').lower() #name = xml_escape(name) control_panel_applets.append( shortcuts.Shortcut( name + " (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,Control_RunDLL \"%s\",@%d" % (cplfile, index) )) del cpi # Extend control-panel applets list with few useful shortcuts that can't be # reached from the control-panel directly control_panel_applets.extend([ shortcuts.Shortcut( u"control panel", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,Control_RunDLL"), shortcuts.Shortcut( u"about microsoft windows (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,ShellAboutW "), shortcuts.Shortcut( u"safely remove hardware", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,Control_RunDLL HotPlug.dll"), ]) """ shortcuts.Shortcut( u"unplug or eject hardware", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,Control_RunDLL HotPlug.dll"), shortcuts.Shortcut( u"device manager (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, #"rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,1" "rundll32.exe devmgr.dll DeviceManager_Execute"), shortcuts.Shortcut( u"disk management (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "diskmgmt.msc"), shortcuts.Shortcut( u"scheduled tasks (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "control.exe schedtasks"), shortcuts.Shortcut( u"scanners and cameras (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "control.exe sticpl.cpl"), shortcuts.Shortcut( u"removable storage (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "ntmsmgr.msc"), shortcuts.Shortcut( u"performance monitor (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "perfmon.msc"), shortcuts.Shortcut( u"private character editor (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "eudcedit.msc"), """ control_panel_applets.extend( read_task_links_xml(xml=read_default_windows7_tasklist_xml())) return control_panel_applets
def get_control_panel_applets(): if utils.platform_windows_vista() or utils.platform_windows_7(): from enso.contrib.open.platform.win32 import control_panel_win7 return control_panel_win7.get_control_panel_applets() control_panel_applets = [] cpi = ControlPanelInfo() # Read disabled ("don't load") control-panels from registry # Note: Control-panel applets can be disabled using TweakUI cpl_disabled_panels = [] for cplfile, _, _ in registry.walk_values(win32con.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\don't load", valuetypes = (win32con.REG_SZ,)): cpl_disabled_panels.append(cplfile.lower()) # List control-panel applets from system directory cpl_files = [cpl for cpl in glob.iglob(os.path.join(os.path.expandvars("${WINDIR}"), "system32", "*.cpl")) if os.path.basename(cpl).lower() not in cpl_disabled_panels] # Add control-panel applets from custom locations, read from registry for _, cplfile, _ in registry.walk_values( win32con.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls", valuetypes = (win32con.REG_EXPAND_SZ, win32con.REG_SZ), autoexpand = True): if not os.path.isfile(cplfile): continue if os.path.basename(cplfile).lower() in cpl_disabled_panels: continue cpl_files.append(cplfile) # Read descriptions of control-panel applets from the .cpl files directly for cplfile in cpl_files: for file, name, desc, index in cpi.get_cplinfo(cplfile): name = unicodedata.normalize('NFKD', name).encode('ascii', 'ignore') name = name.lower() #name = xml_escape(name) control_panel_applets.append( shortcuts.Shortcut( name + " (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,Control_RunDLL \"%s\",@%d" % (cplfile, index) )) del cpi # Extend control-panel applets list with few useful shortcuts that can't be # reached from the control-panel directly control_panel_applets.extend([ shortcuts.Shortcut( u"control panel", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,Control_RunDLL"), shortcuts.Shortcut( u"about microsoft windows (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,ShellAboutW "), shortcuts.Shortcut( u"safely remove hardware", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,Control_RunDLL HotPlug.dll"), shortcuts.Shortcut( u"unplug or eject hardware", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "rundll32.exe shell32.dll,Control_RunDLL HotPlug.dll"), shortcuts.Shortcut( u"device manager (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, #"rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,1" "rundll32.exe devmgr.dll DeviceManager_Execute"), shortcuts.Shortcut( u"disk management (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "diskmgmt.msc"), shortcuts.Shortcut( u"scheduled tasks (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "control.exe schedtasks"), shortcuts.Shortcut( u"scanners and cameras (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "control.exe sticpl.cpl"), shortcuts.Shortcut( u"removable storage (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "ntmsmgr.msc"), shortcuts.Shortcut( u"performance monitor (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "perfmon.msc"), shortcuts.Shortcut( u"private character editor (control panel)", shortcuts.SHORTCUT_TYPE_CONTROL_PANEL, "eudcedit.msc"), ]) return control_panel_applets