本文整理匯總了Python中winreg.QueryValue方法的典型用法代碼示例。如果您正苦於以下問題:Python winreg.QueryValue方法的具體用法?Python winreg.QueryValue怎麽用?Python winreg.QueryValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類winreg
的用法示例。
在下文中一共展示了winreg.QueryValue方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _find_chrome_win
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import QueryValue [as 別名]
def _find_chrome_win():
import winreg as reg
reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'
for install_type in reg.HKEY_CURRENT_USER, reg.HKEY_LOCAL_MACHINE:
try:
reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
chrome_path = reg.QueryValue(reg_key, None)
reg_key.Close()
if not os.path.isfile(chrome_path):
continue
except WindowsError:
chrome_path = None
else:
break
return chrome_path
示例2: win_find_path
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import QueryValue [as 別名]
def win_find_path():
import winreg
reg = winreg.ConnectRegistry(None, winreg.HKEY_CLASSES_ROOT)
subkeys = [
r'Stata16Do\shell\do\command', r'Stata15Do\shell\do\command',
r'Stata14Do\shell\do\command', r'Stata13Do\shell\do\command',
r'Stata12Do\shell\do\command']
fpath = ''
for subkey in subkeys:
try:
key = winreg.OpenKey(reg, subkey)
fpath = winreg.QueryValue(key, None).split('"')[1]
except FileNotFoundError:
pass
if fpath:
break
return fpath
示例3: getGenerateScript
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import QueryValue [as 別名]
def getGenerateScript(self):
# Under Windows, GenerateProjectFiles.bat only exists for source builds of the engine
batFile = self.getEngineRoot() + '\\Engine\\Build\\BatchFiles\\GenerateProjectFiles.bat'
if os.path.exists(batFile):
return batFile
# For versions of the engine installed using the launcher, we need to query the shell integration
# to determine the location of the Unreal Version Selector executable, which generates VS project files
try:
key = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, 'Unreal.ProjectFile\\shell\\rungenproj\\command')
if key:
command = winreg.QueryValue(key, None)
if len(command) > 0:
# Write the command to run UnrealVersionSelector.exe to our own batch file
customBat = os.path.join(self._customBatchScriptDir(), 'GenerateProjectFiles.bat')
Utility.writeFile(customBat, command.replace('"%1"', '%1') + '\r\n')
return customBat
except:
pass
raise UnrealManagerException('could not detect the location of GenerateProjectFiles.bat or UnrealVersionSelector.exe.\nThis typically indicates that .uproject files are not correctly associated with UE4.')
示例4: _find_edge_win
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import QueryValue [as 別名]
def _find_edge_win():
import winreg as reg
reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe'
for install_type in reg.HKEY_CURRENT_USER, reg.HKEY_LOCAL_MACHINE:
try:
reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
edge_path = reg.QueryValue(reg_key, None)
reg_key.Close()
if not os.path.isfile(edge_path):
continue
except WindowsError:
edge_path = None
else:
break
return edge_path
示例5: get_registry_app_path
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import QueryValue [as 別名]
def get_registry_app_path(key,filename):
if not winreg:
return None
try:
result=winreg.QueryValue(key,"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\%s.exe"%filename[0])
except WindowsError:
pass
else:
if os.path.isfile(result):
return result
示例6: get_browser_path
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import QueryValue [as 別名]
def get_browser_path():
paths_dict = {}
for name in BROWSER_PATH:
handler = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE, BROWSER_PATH[name], access=winreg.KEY_READ)
abs_path = winreg.QueryValue(handler, None)
# print(abs_path)
paths_dict[name] = abs_path
return paths_dict
示例7: find_chrome_win
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import QueryValue [as 別名]
def find_chrome_win():
import winreg as reg
reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'
for install_type in reg.HKEY_LOCAL_MACHINE, reg.HKEY_CURRENT_USER:
try:
reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
chrome_path = reg.QueryValue(reg_key, None)
reg_key.Close()
except WindowsError:
pass
return chrome_path
示例8: find_firefox_win
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import QueryValue [as 別名]
def find_firefox_win():
import winreg as reg
reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe'
for install_type in reg.HKEY_LOCAL_MACHINE, reg.HKEY_CURRENT_USER:
try:
reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
firefox_path = reg.QueryValue(reg_key, None)
reg_key.Close()
except WindowsError:
pass
return firefox_path
示例9: _get_interpreters_from_windows_registry
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import QueryValue [as 別名]
def _get_interpreters_from_windows_registry(self):
# https://github.com/python/cpython/blob/master/Tools/msi/README.txt
import winreg
result = set()
for key in [winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER]:
for version in [
"3.5",
"3.5-32",
"3.5-64",
"3.6",
"3.6-32",
"3.6-64",
"3.7",
"3.7-32",
"3.7-64",
"3.8",
"3.8-32",
"3.8-64",
]:
try:
for subkey in [
"SOFTWARE\\Python\\PythonCore\\" + version + "\\InstallPath",
"SOFTWARE\\Python\\PythonCore\\Wow6432Node\\" + version + "\\InstallPath",
]:
dir_ = winreg.QueryValue(key, subkey)
if dir_:
path = os.path.join(dir_, WINDOWS_EXE)
if os.path.exists(path):
result.add(path)
except Exception:
pass
return result
示例10: find_makensis_win
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import QueryValue [as 別名]
def find_makensis_win():
"""Locate makensis.exe on Windows by querying the registry"""
try:
nsis_install_dir = winreg.QueryValue(
winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\NSIS"
)
except OSError:
nsis_install_dir = winreg.QueryValue(
winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\NSIS"
)
return pjoin(nsis_install_dir, "makensis.exe")
示例11: find_chrome_win
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import QueryValue [as 別名]
def find_chrome_win(self):
import winreg as reg
reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'
for install_type in reg.HKEY_CURRENT_USER, reg.HKEY_LOCAL_MACHINE:
try:
reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
chrome_path = reg.QueryValue(reg_key, None)
reg_key.Close()
except WindowsError:
chrome_path = None
else:
break
return chrome_path