本文整理匯總了Python中winreg.KEY_WOW64_64KEY屬性的典型用法代碼示例。如果您正苦於以下問題:Python winreg.KEY_WOW64_64KEY屬性的具體用法?Python winreg.KEY_WOW64_64KEY怎麽用?Python winreg.KEY_WOW64_64KEY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類winreg
的用法示例。
在下文中一共展示了winreg.KEY_WOW64_64KEY屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: open_key
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def open_key(key):
"""Open the register key.
Args:
key (str): The key of register.
Returns:
str: The handle to the specified key.
"""
machine_type = platform.machine()
mappings = {"AMD64": winreg.KEY_WOW64_64KEY}
return winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE,
key,
access=winreg.KEY_READ | mappings.get(machine_type,
winreg.KEY_WOW64_32KEY),
)
示例2: _init_from_registry
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def _init_from_registry(cls):
if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert':
return
import winreg
for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
try:
hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
r'Software\Imagemagick\Current',
0, winreg.KEY_QUERY_VALUE | flag)
binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
winreg.CloseKey(hkey)
break
except Exception:
binpath = ''
if binpath:
for exe in ('convert.exe', 'magick.exe'):
path = os.path.join(binpath, exe)
if os.path.exists(path):
binpath = path
break
else:
binpath = ''
rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath
示例3: CoCreateInstanceC2R
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def CoCreateInstanceC2R (self, store, reg, clsid, iid) :
# Ugly code to find DLL in C2R version of COM object and get a COM
# object despite the fact that COM doesn't handle C2R
try:
# Get DLL to load from 2R register
aReg = winreg.ConnectRegistry(None, store)
aKey = winreg.OpenKey(aReg, reg, 0, winreg.KEY_READ | winreg.KEY_WOW64_64KEY)
dummy_n, IconvDLL, dummy_t = winreg.EnumValue(aKey, 0)
winreg.CloseKey(aKey)
winreg.CloseKey(aReg)
# Create OLE object from DLL
IconvOLE = ctypes.OleDLL(IconvDLL)
# Get COM Instance from OLE
clsid_class = uuid.UUID(str(clsid)).bytes_le
iclassfactory = uuid.UUID(str(pythoncom.IID_IClassFactory)).bytes_le
com_classfactory = ctypes.c_long(0)
IconvOLE.DllGetClassObject(clsid_class, iclassfactory, ctypes.byref(com_classfactory))
MyFactory = pythoncom.ObjectFromAddress(com_classfactory.value, pythoncom.IID_IClassFactory)
return MyFactory.CreateInstance (None, str(iid))
except:
return None
示例4: IsLavFilters
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def IsLavFilters():
''' Check if LavFilters is present '''
if windows:
software_list = WinSoftwareInstalled(winreg.HKEY_LOCAL_MACHINE, winreg.KEY_WOW64_32KEY) + WinSoftwareInstalled(winreg.HKEY_LOCAL_MACHINE, winreg.KEY_WOW64_64KEY) + WinSoftwareInstalled(winreg.HKEY_CURRENT_USER, 0)
if not any('LAV Filters' in software['name'] for software in software_list):
# does not exist
return False
else:
cache = apt.Cache()
cache.open()
try:
#print("lav filters")
return cache["gst123"].is_installed
except Exception:
# does not exist
return False
return True
示例5: uninstall_all
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def uninstall_all():
"""uninstalls PyXLL from all installed Excel versions"""
for wow64_flags in (winreg.KEY_WOW64_64KEY, winreg.KEY_WOW64_32KEY):
for root in _root_keys.keys():
try:
flags = wow64_flags | winreg.KEY_READ
office_root = winreg.OpenKey(root, r"Software\Microsoft\Office", 0, flags)
except WindowsError:
continue
# look for all installed versions of Excel and uninstall PyXLL
i = 0
while True:
try:
subkey = winreg.EnumKey(office_root, i)
except WindowsError:
break
match = re.match("^(\d+(?:\.\d+)?)$", subkey)
if match:
office_version = match.group(1)
uninstall(office_root, office_version, wow64_flags)
i += 1
winreg.CloseKey(office_root)
示例6: _get_windows_uuid
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def _get_windows_uuid():
# pylint: disable=broad-except
# pylint: disable=no-member
uuid_value = None
try:
try: # Python 2
import _winreg as winreg
except ImportError: # Python 3
import winreg
registry = winreg.HKEY_LOCAL_MACHINE
address = 'SOFTWARE\\Microsoft\\Cryptography'
keyargs = winreg.KEY_READ | winreg.KEY_WOW64_64KEY
key = winreg.OpenKey(registry, address, 0, keyargs)
value = winreg.QueryValueEx(key, 'MachineGuid')
winreg.CloseKey(key)
uuid_value = value[0]
except Exception:
pass
if not uuid_value:
try:
import subprocess
output = subprocess.check_output(['vol', 'c:'])
output = output.split()
uuid_value = output[len(output) - 1:]
except Exception:
pass
return uuid_value
示例7: get_non_syspath_dirs
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def get_non_syspath_dirs():
"""Returns a list containing the directories of the applications which are not found in the system path"""
# Try standard registry and the 32bit as well as 64bit mapping of it
for access_right in [_wr.KEY_READ, _wr.KEY_READ | _wr.KEY_WOW64_32KEY, _wr.KEY_READ | _wr.KEY_WOW64_64KEY]:
# Global instalations put their keys in HKLM (HKEY_LOCAL_MACHINE), user installations
# put their keys in HKCU (HKEY_CURRENT_USER)
for hkey in [_wr.HKEY_LOCAL_MACHINE, _wr.HKEY_CURRENT_USER]:
try:
key = _wr.OpenKey(hkey, INKSCAPE_REG_KEY, 0, access_right)
try:
# Inkscape stores its installation location in a Standard key -> ""
value, _ = _wr.QueryValueEx(key, "")
_wr.CloseKey(key)
dirname = _os.path.join(value, "bin")
return [dirname] if _os.path.isdir(dirname) else []
except WindowsError:
_wr.CloseKey(key)
except WindowsError:
pass
# Last chance: Guess at the two common locations
for dirname in ["C:\\Program Files\\Inkscape\\bin", "C:\\Program Files (x86)\\Inkscape\\bin"]:
if _os.path.isfile(_os.path.join(dirname, "inkscape.exe")):
return [dirname]
# Give up
return []
示例8: create_registry_entry
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def create_registry_entry(product, arc_version):
"""Create a registry link back to the arcgisbinding package."""
root_key = winreg.HKEY_CURRENT_USER
if product == 'Pro':
product_name = "ArcGISPro"
else:
product_name = "Desktop{}".format(arc_version)
reg_path = "SOFTWARE\\Esri\\{}".format(product_name)
package_key = 'RintegrationProPackagePath'
link_key = None
try:
full_access = (winreg.KEY_WOW64_64KEY + winreg.KEY_ALL_ACCESS)
# find the key, 64- or 32-bit we want it all
link_key = winreg.OpenKey(root_key, reg_path, 0, full_access)
except fnf_exception as error:
handle_fnf(error)
if link_key:
try:
arcpy.AddMessage("Using registry key to link install.")
binding_path = "{}\\{}".format(r_lib_path(), "arcgisbinding")
winreg.SetValueEx(link_key, package_key, 0,
winreg.REG_SZ, binding_path)
except fnf_exception as error:
handle_fnf(error)
示例9: _get_arch
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def _get_arch(flags):
if flags & winreg.KEY_WOW64_64KEY:
return "64 bit"
elif flags & winreg.KEY_WOW64_32KEY:
return "32 bit"
return "unknown"
示例10: __init__
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def __init__(self, ignore_filter: Optional[Callable[[str], bool]]=None):
self._ignore_filter = ignore_filter
if self._is_os_64bit():
self._ARCH_KEYS = [winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY]
else:
self._ARCH_KEYS = [0]
self.__uninstall_keys: Set[UninstallKey] = set()
self.__keys_count: Dict[int, int] = {
arch | hive : 0
for arch in self._ARCH_KEYS
for hive in self._LOOKUP_REGISTRY_HIVES
}
示例11: get_machine_id
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def get_machine_id():
global _machine_id
rv = _machine_id
if rv is not None:
return rv
def _generate():
# Potential sources of secret information on linux. The machine-id
# is stable across boots, the boot id is not
for filename in "/etc/machine-id", "/proc/sys/kernel/random/boot_id":
try:
with open(filename, "rb") as f:
return f.readline().strip()
except IOError:
continue
# On OS X we can use the computer's serial number assuming that
# ioreg exists and can spit out that information.
try:
# Also catch import errors: subprocess may not be available, e.g.
# Google App Engine
# See https://github.com/pallets/werkzeug/issues/925
from subprocess import Popen, PIPE
dump = Popen(
["ioreg", "-c", "IOPlatformExpertDevice", "-d", "2"], stdout=PIPE
).communicate()[0]
match = re.search(b'"serial-number" = <([^>]+)', dump)
if match is not None:
return match.group(1)
except (OSError, ImportError):
pass
# On Windows we can use winreg to get the machine guid
wr = None
try:
import winreg as wr
except ImportError:
try:
import _winreg as wr
except ImportError:
pass
if wr is not None:
try:
with wr.OpenKey(
wr.HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Cryptography",
0,
wr.KEY_READ | wr.KEY_WOW64_64KEY,
) as rk:
machineGuid, wrType = wr.QueryValueEx(rk, "MachineGuid")
if wrType == wr.REG_SZ:
return machineGuid.encode("utf-8")
else:
return machineGuid
except WindowsError:
pass
_machine_id = rv = _generate()
return rv
示例12: get_machine_id
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def get_machine_id():
global _machine_id
rv = _machine_id
if rv is not None:
return rv
def _generate():
# Potential sources of secret information on linux. The machine-id
# is stable across boots, the boot id is not
for filename in '/etc/machine-id', '/proc/sys/kernel/random/boot_id':
try:
with open(filename, 'rb') as f:
return f.readline().strip()
except IOError:
continue
# On OS X we can use the computer's serial number assuming that
# ioreg exists and can spit out that information.
try:
# Also catch import errors: subprocess may not be available, e.g.
# Google App Engine
# See https://github.com/pallets/werkzeug/issues/925
from subprocess import Popen, PIPE
dump = Popen(['ioreg', '-c', 'IOPlatformExpertDevice', '-d', '2'],
stdout=PIPE).communicate()[0]
match = re.search(b'"serial-number" = <([^>]+)', dump)
if match is not None:
return match.group(1)
except (OSError, ImportError):
pass
# On Windows we can use winreg to get the machine guid
wr = None
try:
import winreg as wr
except ImportError:
try:
import _winreg as wr
except ImportError:
pass
if wr is not None:
try:
with wr.OpenKey(wr.HKEY_LOCAL_MACHINE,
'SOFTWARE\\Microsoft\\Cryptography', 0,
wr.KEY_READ | wr.KEY_WOW64_64KEY) as rk:
return wr.QueryValueEx(rk, 'MachineGuid')[0]
except WindowsError:
pass
_machine_id = rv = _generate()
return rv
示例13: get_machine_id
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def get_machine_id():
global _machine_id
rv = _machine_id
if rv is not None:
return rv
def _generate():
# Potential sources of secret information on linux. The machine-id
# is stable across boots, the boot id is not
for filename in '/etc/machine-id', '/proc/sys/kernel/random/boot_id':
try:
with open(filename, 'rb') as f:
return f.readline().strip()
except IOError:
continue
# On OS X we can use the computer's serial number assuming that
# ioreg exists and can spit out that information.
try:
# Also catch import errors: subprocess may not be available, e.g.
# Google App Engine
# See https://github.com/pallets/werkzeug/issues/925
from subprocess import Popen, PIPE
dump = Popen(['ioreg', '-c', 'IOPlatformExpertDevice', '-d', '2'],
stdout=PIPE).communicate()[0]
match = re.search(b'"serial-number" = <([^>]+)', dump)
if match is not None:
return match.group(1)
except (OSError, ImportError):
pass
# On Windows we can use winreg to get the machine guid
wr = None
try:
import winreg as wr
except ImportError:
try:
import _winreg as wr
except ImportError:
pass
if wr is not None:
try:
with wr.OpenKey(wr.HKEY_LOCAL_MACHINE,
'SOFTWARE\\Microsoft\\Cryptography', 0,
wr.KEY_READ | wr.KEY_WOW64_64KEY) as rk:
machineGuid, wrType = wr.QueryValueEx(rk, 'MachineGuid')
if (wrType == wr.REG_SZ):
return machineGuid.encode('utf-8')
else:
return machineGuid
except WindowsError:
pass
_machine_id = rv = _generate()
return rv
示例14: checkjava
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def checkjava():
"""Check for java and setup the proper directory if needed"""
results = []
if sys.platform.startswith('win'):
if not results:
import winreg
for flag in [winreg.KEY_WOW64_64KEY, winreg.KEY_WOW64_32KEY]:
try:
k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r'Software\JavaSoft\Java Development Kit', 0, winreg.KEY_READ | flag)
version, _ = winreg.QueryValueEx(k, 'CurrentVersion')
k.Close()
k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r'Software\JavaSoft\Java Development Kit\%s' % version, 0, winreg.KEY_READ | flag)
path, _ = winreg.QueryValueEx(k, 'JavaHome')
k.Close()
path = os.path.join(str(path), 'bin')
subprocess.run(['"%s"' % os.path.join(path, 'java'), ' -version'], stdout=open(os.devnull, 'w'), stderr=subprocess.STDOUT, check=True)
results.append(path)
except (CalledProcessError, OSError):
pass
if not results:
try:
subprocess.run(['java', '-version'], stdout=open(os.devnull, 'w'), stderr=subprocess.STDOUT, check=True)
results.append('')
except (CalledProcessError, OSError):
pass
if not results and 'ProgramW6432' in os.environ:
results.extend(which('java.exe', os.environ['ProgramW6432']))
if not results and 'ProgramFiles' in os.environ:
results.extend(which('java.exe', os.environ['ProgramFiles']))
if not results and 'ProgramFiles(x86)' in os.environ:
results.extend(which('java.exe', os.environ['ProgramFiles(x86)']))
elif sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
if not results:
try:
subprocess.run(['java', '-version'], stdout=open(os.devnull, 'w'), stderr=subprocess.STDOUT, check=True)
results.append('')
except (CalledProcessError, OSError):
pass
if not results:
results.extend(which('java', path='/usr/bin'))
if not results:
results.extend(which('java', path='/usr/local/bin'))
if not results:
results.extend(which('java', path='/opt'))
if not results:
print('Java JDK is not installed ! Please install java JDK from http://java.oracle.com or OpenJDK')
input("Aborting, press anything to exit")
sys.exit(1)
示例15: tqdb_prepare
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import KEY_WOW64_64KEY [as 別名]
def tqdb_prepare():
# Open the TQAE key and grab the install location:
try:
tqae_key = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE, LOOKUP_KEY, 0, winreg.KEY_READ)
except FileNotFoundError:
import platform
bitness = platform.architecture()[0]
if bitness == '32bit':
other_view_flag = winreg.KEY_WOW64_64KEY
elif bitness == '64bit':
other_view_flag = winreg.KEY_WOW64_32KEY
else:
raise RuntimeError("Platform architecture not recognized: " +
bitness)
try:
tqae_key = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE, LOOKUP_KEY,
access = winreg.KEY_READ | other_view_flag)
except WindowsError as err:
raise RuntimeError('Could not find installation directory for '
'Titan Quest.') from err
try:
install = winreg.QueryValueEx(tqae_key, 'InstallLocation')[0]
except WindowsError as err:
raise RuntimeError('Could not find installation directory for Titan '
'Quest.') from err
logging.info("Found TQ installation directory: " + install)
# Create the required directories if necessary
for d in DIRECTORIES:
Path(d).mkdir(parents=True, exist_ok=True)
# Run the extraction commands:
tool = Path(install, 'ArchiveTool.exe')
for c in COMMANDS:
input_file = Path(install, c[0])
subprocess.run([
# ArchiveTool.exe in the TQ Install directory
str(tool),
# Resource ARC file in the TQ Install directory
str(input_file),
# Extract flag for the ArchiveTool executable
'-extract',
# Output directory (local data/ dir)
str(Path(c[1]).absolute()),
])