python类HKEY_LOCAL_MACHINE的实例源码

nsf2x.py 文件源码 项目:nsf2x 作者: adb014 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def OutlookPath():
    """Function to retrieve the path to Outlook from the registry"""
    aReg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
    aKey = winreg.OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE")
    # prepend unused variables with "dummy_" to keep PyLint happy
    dummy_n, v, dummy_t = winreg.EnumValue(aKey, 0)
    winreg.CloseKey(aKey)
    winreg.CloseKey(aReg)
    return v
env.py 文件源码 项目:teleport 作者: eomsoft 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _get_msbuild(self):
        # 14.0 = VS2015
        # 12.0 = VS2012
        #  4.0 = VS2008
        chk = ['14.0', '12.0', '4.0']

        p = None
        for c in chk:
            p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\MSBuild\ToolsVersions\{}'.format(c), r'MSBuildToolsPath')
            if p is not None:
                break

        return os.path.join(p[0], 'MSBuild.exe') if p is not None else None
env.py 文件源码 项目:teleport 作者: eomsoft 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _get_visual_studio_path(self):
        chk = ['14.0', '12.0', '4.0']
        p = None
        for c in chk:
            p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\VisualStudio\{}'.format(c), r'ShellFolder')
            if p is not None:
                break

        return p[0] if p is not None else None
env.py 文件源码 项目:teleport 作者: eomsoft 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def _get_perl(self):
        p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\perl', 'BinDir')
        return p[0] if p is not None else None
env.py 文件源码 项目:teleport 作者: eomsoft 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _get_nsis(self):
        p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\NSIS\Unicode', '')
        if p is None:
            p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\NSIS', '')
        return os.path.join(p[0], 'makensis.exe') if p is not None else None
env.py 文件源码 项目:teleport 作者: eomsoft 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _get_msbuild(self):
        # 14.0 = VS2015
        # 12.0 = VS2012
        #  4.0 = VS2008
        chk = ['14.0', '12.0', '4.0']

        p = None
        for c in chk:
            p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\MSBuild\ToolsVersions\{}'.format(c), r'MSBuildToolsPath')
            if p is not None:
                break

        return os.path.join(p[0], 'MSBuild.exe') if p is not None else None
env.py 文件源码 项目:teleport 作者: eomsoft 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _get_perl(self):
        p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\perl', 'BinDir')
        return p[0] if p is not None else None
env.py 文件源码 项目:teleport 作者: eomsoft 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _get_nsis(self):
        p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\NSIS\Unicode', '')
        if p is None:
            p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\NSIS', '')
        return os.path.join(p[0], 'makensis.exe') if p is not None else None
img.py 文件源码 项目:enkiWS 作者: juliettef 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def _create_win(self):
        try:
            key = _winreg.OpenKey(
                _winreg.HKEY_LOCAL_MACHINE,
                r'Software\Microsoft\Windows NT\CurrentVersion\Fonts')
        except EnvironmentError:
            try:
                key = _winreg.OpenKey(
                    _winreg.HKEY_LOCAL_MACHINE,
                    r'Software\Microsoft\Windows\CurrentVersion\Fonts')
            except EnvironmentError:
                raise FontNotFound('Can\'t open Windows font registry key')
        try:
            path = self._lookup_win(key, self.font_name, STYLES['NORMAL'], True)
            self.fonts['NORMAL'] = ImageFont.truetype(path, self.font_size)
            for style in ('ITALIC', 'BOLD', 'BOLDITALIC'):
                path = self._lookup_win(key, self.font_name, STYLES[style])
                if path:
                    self.fonts[style] = ImageFont.truetype(path, self.font_size)
                else:
                    if style == 'BOLDITALIC':
                        self.fonts[style] = self.fonts['BOLD']
                    else:
                        self.fonts[style] = self.fonts['NORMAL']
        finally:
            _winreg.CloseKey(key)
installer.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def getWindowsEnvironmentKey(scope):
    assert scope in ('user', 'system')
    root = winreg.HKEY_CURRENT_USER
    subkey = 'Environment'

    if scope != 'user':
        root = winreg.HKEY_LOCAL_MACHINE
        subkey = r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'

    return (root, subkey)
