本文整理汇总了Python中_winreg.REG_BINARY属性的典型用法代码示例。如果您正苦于以下问题:Python _winreg.REG_BINARY属性的具体用法?Python _winreg.REG_BINARY怎么用?Python _winreg.REG_BINARY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类_winreg
的用法示例。
在下文中一共展示了_winreg.REG_BINARY属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DllRegisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_BINARY [as 别名]
def DllRegisterServer():
import _winreg
key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \
"Explorer\\Desktop\\Namespace\\" + \
ShellFolderRoot._reg_clsid_)
_winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolderRoot._reg_desc_)
# And special shell keys under our CLSID
key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
"CLSID\\" + ShellFolderRoot._reg_clsid_ + "\\ShellFolder")
# 'Attributes' is an int stored as a binary! use struct
attr = shellcon.SFGAO_FOLDER | shellcon.SFGAO_HASSUBFOLDER | \
shellcon.SFGAO_BROWSABLE
import struct
s = struct.pack("i", attr)
_winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s)
print ShellFolderRoot._reg_desc_, "registration complete."
示例2: get_str_type
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_BINARY [as 别名]
def get_str_type(reg_type):
if reg_type == _winreg.REG_BINARY:
return "REG_BINARY"
elif reg_type == _winreg.REG_DWORD:
return "REG_DWORD"
elif reg_type == _winreg.REG_DWORD_BIG_ENDIAN:
return "REG_DWORD_BIG_ENDIAN"
elif reg_type == _winreg.REG_DWORD_LITTLE_ENDIAN:
return "REG_DWORD_LITTLE_ENDIAN"
elif reg_type == _winreg.REG_EXPAND_SZ:
return "REG_EXPAND_SZ"
elif reg_type == _winreg.REG_LINK:
return "REG_LINK"
elif reg_type == _winreg.REG_MULTI_SZ:
return "REG_MULTI_SZ"
elif reg_type == _winreg.REG_SZ:
return "REG_SZ"
示例3: write_block
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_BINARY [as 别名]
def write_block(self, bucket_id, value_id, data=""):
"""Described in parent class"""
try:
value_name = self._get_value_name(
bucket_id, value_id)
except BucketValueMissingException:
logger.debug(
"value with id does not exist in specified bucket." +
" generating a new value name for bucket id %s" % bucket_id)
value_name = self._generate_value_name(bucket_id)
logger.debug("generated a new value name in bucket id %s: %s" % (
bucket_id, value_name))
with self._get_bucket_key(bucket_id, _winreg.KEY_WRITE) as key:
_winreg.SetValueEx(key, value_name, 0,
_winreg.REG_BINARY, data)
return RegistryStorageProvider.value_name_to_value_id(value_name)
示例4: DllRegisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_BINARY [as 别名]
def DllRegisterServer():
import _winreg
if sys.getwindowsversion()[0] < 6:
print "This sample only works on Vista"
sys.exit(1)
key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \
"Explorer\\Desktop\\Namespace\\" + \
ShellFolder._reg_clsid_)
_winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolder._reg_desc_)
# And special shell keys under our CLSID
key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
"CLSID\\" + ShellFolder._reg_clsid_ + "\\ShellFolder")
# 'Attributes' is an int stored as a binary! use struct
attr = shellcon.SFGAO_FOLDER | shellcon.SFGAO_HASSUBFOLDER | \
shellcon.SFGAO_BROWSABLE
import struct
s = struct.pack("i", attr)
_winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s)
# register the context menu handler under the FolderViewSampleType type.
keypath = "%s\\shellex\\ContextMenuHandlers\\%s" % (ContextMenu._context_menu_type_, ContextMenu._reg_desc_)
key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, keypath)
_winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ContextMenu._reg_clsid_)
propsys.PSRegisterPropertySchema(get_schema_fname())
print ShellFolder._reg_desc_, "registration complete."
示例5: DllRegisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_BINARY [as 别名]
def DllRegisterServer():
comclass = IEToolbar
# register toolbar with IE
try:
print "Trying to register Toolbar.\n"
hkey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" )
subKey = _winreg.SetValueEx( hkey, comclass._reg_clsid_, 0, _winreg.REG_BINARY, "\0" )
except WindowsError:
print "Couldn't set registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
else:
print "Set registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
# TODO: implement reg settings for standard toolbar button
# unregister plugin
示例6: printReg
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_BINARY [as 别名]
def printReg(hive, value, type, fullkey, outFile, objRegistry, key=None):
if not key:
key = fullkey
if type == _winreg.REG_SZ:
result,reg_value = objRegistry.GetStringValue(hDefKey=hive,sSubKeyName=fullkey,sValueName=value)
elif type == _winreg.REG_EXPAND_SZ:
result,reg_value = objRegistry.GetExpandedStringValue(hDefKey=hive,sSubKeyName=fullkey,sValueName=value)
elif type == _winreg.REG_BINARY:
result,reg_value = objRegistry.GetBinaryValue(hDefKey=hive,sSubKeyName=fullkey,sValueName=value)
r_value = ""
if result == 0:
for decimal in reg_value:
r_value += "%0.2X" % decimal
reg_value = "[BINARY DATA] " + r_value
elif type == _winreg.REG_DWORD:
result,reg_value = objRegistry.GetDWORDValue(hDefKey=hive,sSubKeyName=fullkey,sValueName=value)
elif type == _winreg.REG_MULTI_SZ:
result,reg_value = objRegistry.GetMultiStringValue(hDefKey=hive,sSubKeyName=fullkey,sValueName=value)
else:
reg_value = "OTHER_TYPE"
if reg_value == None:
reg_value = "NULL"
reg_value = convert_to_string(reg_value)
outFile.write(key.replace(","," ") + "," + value.replace(","," ") + "," + reg_value.replace(","," ") + "\n")
#convert windows datetime to nicely formatted date