Python winreg.HKEY_CLASSES_ROOT Examples

The following are 4 code examples of winreg.HKEY_CLASSES_ROOT(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module winreg , or try the search function .
Example #1
Source File: utils.py    From stata_kernel with GNU General Public License v3.0 6 votes vote down vote up
def win_find_path():
    import winreg
    reg = winreg.ConnectRegistry(None, winreg.HKEY_CLASSES_ROOT)
    subkeys = [
        r'Stata16Do\shell\do\command', r'Stata15Do\shell\do\command',
        r'Stata14Do\shell\do\command', r'Stata13Do\shell\do\command',
        r'Stata12Do\shell\do\command']

    fpath = ''
    for subkey in subkeys:
        try:
            key = winreg.OpenKey(reg, subkey)
            fpath = winreg.QueryValue(key, None).split('"')[1]
        except FileNotFoundError:
            pass
        if fpath:
            break

    return fpath 
Example #2
Source File: __init__.py    From SendCode with MIT License 6 votes vote down vote up
def cmder_setup():
    global CMDER_SETUP

    if CMDER_SETUP:
        return

    try:
        akey = winreg.OpenKey(
            winreg.HKEY_CLASSES_ROOT, "Directory\\shell\\Cmder\\command", 0, winreg.KEY_READ)
        command = winreg.QueryValueEx(akey, "")[0]
        conemu_base_dir = os.path.join(
            RE_CMDER.match(command).group(1), "vendor", "conemu-maximus5", "ConEmu")
        if os.path.exists(conemu_base_dir):
            if conemu_base_dir not in os.environ["PATH"]:
                os.environ["PATH"] = conemu_base_dir + ";" + os.environ["PATH"]
                CMDER_SETUP = True
    except Exception:
        return 
Example #3
Source File: __init__.py    From SendCode with MIT License 6 votes vote down vote up
def conemu_setup():
    global CONEMU_SETUP

    if CONEMU_SETUP:
        return

    try:
        akey = winreg.OpenKey(
            winreg.HKEY_CLASSES_ROOT, "Directory\\shell\\ConEmu Here\\command", 0, winreg.KEY_READ)
        command = winreg.QueryValueEx(akey, "")[0]
        conemu_base_dir = os.path.join(RE_CONEMU.match(command).group(1), "ConEmu")
        if os.path.exists(conemu_base_dir):
            if conemu_base_dir not in os.environ["PATH"]:
                os.environ["PATH"] = conemu_base_dir + ";" + os.environ["PATH"]
                CONEMU_SETUP = True
    except Exception:
        return 
Example #4
Source File: local_client.py    From galaxy_blizzard_plugin with MIT License 5 votes vote down vote up
def __init__(self, update_statuses):
        self._WIN_REG_SHELL = (winreg.HKEY_CLASSES_ROOT, r"battlenet\shell\open\command")
        super().__init__(update_statuses)
        self.uninstaller = self.set_uninstaller()
        self._exe = self._find_exe()