本文整理汇总了Python中_winreg.REG_SZ属性的典型用法代码示例。如果您正苦于以下问题:Python _winreg.REG_SZ属性的具体用法?Python _winreg.REG_SZ怎么用?Python _winreg.REG_SZ使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类_winreg
的用法示例。
在下文中一共展示了_winreg.REG_SZ属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getPathFromRegistry
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [as 别名]
def getPathFromRegistry():
registryPath = r"Software\Microsoft\Windows\CurrentVersion\App Paths\trelby.exe"
try:
import _winreg
regPathKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, registryPath)
regPathValue, regPathType = _winreg.QueryValueEx(regPathKey, "Path")
if regPathType == _winreg.REG_SZ:
return regPathValue
else:
raise TypeError
except:
wx.MessageBox("There was an error reading the following registry key: %s.\n"
"You may need to reinstall the program to fix this error." %
registryPath, "Error", wx.OK)
sys.exit()
# convert s, which is returned from the wxWidgets GUI and is an Unicode
# string, to a normal string.
示例2: DllRegisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [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."
示例3: register
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [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."
示例4: test_non_latin_extension
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [as 别名]
def test_non_latin_extension(self):
import _winreg
class MockWinreg(object):
def __getattr__(self, name):
if name == 'EnumKey':
return lambda key, i: _winreg.EnumKey(key, i) + "\xa3"
elif name == 'OpenKey':
return lambda key, name: _winreg.OpenKey(key, name.rstrip("\xa3"))
elif name == 'QueryValueEx':
return lambda subkey, label: (u'текст/простой' , _winreg.REG_SZ)
return getattr(_winreg, name)
mimetypes._winreg = MockWinreg()
try:
# this used to throw an exception if registry contained non-Latin
# characters in extensions (issue #9291)
mimetypes.init()
finally:
mimetypes._winreg = _winreg
示例5: test_non_latin_type
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [as 别名]
def test_non_latin_type(self):
import _winreg
class MockWinreg(object):
def __getattr__(self, name):
if name == 'QueryValueEx':
return lambda subkey, label: (u'текст/простой', _winreg.REG_SZ)
return getattr(_winreg, name)
mimetypes._winreg = MockWinreg()
try:
# this used to throw an exception if registry contained non-Latin
# characters in content types (issue #9291)
mimetypes.init()
finally:
mimetypes._winreg = _winreg
示例6: save
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [as 别名]
def save(self):
if USE_WINDOWS:
import _winreg
try:
key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, self.keyname,
sam=_winreg.KEY_SET_VALUE | _winreg.KEY_WRITE)
except:
key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, self.keyname)
try:
for k, v in self.values.iteritems():
_winreg.SetValueEx(key, str(k), 0, _winreg.REG_SZ, str(v))
finally:
key.Close()
else:
d = os.path.dirname(self.filename)
if not os.path.isdir(d):
os.makedirs(d)
f = open(self.filename, 'w')
try:
data = '\n'.join(["%s=%s" % (k,v)
for k,v in self.values.iteritems()])
f.write(data)
finally:
f.close()
示例7: registry_key
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [as 别名]
def registry_key(key, subkey, value):
"""
Create a new Windows Registry Key in HKEY_CURRENT_USER
`Required`
:param str key: primary registry key name
:param str subkey: registry key sub-key name
:param str value: registry key sub-key value
Returns True if successful, otherwise False
"""
try:
import _winreg
reg_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, key, 0, _winreg.KEY_WRITE)
_winreg.SetValueEx(reg_key, subkey, 0, _winreg.REG_SZ, value)
_winreg.CloseKey(reg_key)
return True
except Exception as e:
log(e)
return False
示例8: get_str_type
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [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"
示例9: get_data
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [as 别名]
def get_data(self):
reg_type = self.value.get_type()
if reg_type == _winreg.REG_DWORD:
return self.value.get_data_as_integer()
elif reg_type == _winreg.REG_DWORD_LITTLE_ENDIAN:
return self.value.get_data_as_integer()
elif reg_type == _winreg.REG_DWORD_BIG_ENDIAN:
return self.value.get_data_as_integer()
elif reg_type == _winreg.REG_SZ:
return self.value.get_data_as_string()
elif reg_type == _winreg.REG_EXPAND_SZ:
return self.value.get_data_as_string()
elif reg_type == _winreg.REG_LINK:
return self.value.get_data_as_string()
return self.value.get_data()
示例10: enforce_shortcut
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [as 别名]
def enforce_shortcut(config, log_func):
if os.name != 'nt':
return
path = win32api.GetModuleFileName(0)
if 'python' in path.lower():
# oops, running the .py too lazy to make that work
path = r"C:\Program Files\BitTorrent\bittorrent.exe"
root_key = _winreg.HKEY_CURRENT_USER
subkey = r'Software\Microsoft\Windows\CurrentVersion\run'
key = _winreg.CreateKey(root_key, subkey)
if config['launch_on_startup']:
_winreg.SetValueEx(key, app_name, 0, _winreg.REG_SZ,
'"%s" --force_start_minimized' % path)
else:
try:
_winreg.DeleteValue(key, app_name)
except WindowsError, e:
# value doesn't exist
pass
示例11: Install
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [as 别名]
def Install():
AddOrRemoveHIDKeys(True)
osExtension = "x86"
if Is64BitOS():
osExtension = "x64"
pluginDir = dirname(__file__.decode(sys.getfilesystemencoding()))
tmpExe = join(pluginDir, "AlternateMceIrService_%s.exe"%osExtension)
myExe = join(pluginDir, "AlternateMceIrService.exe")
try:
os.remove(myExe)
except:
pass
shutil.copyfile(tmpExe,myExe)
key = reg.CreateKey(reg.HKEY_LOCAL_MACHINE, ServiceKey+"\\AlternateMceIrService")
reg.SetValueEx(key, "EventMessageFile", 0, reg.REG_SZ, myExe)
reg.SetValueEx(key, "TypesSupported", 0, reg.REG_DWORD, 7)
service = Service(u"AlternateMceIrService")
service.Install(myExe)
service.Start()
print "Service successfully installed"
示例12: run
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [as 别名]
def run(self):
try:
import _winreg
regPathKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r"Software\NSIS")
regPathValue, regPathType = _winreg.QueryValueEx(regPathKey, "")
if regPathType != _winreg.REG_SZ:
raise TypeError
except:
raise Exception("There was an error reading the registry key for NSIS.\n"
"You may need to reinstall NSIS to fix this error.")
self.executeNSIS(os.path.join(regPathValue, "makensis.exe"), self.nsis_file)
示例13: DllRegisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [as 别名]
def DllRegisterServer():
import _winreg
key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
"directory\\shellex\\CopyHookHandlers\\" +
ShellExtension._reg_desc_)
_winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellExtension._reg_clsid_)
key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
"*\\shellex\\CopyHookHandlers\\" +
ShellExtension._reg_desc_)
_winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellExtension._reg_clsid_)
print ShellExtension._reg_desc_, "registration complete."
示例14: DllRegisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [as 别名]
def DllRegisterServer():
import _winreg
# Special ColumnProvider key
key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
"Folder\\ShellEx\\ColumnHandlers\\" + \
str(ColumnProvider._reg_clsid_ ))
_winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ColumnProvider._reg_desc_)
print ColumnProvider._reg_desc_, "registration complete."
示例15: DllRegisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import REG_SZ [as 别名]
def DllRegisterServer():
# Also need to register specially in:
# HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches
# See link at top of file.
import _winreg
kn = r"Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\%s" \
% (EmptyVolumeCache._reg_desc_,)
key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, kn)
_winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, EmptyVolumeCache._reg_clsid_)