img.py 文件源码 项目:python-flask-security 作者: weinbergdavid 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _create_win(self):
        try:
            key = _winreg.OpenKey(
                _winreg.HKEY_LOCAL_MACHINE,
                r'Software\Microsoft\Windows NT\CurrentVersion\Fonts')
        except EnvironmentError:
            try:
                key = _winreg.OpenKey(
                    _winreg.HKEY_LOCAL_MACHINE,
                    r'Software\Microsoft\Windows\CurrentVersion\Fonts')
            except EnvironmentError:
                raise FontNotFound('Can\'t open Windows font registry key')
        try:
            path = self._lookup_win(key, self.font_name, STYLES['NORMAL'], True)
            self.fonts['NORMAL'] = ImageFont.truetype(path, self.font_size)
            for style in ('ITALIC', 'BOLD', 'BOLDITALIC'):
                path = self._lookup_win(key, self.font_name, STYLES[style])
                if path:
                    self.fonts[style] = ImageFont.truetype(path, self.font_size)
                else:
                    if style == 'BOLDITALIC':
                        self.fonts[style] = self.fonts['BOLD']
                    else:
                        self.fonts[style] = self.fonts['NORMAL']
        finally:
            _winreg.CloseKey(key)
img.py 文件源码 项目:blender 作者: gastrodia 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _create_win(self):
        try:
            key = _winreg.OpenKey(
                _winreg.HKEY_LOCAL_MACHINE,
                r'Software\Microsoft\Windows NT\CurrentVersion\Fonts')
        except EnvironmentError:
            try:
                key = _winreg.OpenKey(
                    _winreg.HKEY_LOCAL_MACHINE,
                    r'Software\Microsoft\Windows\CurrentVersion\Fonts')
            except EnvironmentError:
                raise FontNotFound('Can\'t open Windows font registry key')
        try:
            path = self._lookup_win(key, self.font_name, STYLES['NORMAL'], True)
            self.fonts['NORMAL'] = ImageFont.truetype(path, self.font_size)
            for style in ('ITALIC', 'BOLD', 'BOLDITALIC'):
                path = self._lookup_win(key, self.font_name, STYLES[style])
                if path:
                    self.fonts[style] = ImageFont.truetype(path, self.font_size)
                else:
                    if style == 'BOLDITALIC':
                        self.fonts[style] = self.fonts['BOLD']
                    else:
                        self.fonts[style] = self.fonts['NORMAL']
        finally:
            _winreg.CloseKey(key)
WinEnum.py 文件源码 项目:WindowsEnumeration 作者: tdmathison 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def walk_registry(hkey, path, access_flags, keywords, onerror=None):
    """ Walks all keys of the registry searching for values that match any of the provided 'keywords'. """
    try:
        key = winreg.OpenKey(hkey, path, access_flags)
    except OSError as e:
        if onerror is not None:
            onerror(e)
        return

    i = 0
    sub_keys = []
    with key:
        while True:
            try:
                sub_keys.append(winreg.EnumKey(key, i))
            except OSError:
                break
            i += 1

        i = 0
        while True:
            try:
                data = winreg.EnumValue(key, i)
                i += 1
                for keyword in keywords:
                    if keyword.lower() in str(data[0]).lower():
                        if hkey == winreg.HKEY_LOCAL_MACHINE:
                            hive = 'HKLM\\'
                        else:
                            hive = 'HKCU\\'

                        print('{0}\\{1}\\{2} = {3}'.format(hive, path, data[0], data[1]))
            except OSError:
                break

        for key in sub_keys:
            next_path = os.path.join(path, key)
            for item in walk_registry(hkey, next_path, access_flags, keywords, onerror):
                yield item
