本文整理汇总了Python中six.moves.winreg.REG_SZ属性的典型用法代码示例。如果您正苦于以下问题:Python winreg.REG_SZ属性的具体用法?Python winreg.REG_SZ怎么用?Python winreg.REG_SZ使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类six.moves.winreg
的用法示例。
在下文中一共展示了winreg.REG_SZ属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: valuestodict
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import REG_SZ [as 别名]
def valuestodict(key):
"""Convert a registry key's values to a dictionary."""
dout = {}
size = winreg.QueryInfoKey(key)[1]
tz_res = None
for i in range(size):
key_name, value, dtype = winreg.EnumValue(key, i)
if dtype == winreg.REG_DWORD or dtype == winreg.REG_DWORD_LITTLE_ENDIAN:
# If it's a DWORD (32-bit integer), it's stored as unsigned - convert
# that to a proper signed integer
if value & (1 << 31):
value = value - (1 << 32)
elif dtype == winreg.REG_SZ:
# If it's a reference to the tzres DLL, load the actual string
if value.startswith('@tzres'):
tz_res = tz_res or tzres()
value = tz_res.name_from_string(value)
value = value.rstrip('\x00') # Remove trailing nulls
dout[key_name] = value
return dout
示例2: set_config_value
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import REG_SZ [as 别名]
def set_config_value(self, name, value, section=None):
key_name = self._get_config_key_name(section)
with winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE,
key_name) as key:
if type(value) == int:
regtype = winreg.REG_DWORD
else:
regtype = winreg.REG_SZ
winreg.SetValueEx(key, name, 0, regtype, value)
示例3: _set_registry_vm_type
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import REG_SZ [as 别名]
def _set_registry_vm_type(vm_type="IAAS"):
with winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows Azure") as key:
winreg.SetValueEx(key, "VMType", 0, winreg.REG_SZ, vm_type)
示例4: _set_registry_ga_params
# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import REG_SZ [as 别名]
def _set_registry_ga_params(install_version, install_timestamp):
with winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\GuestAgent") as key:
install_version_str = "%s.%s.%s.%s" % install_version
winreg.SetValueEx(
key, "Incarnation", 0, winreg.REG_SZ, install_version_str)
install_timestamp_str = install_timestamp.strftime(
'%m/%d/%Y %I:%M:%S %p')
winreg.SetValueEx(
key, "VmProvisionedAt", 0, winreg.REG_SZ,
install_timestamp_str)