Python win32con.KEY_ALL_ACCESS Examples
The following are 17
code examples of win32con.KEY_ALL_ACCESS().
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
win32con
, or try the search function
.
Example #1
Source File: registry.py From code with MIT License | 6 votes |
def __init__(self, hKey, path=None, machine=None): self.access = Con.KEY_ALL_ACCESS if isinstance(hKey, pywintypes.HANDLEType): if path is None: self.hKey = hKey self.path = None else: self.hKey = Api.RegOpenKeyEx(hKey, path, 0, self.access) self.path = path self.machine = None else: if machine is None: self.hKey = Api.RegOpenKeyEx(hKey, path, 0, self.access) self.path = path else: if not machine.startswith("\\\\"): machine = "\\\\%s" % machine hKey = Api.RegConnectRegistry(machine, hKey) if path is None: self.hKey = hKey else: self.hKey = Api.RegOpenKeyEx(hKey, path, 0, self.access) self.path = path self.machine = machine
Example #2
Source File: msw.py From wxGlade with MIT License | 6 votes |
def __init__(self, keyname, handle=None, mode="w"): #access=win32con.KEY_ALL_ACCESS): """Easy access to win32 registry. mode: 'r' or 'w'""" if mode=="w": access = win32con.KEY_ALL_ACCESS elif mode=="r": access = win32con.KEY_READ else: raise ValueError( "mode must be 'r' or 'w'" ) self.mode = mode self.handle = None if handle is None: handle=self.branch # open key try: self.handle = win32api.RegOpenKeyEx(handle, keyname, 0, access) except: #except (pywintypes.error, pywintypes.api_error): self.handle = win32api.RegCreateKey(handle, keyname)
Example #3
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 #4
Source File: util.py From peach with Mozilla Public License 2.0 | 6 votes |
def deleteKey(self, hKey, subKey): """ Recursively remove registry keys. """ try: hKey = win32api.RegOpenKeyEx(hKey, subKey, 0, win32con.KEY_ALL_ACCESS) try: while True: s = win32api.RegEnumKey(hKey, 0) self.deleteKey(hKey, s) print("CleanupRegistry: Removing sub-key '{}'".format(s)) win32api.RegDeleteKey(hKey, s) except win32api.error: pass finally: win32api.RegCloseKey(hKey) except: print("Warning: Unable to open registry key!") pass
Example #5
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 #6
Source File: recipe-174627.py From code with MIT License | 5 votes |
def iteritems(self, access=win32con.KEY_ALL_ACCESS): # yield children for item in self.iteritems_data(): yield item for item in self.iteritems_children(access): yield item
Example #7
Source File: recipe-576431.py From code with MIT License | 5 votes |
def modifyVariableInRegister( name , value ): key = win32api.RegOpenKey( win32con.HKEY_CURRENT_USER,"Environment",0,win32con.KEY_ALL_ACCESS) if not key : raise win32api.RegSetValueEx( key , name , 0 , win32con.REG_SZ , value ) win32api.RegCloseKey( key )
Example #8
Source File: recipe-174627.py From code with MIT License | 5 votes |
def values(self, access=win32con.KEY_ALL_ACCESS): return list(self.itervalues(access))
Example #9
Source File: recipe-174627.py From code with MIT License | 5 votes |
def items(self, access=win32con.KEY_ALL_ACCESS): return list(self.iteritems())
Example #10
Source File: recipe-174627.py From code with MIT License | 5 votes |
def itervalues(self, access=win32con.KEY_ALL_ACCESS): for key, value in self.iteritems(access): yield value
Example #11
Source File: recipe-174627.py From code with MIT License | 5 votes |
def itervalues_children(self, access=win32con.KEY_ALL_ACCESS): for key, value in self.iteritems_children(access): yield value
Example #12
Source File: regutil.py From ironpython2 with Apache License 2.0 | 5 votes |
def UnregisterHelpFile(helpFile, helpDesc = None): """Unregister a help file in the registry. helpFile -- the base name of the help file. helpDesc -- A description for the help file. If None, the helpFile param is used. """ key = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\Help", 0, win32con.KEY_ALL_ACCESS) try: try: win32api.RegDeleteValue(key, helpFile) except win32api.error, exc: import winerror if exc.winerror!=winerror.ERROR_FILE_NOT_FOUND: raise finally: win32api.RegCloseKey(key) # Now de-register with Python itself. if helpDesc is None: helpDesc = helpFile try: win32api.RegDeleteKey(GetRootKey(), BuildDefaultPythonKey() + "\\Help\\%s" % helpDesc) except win32api.error, exc: import winerror if exc.winerror!=winerror.ERROR_FILE_NOT_FOUND: raise
Example #13
Source File: recipe-174627.py From code with MIT License | 5 votes |
def iteritems_children(self, access=win32con.KEY_ALL_ACCESS): i = 0 try: while 1: s, obj, objtype = win32api.RegEnumKey(self.keyhandle, i) yield s, RegistryDict(self.keyhandle, [s], access) i += 1 except: pass
Example #14
Source File: recipe-265858.py From code with MIT License | 5 votes |
def getSoftwareList(self): try: hCounter=0 hAttCounter=0 # connecting to the base hHandle = win32api.RegConnectRegistry(None,win32con.HKEY_LOCAL_MACHINE) # getting the machine name and domain name hCompName = win32api.GetComputerName() hDomainName = win32api.GetDomainName() # opening the sub key to get the list of Softwares installed hHandle = win32api.RegOpenKeyEx(self.HKEY_LOCAL_MACHINE,self.CONST_SW_SUBKEY,0,win32con.KEY_ALL_ACCESS) # get the total no. of sub keys hNoOfSubNodes = win32api.RegQueryInfoKey(hHandle) # delete the entire data and insert it again #deleteMachineSW(hCompName,hDomainName) # browsing each sub Key which can be Applications installed while hCounter < hNoOfSubNodes[0]: hAppName = win32api.RegEnumKey(hHandle,hCounter) hPath = self.CONST_SW_SUBKEY + "\\" + hAppName # initialising hAttCounter hAttCounter = 0 hOpenApp = win32api.RegOpenKeyEx(self.HKEY_LOCAL_MACHINE,hPath,0,win32con.KEY_ALL_ACCESS) # [1] will give the no. of attributes in this sub key hKeyCount = win32api.RegQueryInfoKey(hOpenApp) hMaxKeyCount = hKeyCount[1] hSWName = "" hSWVersion = "" while hAttCounter < hMaxKeyCount: hData = win32api.RegEnumValue(hOpenApp,hAttCounter) if hData[0]== "DisplayName": hSWName = hData[1] self.preparefile("SW Name",hSWName) elif hData[0]== "DisplayVersion": hSWVersion = hData[1] self.preparefile("SW Version",hSWVersion) hAttCounter = hAttCounter + 1 #if (hSWName !=""): #insertMachineSW(hCompName,hDomainName,hSWName,hSWVersion) hCounter = hCounter + 1 except: self.preparefile("Exception","In exception in getSoftwareList")
Example #15
Source File: win32serviceutil.py From ironpython2 with Apache License 2.0 | 5 votes |
def LocateSpecificServiceExe(serviceName): # Given the name of a specific service, return the .EXE name _it_ uses # (which may or may not be the Python Service EXE hkey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\%s" % (serviceName), 0, win32con.KEY_ALL_ACCESS) try: return win32api.RegQueryValueEx(hkey, "ImagePath")[0] finally: hkey.Close()
Example #16
Source File: recipe-265858.py From code with MIT License | 4 votes |
def getSysInfo(self): try: hCounter=0 hProcessorName="" # connecting to the base hHandle = win32api.RegConnectRegistry(None,self.HKEY_LOCAL_MACHINE) # opening the sub key to get the processor name print "debug1" hHandle = win32api.RegOpenKeyEx(self.HKEY_LOCAL_MACHINE,self.CONST_PROC_SUBKEY,0,win32con.KEY_ALL_ACCESS) hNoOfKeys = win32api.RegQueryInfoKey(hHandle)[1] while hCounter < hNoOfKeys: hData = win32api.RegEnumValue(hHandle,hCounter) if hData[0]== "Identifier": hProcessorName = hData[1] hCounter = hCounter + 1 if hProcessorName=="": hProcessorName = "Processor Name Cannot be determined" self.preparefile("Processor Name",hProcessorName) hCompName = win32api.GetComputerName() self.preparefile("Computer Name",hCompName) hDomainName = win32api.GetDomainName() self.preparefile("Domain Name",hDomainName) hUserName = win32api.GetUserName() self.preparefile("User Name",hUserName) # getting OS Details hCounter=0 # opening the sub key to get the processor name hHandle = win32api.RegOpenKeyEx(self.HKEY_LOCAL_MACHINE,self.CONST_OS_SUBKEY,0,win32con.KEY_ALL_ACCESS) hNoOfKeys = win32api.RegQueryInfoKey(hHandle)[1] hOSVersion="" hOSName="" while hCounter < hNoOfKeys: hData = win32api.RegEnumValue(hHandle,hCounter) if hData[0]== "ProductName": hOSName = hData[1] self.preparefile("OS Name",hOSName) break hCounter = hCounter + 1 if hOSName=="": self.preparefile("OS Name","OS Name could not be read from the registry") hCounter = 0 while hCounter < hNoOfKeys: hData = win32api.RegEnumValue(hHandle,hCounter) if hData[0]== "CSDVersion": hOSVersion = hData[1] self.preparefile("OS Version",hOSVersion) break hCounter = hCounter + 1 if hOSVersion=="": self.preparefile("OS Version","OS Version could not be read from the registry") # inserting master data #insertMachineMaster(hCompName,hDomainName,hOSName,hOSVersion,hProcessorName) except: self.preparefile("Exception","in Exception in getSysDetails")
Example #17
Source File: win32serviceutil.py From ironpython2 with Apache License 2.0 | 4 votes |
def InstallPerfmonForService(serviceName, iniName, dllName = None): # If no DLL name, look it up in the INI file name if not dllName: # May be empty string! dllName = win32api.GetProfileVal("Python", "dll", "", iniName) # Still not found - look for the standard one in the same dir as win32service.pyd if not dllName: try: tryName = os.path.join(os.path.split(win32service.__file__)[0], "perfmondata.dll") if os.path.isfile(tryName): dllName = tryName except AttributeError: # Frozen app? - anyway, can't find it! pass if not dllName: raise ValueError("The name of the performance DLL must be available") dllName = win32api.GetFullPathName(dllName) # Now setup all the required "Performance" entries. hkey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\%s" % (serviceName), 0, win32con.KEY_ALL_ACCESS) try: subKey = win32api.RegCreateKey(hkey, "Performance") try: win32api.RegSetValueEx(subKey, "Library", 0, win32con.REG_SZ, dllName) win32api.RegSetValueEx(subKey, "Open", 0, win32con.REG_SZ, "OpenPerformanceData") win32api.RegSetValueEx(subKey, "Close", 0, win32con.REG_SZ, "ClosePerformanceData") win32api.RegSetValueEx(subKey, "Collect", 0, win32con.REG_SZ, "CollectPerformanceData") finally: win32api.RegCloseKey(subKey) finally: win32api.RegCloseKey(hkey) # Now do the "Lodctr" thang... try: import perfmon path, fname = os.path.split(iniName) oldPath = os.getcwd() if path: os.chdir(path) try: perfmon.LoadPerfCounterTextStrings("python.exe " + fname) finally: os.chdir(oldPath) except win32api.error, details: print "The service was installed OK, but the performance monitor" print "data could not be loaded.", details