本文整理汇总了Python中six.moves.winreg.HKEY_LOCAL_MACHINE属性的典型用法代码示例。如果您正苦于以下问题:Python winreg.HKEY_LOCAL_MACHINE属性的具体用法?Python winreg.HKEY_LOCAL_MACHINE怎么用?Python winreg.HKEY_LOCAL_MACHINE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类six.moves.winreg
的用法示例。
在下文中一共展示了winreg.HKEY_LOCAL_MACHINE属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: discover_pythons
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import HKEY_LOCAL_MACHINE [as 别名]
def discover_pythons():
for hive, hive_name, key, flags, default_arch in [
(winreg.HKEY_CURRENT_USER, "HKEY_CURRENT_USER", r"Software\Python", 0, 64),
(
winreg.HKEY_LOCAL_MACHINE,
"HKEY_LOCAL_MACHINE",
r"Software\Python",
winreg.KEY_WOW64_64KEY,
64,
),
(
winreg.HKEY_LOCAL_MACHINE,
"HKEY_LOCAL_MACHINE",
r"Software\Python",
winreg.KEY_WOW64_32KEY,
32,
),
]:
for spec in process_set(hive, hive_name, key, flags, default_arch):
yield spec
示例2: _settzkeyname
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import HKEY_LOCAL_MACHINE [as 别名]
def _settzkeyname():
handle = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
try:
winreg.OpenKey(handle, TZKEYNAMENT).Close()
TZKEYNAME = TZKEYNAMENT
except WindowsError:
TZKEYNAME = TZKEYNAME9X
handle.Close()
return TZKEYNAME
示例3: list
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import HKEY_LOCAL_MACHINE [as 别名]
def list():
"""Return a list of all time zones known to the system."""
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
with winreg.OpenKey(handle, TZKEYNAME) as tzkey:
result = [winreg.EnumKey(tzkey, i)
for i in range(winreg.QueryInfoKey(tzkey)[0])]
return result
示例4: __init__
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import HKEY_LOCAL_MACHINE [as 别名]
def __init__(self, name):
self._name = name
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
tzkeyname = text_type("{kn}\\{name}").format(kn=TZKEYNAME, name=name)
with winreg.OpenKey(handle, tzkeyname) as tzkey:
keydict = valuestodict(tzkey)
self._std_abbr = keydict["Std"]
self._dst_abbr = keydict["Dlt"]
self._display = keydict["Display"]
# See http://ww_winreg.jsiinc.com/SUBA/tip0300/rh0398.htm
tup = struct.unpack("=3l16h", keydict["TZI"])
stdoffset = -tup[0]-tup[1] # Bias + StandardBias * -1
dstoffset = stdoffset-tup[2] # + DaylightBias * -1
self._std_offset = datetime.timedelta(minutes=stdoffset)
self._dst_offset = datetime.timedelta(minutes=dstoffset)
# for the meaning see the win32 TIME_ZONE_INFORMATION structure docs
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms725481(v=vs.85).aspx
(self._stdmonth,
self._stddayofweek, # Sunday = 0
self._stdweeknumber, # Last = 5
self._stdhour,
self._stdminute) = tup[4:9]
(self._dstmonth,
self._dstdayofweek, # Sunday = 0
self._dstweeknumber, # Last = 5
self._dsthour,
self._dstminute) = tup[12:17]
self._dst_base_offset_ = self._dst_offset - self._std_offset
self.hasdst = self._get_hasdst()
示例5: __init__
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import HKEY_LOCAL_MACHINE [as 别名]
def __init__(self, name):
self._name = name
# multiple contexts only possible in 2.7 and 3.1, we still support 2.6
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
tzkeyname = text_type("{kn}\{name}").format(kn=TZKEYNAME, name=name)
with winreg.OpenKey(handle, tzkeyname) as tzkey:
keydict = valuestodict(tzkey)
self._std_abbr = keydict["Std"]
self._dst_abbr = keydict["Dlt"]
self._display = keydict["Display"]
# See http://ww_winreg.jsiinc.com/SUBA/tip0300/rh0398.htm
tup = struct.unpack("=3l16h", keydict["TZI"])
stdoffset = -tup[0]-tup[1] # Bias + StandardBias * -1
dstoffset = stdoffset-tup[2] # + DaylightBias * -1
self._std_offset = datetime.timedelta(minutes=stdoffset)
self._dst_offset = datetime.timedelta(minutes=dstoffset)
# for the meaning see the win32 TIME_ZONE_INFORMATION structure docs
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms725481(v=vs.85).aspx
(self._stdmonth,
self._stddayofweek, # Sunday = 0
self._stdweeknumber, # Last = 5
self._stdhour,
self._stdminute) = tup[4:9]
(self._dstmonth,
self._dstdayofweek, # Sunday = 0
self._dstweeknumber, # Last = 5
self._dsthour,
self._dstminute) = tup[12:17]
self._dst_base_offset_ = self._dst_offset - self._std_offset
self.hasdst = self._get_hasdst()
示例6: list
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import HKEY_LOCAL_MACHINE [as 别名]
def list():
"""Return a list of all time zones known to the system."""
handle = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
tzkey = winreg.OpenKey(handle, TZKEYNAME)
result = [winreg.EnumKey(tzkey, i)
for i in range(winreg.QueryInfoKey(tzkey)[0])]
tzkey.Close()
handle.Close()
return result
示例7: __init__
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import HKEY_LOCAL_MACHINE [as 别名]
def __init__(self, name):
self._name = name
# multiple contexts only possible in 2.7 and 3.1, we still support 2.6
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
with winreg.OpenKey(handle,
"%s\%s" % (TZKEYNAME, name)) as tzkey:
keydict = valuestodict(tzkey)
self._stdname = keydict["Std"].encode("iso-8859-1")
self._dstname = keydict["Dlt"].encode("iso-8859-1")
self._display = keydict["Display"]
# See http://ww_winreg.jsiinc.com/SUBA/tip0300/rh0398.htm
tup = struct.unpack("=3l16h", keydict["TZI"])
self._stdoffset = -tup[0]-tup[1] # Bias + StandardBias * -1
self._dstoffset = self._stdoffset-tup[2] # + DaylightBias * -1
# for the meaning see the win32 TIME_ZONE_INFORMATION structure docs
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms725481(v=vs.85).aspx
(self._stdmonth,
self._stddayofweek, # Sunday = 0
self._stdweeknumber, # Last = 5
self._stdhour,
self._stdminute) = tup[4:9]
(self._dstmonth,
self._dstdayofweek, # Sunday = 0
self._dstweeknumber, # Last = 5
self._dsthour,
self._dstminute) = tup[12:17]
示例8: _get_registry_dhcp_server
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import HKEY_LOCAL_MACHINE [as 别名]
def _get_registry_dhcp_server(adapter_name):
with winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Services\\" +
"Tcpip\\Parameters\\Interfaces\\%s" % adapter_name, 0,
winreg.KEY_READ) as key:
try:
dhcp_server = winreg.QueryValueEx(key, "DhcpServer")[0]
if dhcp_server == "255.255.255.255":
dhcp_server = None
return dhcp_server
except Exception as ex:
# Not found
if ex.errno != 2:
raise
示例9: get_user_home
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import HKEY_LOCAL_MACHINE [as 别名]
def get_user_home(self, username):
user_sid = self.get_user_sid(username)
if user_sid:
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\'
'Microsoft\\Windows NT\\CurrentVersion\\'
'ProfileList\\%s' % user_sid) as key:
return winreg.QueryValueEx(key, 'ProfileImagePath')[0]
LOG.debug('Home directory not found for user %r', username)
return None