当前位置: 首页>>代码示例>>Python>>正文


Python _winreg.KEY_READ属性代码示例

本文整理汇总了Python中_winreg.KEY_READ属性的典型用法代码示例。如果您正苦于以下问题:Python _winreg.KEY_READ属性的具体用法?Python _winreg.KEY_READ怎么用?Python _winreg.KEY_READ使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在_winreg的用法示例。


在下文中一共展示了_winreg.KEY_READ属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _open_windows_native_key

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def _open_windows_native_key(self, key, sub_key):
        """
        Opens a windows registry key using the OS bitness-based version of the
        registry view.
        This method eventually calls the _winreg.OpenKey() method.

        This is useful because if we're running a 32-bit python interpreter, by
        default _winreg accesses the 32-bit registry view. This is a problem on
        64-bit OSes as it limits us to registries of 32-bit applications.
        """
        import _winreg

        python_bitness, linkage = platform.architecture()

        # If we're running 32-bit python, by default _winreg accesses the
        # 32-bit registry view. This is a problem on 64-bit OSes.
        if python_bitness == '32bit' and platform.machine().endswith('64'):
            # Force _winreg to access the 64-bit registry view with the access
            # map as _winreg.KEY_WOW64_64KEY
            return _winreg.OpenKey(key, sub_key, 0, _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY)
        else:
            return _winreg.OpenKey(key, sub_key)

        return key 
开发者ID:ni,项目名称:python_labview_automation,代码行数:26,代码来源:labview.py

示例2: win32_reg_read

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def win32_reg_read (self, keyname, path):
		try:
			import _winreg
			mode = _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY
			key = _winreg.OpenKey(keyname, path, 0, mode)
			count = _winreg.QueryInfoKey(key)[0]
		except:
			return None
		data = {}
		for i in range(count):
			try:
				name, value, tt = _winreg.EnumValue(key, i)
			except OSError as e:
				break
			data[name] = (tt, value) 
		return data 
开发者ID:skywind3000,项目名称:terminal,代码行数:18,代码来源:terminal.py

示例3: get_all_values

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def get_all_values(self):
        schema = {}
        for subkey in self:
            schema[subkey.name] = subkey.get_all_values()

        key = winreg.OpenKeyEx(self._root, self.subkey, 0, winreg.KEY_READ | self._flags)
        try:
            with key:
                for i in count():
                    vname, value, vtype = winreg.EnumValue(key, i)
                    value = get_value_from_tuple(value, vtype)
                    if value:
                        schema[vname or ''] = value
        except OSError:
            pass

        return PythonWrappedDict(schema) 
开发者ID:sarugaku,项目名称:pythonfinder,代码行数:19,代码来源:_registry.py

示例4: readKey

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def readKey(self, hkey, key_name, value_name = '', ignore_errors = False):
        if sys.platform != 'win32':
            return None
        try:
            if DEBUG:
                print >> sys.stderr, 'win32regcheck: Opening', key_name, value_name
            full_key = _winreg.OpenKey(hkey, key_name, 0, _winreg.KEY_READ)
            if DEBUG:
                print >> sys.stderr, 'win32regcheck: Open returned', full_key
            value_data, value_type = _winreg.QueryValueEx(full_key, value_name)
            if DEBUG:
                print >> sys.stderr, 'win32regcheck: Read', value_data, value_type
            _winreg.CloseKey(full_key)
            return value_data
        except:
            if not ignore_errors:
                print_exc(file=sys.stderr)
                print_stack()
            return None 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:21,代码来源:win32regchecker.py

