Python _winreg.REG_MULTI_SZ Examples

The following are 3 code examples of _winreg.REG_MULTI_SZ(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module _winreg , or try the search function .
Example #1
Source File: registry_obj.py    From Fastir_Collector with GNU General Public License v3.0 6 votes vote down vote up
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" 
Example #2
Source File: tools.py    From syncthing-gtk with GNU General Public License v2.0 5 votes vote down vote up
def is_ran_on_startup(program_name):
	"""
	Returns True if specified program is set to be ran on startup, either
	by XDG autostart or by windows registry.
	Only name (desktop filename or registry key) is checked.
	"""
	if IS_WINDOWS:
		# Check if there is value for application in ...\Run
		try:
			key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run")
			trash, keytype = _winreg.QueryValueEx(key, program_name)
			_winreg.CloseKey(key)
			return keytype in (_winreg.REG_SZ, _winreg.REG_EXPAND_SZ, _winreg.REG_MULTI_SZ)
		except WindowsError:
			# Key not found
			return False
	else:
		# Check if there application.desktop file exists
		desktopfile = os.path.join(get_config_dir(), "autostart", "%s.desktop" % (program_name,))
		if not os.path.exists(desktopfile):
			return False
		# Check if desktop file is not marked as hidden
		# (stupid way, but should work)
		is_entry = False
		with open(desktopfile, "r") as f:
			for line in f.readlines():
				line = line.strip(" \r\t\n").lower()
				if line == "[desktop entry]":
					is_entry = True
					continue
				if "=" in line:
					key, value = line.split("=", 1)
					if key.strip(" ") == "hidden":
						if value.strip(" ") == "true":
							# Desktop file is 'hidden', i.e. disabled
							return False
		# File is present and not hidden - autostart is enabled
		return is_entry 
Example #3
Source File: support.py    From CIS-ESP with Apache License 2.0 5 votes vote down vote up
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