當前位置: 首頁>>代碼示例>>Python>>正文


Python _winreg.HKEY_LOCAL_MACHINE屬性代碼示例

本文整理匯總了Python中_winreg.HKEY_LOCAL_MACHINE屬性的典型用法代碼示例。如果您正苦於以下問題:Python _winreg.HKEY_LOCAL_MACHINE屬性的具體用法?Python _winreg.HKEY_LOCAL_MACHINE怎麽用?Python _winreg.HKEY_LOCAL_MACHINE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在_winreg的用法示例。


在下文中一共展示了_winreg.HKEY_LOCAL_MACHINE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: register

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def register(classobj):
    import _winreg
    subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_
    try:
        hKey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
        subKey = _winreg.SetValueEx( hKey, "ButtonText", 0, _winreg.REG_SZ, classobj._button_text_ )
        _winreg.SetValueEx( hKey, "ClsidExtension", 0, _winreg.REG_SZ, classobj._reg_clsid_ ) # reg value for calling COM object
        _winreg.SetValueEx( hKey, "CLSID", 0, _winreg.REG_SZ, "{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}" ) # CLSID for button that sends command to COM object
        _winreg.SetValueEx( hKey, "Default Visible", 0, _winreg.REG_SZ, "Yes" )
        _winreg.SetValueEx( hKey, "ToolTip", 0, _winreg.REG_SZ, classobj._tool_tip_ )
        _winreg.SetValueEx( hKey, "Icon", 0, _winreg.REG_SZ, classobj._icon_)
        _winreg.SetValueEx( hKey, "HotIcon", 0, _winreg.REG_SZ, classobj._hot_icon_)
    except WindowsError:
        print "Couldn't set standard toolbar reg keys."
    else:
        print "Set standard toolbar reg keys." 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:18,代碼來源:iebutton.py

示例2: QueryAutoCdRom

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def QueryAutoCdRom():
	keypath=r'SYSTEM\CurrentControlSet\Services\cdrom'
	try:
		key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,keypath)
		return  _winreg.QueryValueEx(key,'AutoRun')[0]
	except:
		return None

# def QueryHKCUNoDriveAutoRun():# 0-0x3FFFFFF 
# 	keypath=r'Software\Microsoft\Windows\CurrentVersion\Policies\Explorer'
# 	try:
# 		key=_winreg.OpenKey(_winreg.HKEY_CURRENT_USER,keypath)
# 		return  _winreg.QueryValueEx(key,'NoDriveAutoRun ')[0]
# 	except:
# 		return None

# def QueryHKCUNoDriveTypeAutoRun():
# 	keypath=r'Software\Microsoft\Windows\CurrentVersion\Policies\Explorer'
# 	try:
# 		key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,keypath)
# 		return  _winreg.QueryValueEx(key,'NoDriveTypeAutoRun ')[0]
# 	except:
# 		return None 
開發者ID:turingsec,項目名稱:marsnake,代碼行數:25,代碼來源:win_sec_check.py

示例3: get_arcgis_paths

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def get_arcgis_paths():
    """
    Use the windows registry to figure out the paths to the following folders:

    - bin
    - arcpy
    - scripts

    as subfolders of the installation directory.
    """
    import _winreg
    registry = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
    arcgis_version = get_arcgis_version()
    try:
        key = _winreg.OpenKey(registry, r"SOFTWARE\wow6432Node\ESRI\Desktop%s" % arcgis_version)
    except WindowsError:
        key = _winreg.OpenKey(registry, r"SOFTWARE\ESRI\Desktop%s" % arcgis_version)
    install_dir, _ = _winreg.QueryValueEx(key, 'InstallDir')
    paths = [os.path.join(install_dir, 'bin64'),
            os.path.join(install_dir, 'arcpy'),
            os.path.join(install_dir, 'scripts')]
    return paths 
開發者ID:architecture-building-systems,項目名稱:CityEnergyAnalyst,代碼行數:24,代碼來源:install_toolbox.py

示例4: get_arcgis_version

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def get_arcgis_version():
    """Check the registry for ArcGIS and return the version. Checks the following two locations:

    - HKLM\software\wow6432Node\esri\Arcgis\RealVersion
    - HKLM\SOFTWARE\ESRI\ArcGIS\RealVersion

    returns the version string as ``"major.minor"``, so ``"10.4"`` or ``"10.5"``
    """
    import _winreg
    registry = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
    try:
        key = _winreg.OpenKey(registry, r"software\wow6432Node\esri\Arcgis")
    except WindowsError:
        key = _winreg.OpenKey(registry, r"SOFTWARE\ESRI\ArcGIS")
    value, _ = _winreg.QueryValueEx(key, 'RealVersion')
    return '.'.join(value.split('.')[:2]) 
開發者ID:architecture-building-systems,項目名稱:CityEnergyAnalyst,代碼行數:18,代碼來源:install_toolbox.py

