Python win32api.RegQueryValueEx() Examples
The following are 30
code examples of win32api.RegQueryValueEx().
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
win32api
, or try the search function
.
Example #1
Source File: platform.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using _winreg import _winreg RegQueryValueEx = _winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #2
Source File: windowsprivcheck.py From LHF with GNU General Public License v3.0 | 6 votes |
def get_user_paths(): try: keyh = win32api.RegOpenKeyEx(win32con.HKEY_USERS, None , 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: return 0 paths = [] subkeys = win32api.RegEnumKeyEx(keyh) for subkey in subkeys: try: subkeyh = win32api.RegOpenKeyEx(keyh, subkey[0] + "\\Environment" , 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: pass else: subkey_count, value_count, mod_time = win32api.RegQueryInfoKey(subkeyh) try: path, type = win32api.RegQueryValueEx(subkeyh, "PATH") paths.append((subkey[0], path)) except: pass return paths
Example #3
Source File: windowsprivcheck.py From LHF with GNU General Public License v3.0 | 6 votes |
def get_system_path(): # HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment key_string = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment' try: keyh = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, key_string , 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: return None try: path, type = win32api.RegQueryValueEx(keyh, "PATH") return path except: return None #name=sys.argv[1] #if not os.path.exists(name): #print name, "does not exist!" #sys.exit()
Example #4
Source File: recipe-174627.py From code with MIT License | 6 votes |
def __getitem__(self, item): item = str(item) # is it data? try: return self.massageIncomingRegistryValue(win32api.RegQueryValueEx(self.keyhandle, item)) except: pass # it's probably a key then try: return RegistryDict(self.keyhandle, item, win32con.KEY_ALL_ACCESS) except: pass # must not be there raise KeyError, item
Example #5
Source File: platform.py From jawfish with MIT License | 6 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using winreg import winreg RegQueryValueEx = winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #6
Source File: platform.py From pmatic with GNU General Public License v2.0 | 6 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using _winreg import _winreg RegQueryValueEx = _winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #7
Source File: windows-privesc-check.py From WHP with Do What The F*ck You Want To Public License | 6 votes |
def get_system_path(): # HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment key_string = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment' try: keyh = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, key_string , 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: return None try: path, type = win32api.RegQueryValueEx(keyh, "PATH") return path except: return None #name=sys.argv[1] #if not os.path.exists(name): #print name, "does not exist!" #sys.exit()
Example #8
Source File: windows-privesc-check.py From WHP with Do What The F*ck You Want To Public License | 6 votes |
def get_user_paths(): try: keyh = win32api.RegOpenKeyEx(win32con.HKEY_USERS, None , 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: return 0 paths = [] subkeys = win32api.RegEnumKeyEx(keyh) for subkey in subkeys: try: subkeyh = win32api.RegOpenKeyEx(keyh, subkey[0] + "\\Environment" , 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: pass else: subkey_count, value_count, mod_time = win32api.RegQueryInfoKey(subkeyh) try: path, type = win32api.RegQueryValueEx(subkeyh, "PATH") paths.append((subkey[0], path)) except: pass return paths
Example #9
Source File: platform.py From oss-ftp with MIT License | 6 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using _winreg import _winreg RegQueryValueEx = _winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #10
Source File: platform.py From Computable with MIT License | 6 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using _winreg import _winreg RegQueryValueEx = _winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #11
Source File: platform.py From BinderFilter with MIT License | 6 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using _winreg import _winreg RegQueryValueEx = _winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #12
Source File: platform.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using _winreg import _winreg RegQueryValueEx = _winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #13
Source File: platform.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using _winreg import _winreg RegQueryValueEx = _winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #14
Source File: test_win32api.py From ironpython2 with Apache License 2.0 | 6 votes |
def testValues(self): key_name = r'PythonTestHarness\win32api' ## tuples containing value name, value type, data values=( (None, win32con.REG_SZ, 'This is default unnamed value'), ('REG_SZ', win32con.REG_SZ,'REG_SZ text data'), ('REG_EXPAND_SZ', win32con.REG_EXPAND_SZ, '%systemdir%'), ## REG_MULTI_SZ value needs to be a list since strings are returned as a list ('REG_MULTI_SZ', win32con.REG_MULTI_SZ, ['string 1','string 2','string 3','string 4']), ('REG_DWORD', win32con.REG_DWORD, 666), ('REG_BINARY', win32con.REG_BINARY, str2bytes('\x00\x01\x02\x03\x04\x05\x06\x07\x08\x01\x00')), ) hkey = win32api.RegCreateKey(win32con.HKEY_CURRENT_USER, key_name) for value_name, reg_type, data in values: win32api.RegSetValueEx(hkey, value_name, None, reg_type, data) for value_name, orig_type, orig_data in values: data, typ=win32api.RegQueryValueEx(hkey, value_name) self.assertEqual(typ, orig_type) self.assertEqual(data, orig_data)
Example #15
Source File: win32serviceutil.py From ironpython2 with Apache License 2.0 | 6 votes |
def __FindSvcDeps(findName): if type(findName) is pywintypes.UnicodeType: findName = str(findName) dict = {} k = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services") num = 0 while 1: try: svc = win32api.RegEnumKey(k, num) except win32api.error: break num = num + 1 sk = win32api.RegOpenKey(k, svc) try: deps, typ = win32api.RegQueryValueEx(sk, "DependOnService") except win32api.error: deps = () for dep in deps: dep = dep.lower() dep_on = dict.get(dep, []) dep_on.append(svc) dict[dep]=dep_on return __ResolveDeps(findName, dict)
Example #16
Source File: regsetup.py From ironpython2 with Apache License 2.0 | 6 votes |
def FindHelpPath(helpFile, helpDesc, searchPaths): # See if the current registry entry is OK import os, win32api, win32con try: key = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\Help", 0, win32con.KEY_ALL_ACCESS) try: try: path = win32api.RegQueryValueEx(key, helpDesc)[0] if FileExists(os.path.join(path, helpFile)): return os.path.abspath(path) except win32api.error: pass # no registry entry. finally: key.Close() except win32api.error: pass for pathLook in searchPaths: if FileExists(os.path.join(pathLook, helpFile)): return os.path.abspath(pathLook) pathLook = os.path.join(pathLook, "Help") if FileExists(os.path.join( pathLook, helpFile)): return os.path.abspath(pathLook) raise error("The help file %s can not be located" % helpFile)
Example #17
Source File: platform.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using _winreg import _winreg RegQueryValueEx = _winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #18
Source File: platform.py From meddle with MIT License | 6 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using _winreg import _winreg RegQueryValueEx = _winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #19
Source File: platform.py From RevitBatchProcessor with GNU General Public License v3.0 | 6 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using _winreg import _winreg RegQueryValueEx = _winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #20
Source File: platform.py From canape with GNU General Public License v3.0 | 6 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using _winreg import _winreg RegQueryValueEx = _winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #21
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def StartYardServer(self): try: rkey = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Webers\\Y.A.R.D") path = RegQueryValueEx(rkey, "program")[0] if not os.path.exists(path): raise Exception except: raise self.Exception( "Please start Yards.exe first and configure it." ) try: hProcess = CreateProcess( None, path, None, None, 0, CREATE_NEW_CONSOLE, None, None, STARTUPINFO() )[0] except Exception, exc: raise eg.Exception(FormatError(exc[0]))
Example #22
Source File: win32.py From python-for-android with Apache License 2.0 | 5 votes |
def getProgramFilesPath(): """Get the path to the Program Files folder.""" keyname = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' currentV = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, keyname, 0, win32con.KEY_READ) return win32api.RegQueryValueEx(currentV, 'ProgramFilesDir')[0]
Example #23
Source File: platform.py From medicare-demo with Apache License 2.0 | 5 votes |
def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ from win32api import RegQueryValueEx try: return RegQueryValueEx(key,name) except: return default
Example #24
Source File: Constant.py From pc-protector-moe with GNU General Public License v3.0 | 5 votes |
def get_desktop(): key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 0, win32con.KEY_READ) return win32api.RegQueryValueEx(key, 'Desktop')[0]
Example #25
Source File: win32.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def getProgramsMenuPath(): """Get the path to the Programs menu. Probably will break on non-US Windows. @returns: the filesystem location of the common Start Menu->Programs. """ if not platform.isWinNT(): return "C:\\Windows\\Start Menu\\Programs" keyname = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders' hShellFolders = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, keyname, 0, win32con.KEY_READ) return win32api.RegQueryValueEx(hShellFolders, 'Common Programs')[0]
Example #26
Source File: win32.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def getProgramFilesPath(): """Get the path to the Program Files folder.""" keyname = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' currentV = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, keyname, 0, win32con.KEY_READ) return win32api.RegQueryValueEx(currentV, 'ProgramFilesDir')[0]
Example #27
Source File: ImportManager.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __init__(self): self.path = "WindowsRegistry" self.map = {} try: import win32api ## import win32con except ImportError: pass else: HKEY_CURRENT_USER = -2147483647 HKEY_LOCAL_MACHINE = -2147483646 KEY_ALL_ACCESS = 983103 subkey = r"Software\Python\PythonCore\%s\Modules" % sys.winver for root in (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE): try: hkey = win32api.RegOpenKeyEx(root, subkey, 0, KEY_ALL_ACCESS) except: pass else: numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(hkey) for i in range(numsubkeys): subkeyname = win32api.RegEnumKey(hkey, i) hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, KEY_ALL_ACCESS) val = win32api.RegQueryValueEx(hskey, '') desc = getDescr(val[0]) self.map[subkeyname] = (val[0], desc) hskey.Close() hkey.Close() break
Example #28
Source File: impdirector.py From ConTroll_Remote_Access_Trojan with Apache License 2.0 | 5 votes |
def __init__(self): self.path = "WindowsRegistry" self.map = {} try: import win32api import win32con except ImportError: return subkey = r"Software\Python\PythonCore\%s\Modules" % sys.winver for root in (win32con.HKEY_CURRENT_USER, win32con.HKEY_LOCAL_MACHINE): try: hkey = win32api.RegOpenKeyEx(root, subkey, 0, win32con.KEY_READ) except Exception, e: logger.debug('RegistryImportDirector: %s' % e) continue numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(hkey) for i in range(numsubkeys): subkeyname = win32api.RegEnumKey(hkey, i) hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, win32con.KEY_READ) val = win32api.RegQueryValueEx(hskey, '') desc = getDescr(val[0]) #print " RegistryImportDirector got %s %s" % (val[0], desc) #XXX self.map[subkeyname] = (val[0], desc) hskey.Close() hkey.Close() break
Example #29
Source File: msw.py From wxGlade with MIT License | 5 votes |
def __getitem__(self, name): value, type = win32api.RegQueryValueEx( self.handle, name) if type==win32con.REG_MULTI_SZ: return tuple(value) return value
Example #30
Source File: putty.py From BrainDamage with Apache License 2.0 | 5 votes |
def get_default_database(self): accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, 'Software\\ACS\\PuTTY Connection Manager', 0, accessRead) thisName = str(win32api.RegQueryValueEx(key, 'DefaultDatabase')[0]) if thisName: return thisName else: return ' '