示例5: _iter_files

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def _iter_files(rsa_key, base_dir=None):
    try:
        if isinstance(rsa_key, Crypto.PublicKey.RSA.RsaKey):
            if base_dir:
                if os.path.isdir(base_dir):
                    return os.path.walk(base_dir, lambda _, dirname, files: [globals()['tasks'].put_nowait((encrypt_file, (os.path.join(dirname, filename), rsa_key))) for filename in files], None)
                else:
                    util.log("Target directory '{}' not found".format(base_dir))
            else:
                cipher = Crypto.Cipher.PKCS1_OAEP.new(rsa_key)
                reg_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, globals()['registry_key'], 0, _winreg.KEY_READ)
                i = 0
                while True:
                    try:
                        filename, key, _ = _winreg.EnumValue(reg_key, i)
                        key = cipher.decrypt(base64.b64decode(key))
                        globals()['tasks'].put_nowait((decrypt_file, (filename, key)))
                        i += 1
                    except:
                        _winreg.CloseKey(reg_key)
                        break
    except Exception as e:
        util.log('{} error: {}'.format(_iter_files.__name__, str(e))) 
开发者ID:malwaredllc,项目名称:byob,代码行数:25,代码来源:ransom.py

示例6: uninstall_all

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def uninstall_all():
    """uninstalls PyXLL from all installed Excel versions"""
    for wow64_flags in (winreg.KEY_WOW64_64KEY, winreg.KEY_WOW64_32KEY):
        for root in _root_keys.keys():
            try:
                flags = wow64_flags | winreg.KEY_READ
                office_root = winreg.OpenKey(root, r"Software\Microsoft\Office", 0, flags)
            except WindowsError:
                continue

            # look for all installed versions of Excel and uninstall PyXLL
            i = 0
            while True:
                try:
                    subkey = winreg.EnumKey(office_root, i)
                except WindowsError:
                    break

                match = re.match("^(\d+(?:\.\d+)?)$", subkey)
                if match:
                    office_version = match.group(1)
                    uninstall(office_root, office_version, wow64_flags)
                i += 1

            winreg.CloseKey(office_root) 
开发者ID:pyxll,项目名称:pyxll-examples,代码行数:27,代码来源:uninstall.py

示例7: CheckForMceDriver

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def CheckForMceDriver():
    """
    Checks the HID registry values.
    """
    HID_SUB_KEY = "SYSTEM\\CurrentControlSet\\Services\\HidIr\\Remotes\\745a17a0-74d3-11d0-b6fe-00a0c90f57d"
    noKeyCount = 0
    ValuesToCheck = ['a','b']
    for a in ValuesToCheck:
        tmpkey = HID_SUB_KEY+a
        try:
            key = reg.OpenKey(reg.HKEY_LOCAL_MACHINE, tmpkey, 0, reg.KEY_READ)
        except WindowsError:
            noKeyCount = noKeyCount + 1
            continue
    if noKeyCount == len(ValuesToCheck):
        return False
    return True 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:19,代码来源:__init__.py

示例8: GetMpcHcPath

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def GetMpcHcPath(self):
        """
        Get the path of MPC-HC's installation directory through querying
        the Windows registry.
        """
        try:
            if "PROCESSOR_ARCHITEW6432" in environ:
                args = [_winreg.HKEY_CURRENT_USER,
                    "Software\MPC-HC\MPC-HC"]
                args.extend((0, _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY))
            else:
                args = [_winreg.HKEY_CURRENT_USER,
                    "Software\Gabest\Media Player Classic"]
            mpc = _winreg.OpenKey(*args)
            mpcPath =_winreg.QueryValueEx(mpc, "ExePath")[0]
            _winreg.CloseKey(mpc)
        except WindowsError:
            mpcPath = None
        return mpcPath 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:21,代码来源:__init__.py

示例9: is_uac_enabled

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def is_uac_enabled():
    """
    Note:
      check uac is enabled or not from reg value.
    Returns:
     True if uac is enabled, False if uac is disabled.
    """
    import _winreg    
    
    reg_key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System', 0, _winreg.KEY_READ)
    value, regtype = _winreg.QueryValueEx(reg_key, 'EnableLUA')
    
    if value == 1:
        #reg value 1 means UAC is enabled
        return True
    else:
        return False 
开发者ID:samuraitaiga,项目名称:py-metatrader,代码行数:19,代码来源:mt4.py