示例5: CheckRegistryKey

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def CheckRegistryKey(javaKey):
		""" Method checks for the java in the registry entries. """
		from _winreg import ConnectRegistry, HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx

		path = None
		try:
			aReg = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
			rk = OpenKey(aReg, javaKey)
			for i in range(1024):
				currentVersion = QueryValueEx(rk, "CurrentVersion")
				if currentVersion != None:
					key = OpenKey(rk, currentVersion[0])
					if key != None:
						path = QueryValueEx(key, "JavaHome")
						return path[0]
		except Exception, err:
			# TODO: Add Warning/Error messages in Logger.
			WriteUcsWarning("Not able to access registry.")
			return None 
開發者ID:CiscoUcs,項目名稱:UcsPythonSDK,代碼行數:21,代碼來源:UcsBase.py

示例6: _find_msvc_in_registry

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def _find_msvc_in_registry(env,version):
    if _is_py2:
        import _winreg as winreg
    else:
        import winreg

    vs_ver = str(version) + '.0'
    vs_key = 'SOFTWARE\\Microsoft\\VisualStudio\\' + vs_ver + '\\Setup\\VS'
    vc_key = 'SOFTWARE\\Microsoft\\VisualStudio\\' + vs_ver + '\\Setup\\VC'
    vs_dir = _read_registry(winreg.HKEY_LOCAL_MACHINE, vs_key, 'ProductDir')
    vc_dir = _read_registry(winreg.HKEY_LOCAL_MACHINE, vc_key, 'ProductDir')
    
    # On a 64-bit host, look for a 32-bit installation 

    if (not vs_dir or not vc_dir):
        vs_key = 'SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\' + \
            vs_ver + '\\Setup\\VS'
        vc_key = 'SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\' + \
            vs_ver + '\\Setup\\VC'
        vs_dir = _read_registry(winreg.HKEY_LOCAL_MACHINE, 
                                vs_key, 'ProductDir')
        vc_dir = _read_registry(winreg.HKEY_LOCAL_MACHINE, 
                                vc_key, 'ProductDir')
    return (vs_dir,vc_dir) 
開發者ID:intelxed,項目名稱:mbuild,代碼行數:26,代碼來源:msvs.py

示例7: get_reboot_required

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def get_reboot_required():
  """Returns True if the system should be rebooted to apply updates.

  This is not guaranteed to notice all conditions that could require reboot.
  """
  # Based on https://stackoverflow.com/a/45717438
  k = None
  import _winreg
  try:
    k = _winreg.OpenKey(
        _winreg.HKEY_LOCAL_MACHINE,
        'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\'
        'Auto Update\\RebootRequired')
    _, num_values, _ = _winreg.QueryInfoKey(k)
    return num_values > 0
  except WindowsError:  # pylint: disable=undefined-variable
    # This error very likely means the RebootRequired key does not exist,
    # meaning reboot is not required.
    return False
  finally:
    if k:
      k.Close() 
開發者ID:luci,項目名稱:luci-py,代碼行數:24,代碼來源:win.py

示例8: get_win32_executable

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def get_win32_executable():
    if PY3:
        import winreg
    else:
        import _winreg as winreg
    reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
    try:
        key = winreg.OpenKey(reg, 'SOFTWARE\\VMware, Inc.\\VMware Workstation')
        try:
            return os.path.join(winreg.QueryValueEx(key, 'InstallPath')[0], 'vmrun.exe')
        finally:
            winreg.CloseKey(key)
    except WindowsError:
        key = winreg.OpenKey(reg, 'SOFTWARE\\WOW6432Node\\VMware, Inc.\\VMware Workstation')
        try:
            return os.path.join(winreg.QueryValueEx(key, 'InstallPath')[0], 'vmrun.exe')
        finally:
            winreg.CloseKey(key)
    finally:
        reg.Close()
    return get_fallback_executable() 
開發者ID:mechboxes,項目名稱:mech,代碼行數:23,代碼來源:vmrun.py

示例9: win32InstalledFonts

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def win32InstalledFonts( fontDirectory = None ):
    """Get list of explicitly *installed* font names"""
    import _winreg
    if fontDirectory is None:
        fontDirectory = win32FontDirectory()
    k = None
    items = {}
    for keyName in (
        r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts",
        r"SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts",
    ):
        try:
            k = _winreg.OpenKey(
                _winreg.HKEY_LOCAL_MACHINE,
                keyName
            )
        except OSError, err:
            pass 
開發者ID:gltn,項目名稱:stdm,代碼行數:20,代碼來源:findsystem.py