img.py 文件源码 项目:yatta_reader 作者: sound88 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def _create_win(self):
        try:
            key = _winreg.OpenKey(
                _winreg.HKEY_LOCAL_MACHINE,
                r'Software\Microsoft\Windows NT\CurrentVersion\Fonts')
        except EnvironmentError:
            try:
                key = _winreg.OpenKey(
                    _winreg.HKEY_LOCAL_MACHINE,
                    r'Software\Microsoft\Windows\CurrentVersion\Fonts')
            except EnvironmentError:
                raise FontNotFound('Can\'t open Windows font registry key')
        try:
            path = self._lookup_win(key, self.font_name, STYLES['NORMAL'], True)
            self.fonts['NORMAL'] = ImageFont.truetype(path, self.font_size)
            for style in ('ITALIC', 'BOLD', 'BOLDITALIC'):
                path = self._lookup_win(key, self.font_name, STYLES[style])
                if path:
                    self.fonts[style] = ImageFont.truetype(path, self.font_size)
                else:
                    if style == 'BOLDITALIC':
                        self.fonts[style] = self.fonts['BOLD']
                    else:
                        self.fonts[style] = self.fonts['NORMAL']
        finally:
            _winreg.CloseKey(key)
putty.py 文件源码 项目:Packages 作者: Keypirinha 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _autodetect_official_installreg(self):
        try:
            key = winreg.OpenKey(
                winreg.HKEY_LOCAL_MACHINE,
                "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\PUTTY_is1",
                access=winreg.KEY_READ | winreg.KEY_WOW64_32KEY)
            value = winreg.QueryValueEx(key, "InstallLocation")[0]
            winreg.CloseKey(key)
            exe_file = os.path.join(value, self.EXE_NAME_OFFICIAL)
            if os.path.exists(exe_file):
                return exe_file
        except:
            pass
        return None
filezilla.py 文件源码 项目:Packages 作者: Keypirinha 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _autodetect_official_installreg(self):
        try:
            key = winreg.OpenKey(
                winreg.HKEY_LOCAL_MACHINE,
                "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\FileZilla Client",
                access=winreg.KEY_READ | winreg.KEY_WOW64_32KEY)
            value = winreg.QueryValueEx(key, "InstallLocation")[0]
            winreg.CloseKey(key)
            exe_file = os.path.join(value, self.EXE_NAME_OFFICIAL)
            if os.path.exists(exe_file):
                return exe_file
        except:
            pass
        return None
winscp.py 文件源码 项目:Packages 作者: Keypirinha 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _autodetect_official_installreg(self):
        try:
            key = winreg.OpenKey(
                winreg.HKEY_LOCAL_MACHINE,
                "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\winscp3_is1",
                access=winreg.KEY_READ | winreg.KEY_WOW64_32KEY)
            value = winreg.QueryValueEx(key, "InstallLocation")[0]
            winreg.CloseKey(key)
            exe_file = os.path.join(value, self.EXE_NAME_OFFICIAL)
            if os.path.exists(exe_file):
                return exe_file
        except:
            pass
        return None
Windows.py 文件源码 项目:lib9 作者: Jumpscale 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _getHiveAndKey(self, fullKey):
        '''Split a windows registry key in two parts: the hive (hkey) and the registry key
        Eg: "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion" will return: (_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion")
        '''
        str_hkey, str_key = fullKey.split('\\', 1)
        hiveType = WinRegHiveType.getByName(str_hkey.lower())
        return hiveType.hive, str_key
Windows.py 文件源码 项目:lib9 作者: Jumpscale 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def exportRegKeysToString(self, key):
        """Exports Windows registry key to a string

        This function exports a Windows registry key to a string (ini-file format).

        @param key: The registry key to export. The key should include the section. Eg. "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion"
        @type key: string
        """
        strBuffer = StringIO()
        regfile = IniFile(strBuffer)
        self._addValuesRecursively(regfile, key)
        return regfile.getContent()
Windows.py 文件源码 项目:lib9 作者: Jumpscale 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def exportRegKeysToFile(self, key, path):
        """Exports Windows registry key to a file

        This function exports a Windows registry key to an ini-file.

        @param key: The registry key to export. The key should include the section. Eg. "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion"
        @type key: string

        @param path: The path of the file to export to
        @type path: string
        """
        j.sal.fs.writeFile(path, self.exportRegKeysToString(key))


问题


面经


文章

微信
公众号

扫码关注公众号