示例10: check_installed

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def check_installed():
    ret = True
    runkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
        r"Software\Microsoft\Windows\CurrentVersion\Run", 0, winreg.KEY_READ)
    try:
        winreg.QueryValueEx(runkey, "Px")
    except:
        ret = False
    winreg.CloseKey(runkey)

    return ret 
开发者ID:genotrance,项目名称:px,代码行数:13,代码来源:px.py

示例11: break_sopcast

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def break_sopcast():
    if xbmc.getCondVisibility('system.platform.windows'):
        import _winreg
        aReg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
        try:
            aKey = _winreg.OpenKey(aReg, r'SOFTWARE\SopCast\Player\InstallPath', 0, _winreg.KEY_READ)
            name, value, type = _winreg.EnumValue(aKey, 0)
            codec_file = os.path.join(os.path.join(value.replace("SopCast.exe", "")), 'codec', 'sop.ocx.old')
            _winreg.CloseKey(aKey)
            if xbmcvfs.exists(codec_file): xbmcvfs.rename(codec_file,
                                                          os.path.join(os.path.join(value.replace("SopCast.exe", "")),
                                                                       'codec', 'sop.ocx'))
        except:
            pass 
开发者ID:tvaddonsco,项目名称:program.plexus,代码行数:16,代码来源:sopcast.py

示例12: _get_windows_uuid

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def _get_windows_uuid():
    # pylint: disable=broad-except
    # pylint: disable=no-member
    uuid_value = None
    try:
        try:  # Python 2
            import _winreg as winreg
        except ImportError:  # Python 3
            import winreg
        registry = winreg.HKEY_LOCAL_MACHINE
        address = 'SOFTWARE\\Microsoft\\Cryptography'
        keyargs = winreg.KEY_READ | winreg.KEY_WOW64_64KEY
        key = winreg.OpenKey(registry, address, 0, keyargs)
        value = winreg.QueryValueEx(key, 'MachineGuid')
        winreg.CloseKey(key)
        uuid_value = value[0]
    except Exception:
        pass
    if not uuid_value:
        try:
            import subprocess
            output = subprocess.check_output(['vol', 'c:'])
            output = output.split()
            uuid_value = output[len(output) - 1:]
        except Exception:
            pass
    return uuid_value 
开发者ID:CastagnaIT,项目名称:plugin.video.netflix,代码行数:29,代码来源:uuid_device.py

示例13: break_sopcast

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def break_sopcast():
	if xbmc.getCondVisibility('system.platform.windows'):
		import _winreg
		aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
		try:
			aKey = _winreg.OpenKey(aReg, r'SOFTWARE\SopCast\Player\InstallPath',0, _winreg.KEY_READ)
			name, value, type = _winreg.EnumValue(aKey, 0)
			codec_file = os.path.join(os.path.join(value.replace("SopCast.exe","")),'codec','sop.ocx.old')
			_winreg.CloseKey(aKey)
			if xbmcvfs.exists(codec_file): xbmcvfs.rename(codec_file,os.path.join(os.path.join(value.replace("SopCast.exe","")),'codec','sop.ocx'))
		except:pass 
开发者ID:enen92,项目名称:program.plexus,代码行数:13,代码来源:sopcast.py

示例14: __iter__

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def __iter__(self):
        subkey_names = []
        try:
            with winreg.OpenKeyEx(self._root, self.subkey, 0, winreg.KEY_READ | self._flags) as key:
                for i in count():
                    subkey_names.append(winreg.EnumKey(key, i))
        except OSError:
            pass
        return iter(self[k] for k in subkey_names) 
开发者ID:sarugaku,项目名称:pythonfinder,代码行数:11,代码来源:_registry.py

示例15: get_value

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import KEY_READ [as 别名]
def get_value(self, value_name):
        try:
            with winreg.OpenKeyEx(self._root, self.subkey, 0, winreg.KEY_READ | self._flags) as key:
                return get_value_from_tuple(*winreg.QueryValueEx(key, value_name))
        except OSError:
            return None 
开发者ID:sarugaku,项目名称:pythonfinder,代码行数:8,代码来源:_registry.py


注:本文中的_winreg.KEY_READ属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。