示例10: _get_labview_paths_windows

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def _get_labview_paths_windows(self):
        # Connect to the registry at the root of the LabVIEW key
        import _winreg
        reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)

        installed_lv_paths = []
        # Iterate over all subkeys until you find one that isn't a version
        # number.  Each subkey represents a currently installed version of
        # LabVIEW. We want to pull from that the key indicating its install
        # path. We put each one into an array
        for root_key in [r"SOFTWARE\Wow6432Node\National Instruments\LabVIEW",
                         r"SOFTWARE\National Instruments\LabVIEW"]:
            try:
                key = self._open_windows_native_key(reg, root_key)
                i = 0
                current_lv_version = _winreg.EnumKey(key, i)
                while current_lv_version.find('.') != -1:
                    try:
                        current_lv_reg_key = self._open_windows_native_key(
                            reg, root_key + "\\" + current_lv_version)
                        value, key_type = _winreg.QueryValueEx(
                            current_lv_reg_key, "PATH")
                    except WindowsError as e:
                        if e.errno == 2:
                            pass
                    else:
                        installed_lv_paths.append(value)
                    finally:
                        i += 1
                        try:
                            current_lv_version = _winreg.EnumKey(key, i)
                        except (IOError, WindowsError):
                            break
            except WindowsError as e:
                # If the key doesn't exist LabVIEW may not be installed.  We
                # can safely ignore this error
                pass

        return installed_lv_paths 
開發者ID:ni,項目名稱:python_labview_automation,代碼行數:41,代碼來源:labview.py

示例11: _get_active_labview_windows

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def _get_active_labview_windows(self):
        # Connect to the registry at the root of the LabVIEW key
        import _winreg

        reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
        try:
            key = self._open_windows_native_key(
                reg, r"SOFTWARE\National Instruments\LabVIEW\CurrentVersion")
            value, key_type = _winreg.QueryValueEx(key, "PATH")
        except WindowsError:
            key = self._open_windows_native_key(
                reg,
                r"SOFTWARE\Wow6432Node\National Instruments\LabVIEW\CurrentVersion")
            value, key_type = _winreg.QueryValueEx(key, "PATH")
        return value 
開發者ID:ni,項目名稱:python_labview_automation,代碼行數:17,代碼來源:labview.py

示例12: set_envvar_in_registry

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def set_envvar_in_registry(envvar, value):
    try:
        import winreg
    except ImportError:
        import _winreg as winreg

    reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
    with winreg.OpenKey(reg, KEY, 0, winreg.KEY_ALL_ACCESS) as regkey:
        winreg.SetValueEx(regkey, envvar, 0, winreg.REG_EXPAND_SZ, value) 
開發者ID:coala,項目名稱:coala-quickstart,代碼行數:11,代碼來源:store_env_in_registry.py

示例13: get_tuntap_ComponentId

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def get_tuntap_ComponentId():
    '''
    \brief Retrieve the instance ID of the TUN/TAP interface from the Windows
        registry,
    
    This function loops through all the sub-entries at the following location
    in the Windows registry: reg.HKEY_LOCAL_MACHINE, ADAPTER_KEY
      
    It looks for one which has the 'ComponentId' key set to
    TUNTAP_COMPONENT_ID, and returns the value of the 'NetCfgInstanceId' key.
    
    \return The 'ComponentId' associated with the TUN/TAP interface, a string
        of the form "{A9A413D7-4D1C-47BA-A3A9-92F091828881}".
    '''
    with reg.OpenKey(reg.HKEY_LOCAL_MACHINE, ADAPTER_KEY) as adapters:
        try:
            for i in xrange(10000):
                key_name = reg.EnumKey(adapters, i)
                with reg.OpenKey(adapters, key_name) as adapter:
                    try:
                        component_id = reg.QueryValueEx(adapter, 'ComponentId')[0]
                        if component_id == TUNTAP_COMPONENT_ID:
                            return reg.QueryValueEx(adapter, 'NetCfgInstanceId')[0]
                    except WindowsError, err:
                        pass
        except WindowsError, err:
            pass 
開發者ID:alexsunday,項目名稱:pyvpn,代碼行數:29,代碼來源:tun-ping-responder.py

示例14: _FindTimeZoneKey

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def _FindTimeZoneKey(self):
		"""Find the registry key for the time zone name (self.timeZoneName)."""
		# for multi-language compatability, match the time zone name in the
		# "Std" key of the time zone key.
		zoneNames = dict(self._get_indexed_time_zone_keys('Std'))
		# Also match the time zone key name itself, to be compatible with
		# English-based hard-coded time zones.
		timeZoneName = zoneNames.get(self.timeZoneName, self.timeZoneName)
		key = _RegKeyDict.open(_winreg.HKEY_LOCAL_MACHINE, self.tzRegKey)
		try:
			result = key.subkey(timeZoneName)
		except:
			raise ValueError('Timezone Name %s not found.' % timeZoneName)
		return result 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:16,代碼來源:win32timezone.py

示例15: _get_time_zone_key

# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import HKEY_LOCAL_MACHINE [as 別名]
def _get_time_zone_key(subkey=None):
		"Return the registry key that stores time zone details"
		key = _RegKeyDict.open(_winreg.HKEY_LOCAL_MACHINE, TimeZoneInfo.tzRegKey)
		if subkey:
			key = key.subkey(subkey)
		return key 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:8,代碼來源:win32timezone.py


注:本文中的_winreg.HKEY_LOCAL_MACHINE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。