當前位置: 首頁>>代碼示例>>Python>>正文


Python win32api.RegCloseKey方法代碼示例

本文整理匯總了Python中win32api.RegCloseKey方法的典型用法代碼示例。如果您正苦於以下問題:Python win32api.RegCloseKey方法的具體用法?Python win32api.RegCloseKey怎麽用?Python win32api.RegCloseKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在win32api的用法示例。


在下文中一共展示了win32api.RegCloseKey方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: GetSubList

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
def GetSubList(self):
		keyStr = regutil.BuildDefaultPythonKey() + "\\PythonPath"
		hKey = win32api.RegOpenKey(regutil.GetRootKey(), keyStr)
		try:
			ret = []
			ret.append(HLIProjectRoot("", "Standard Python Library")) # The core path.
			index = 0
			while 1:
				try:
					ret.append(HLIProjectRoot(win32api.RegEnumKey(hKey, index)))
					index = index + 1
				except win32api.error:
					break
			return ret
		finally:
			win32api.RegCloseKey(hKey) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:18,代碼來源:browseProjects.py

示例2: UpdateForRegItem

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
def UpdateForRegItem(self, item):
		self.DeleteAllItems()
		hkey = win32api.RegOpenKey(item.keyRoot, item.keyName)
		try:
			valNum = 0
			ret = []
			while 1:
				try:
					res = win32api.RegEnumValue(hkey, valNum)
				except win32api.error:
					break
				name = res[0]
				if not name: name = "(Default)"
				self.InsertItem(valNum, name)
				self.SetItemText(valNum, 1, str(res[1]))
				valNum = valNum + 1
		finally:
			win32api.RegCloseKey(hkey) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:20,代碼來源:regedit.py

示例3: RegisterCoreDLL

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
def RegisterCoreDLL(coredllName = None):
	"""Registers the core DLL in the registry.

        If no params are passed, the name of the Python DLL used in 
        the current process is used and registered.
	"""
	if coredllName is None:
		coredllName = win32api.GetModuleFileName(sys.dllhandle)
		# must exist!
	else:
		try:
			os.stat(coredllName)
		except os.error:
			print "Warning: Registering non-existant core DLL %s" % coredllName

	hKey = win32api.RegCreateKey(GetRootKey() , BuildDefaultPythonKey())
	try:
		win32api.RegSetValue(hKey, "Dll", win32con.REG_SZ, coredllName)
	finally:
		win32api.RegCloseKey(hKey)
	# Lastly, setup the current version to point to me.
	win32api.RegSetValue(GetRootKey(), "Software\\Python\\PythonCore\\CurrentVersion", win32con.REG_SZ, sys.winver) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:24,代碼來源:regutil.py

示例4: deleteKey

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
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 
開發者ID:MozillaSecurity,項目名稱:peach,代碼行數:22,代碼來源:util.py

示例5: GetItemsCurrentValue

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
def GetItemsCurrentValue(self, item, valueName):
		hkey = win32api.RegOpenKey(item.keyRoot, item.keyName)
		try:
			val, type = win32api.RegQueryValueEx(hkey, valueName)
			if type != win32con.REG_SZ:
				raise TypeError("Only strings can be edited")
			return val
		finally:
			win32api.RegCloseKey(hkey) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:regedit.py

示例6: SetItemsCurrentValue

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
def SetItemsCurrentValue(self, item, valueName, value):
		# ** Assumes already checked is a string.
		hkey = win32api.RegOpenKey(item.keyRoot, item.keyName , 0, win32con.KEY_SET_VALUE)
		try:
			win32api.RegSetValueEx(hkey, valueName, 0, win32con.REG_SZ, value)
		finally:
			win32api.RegCloseKey(hkey) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:regedit.py

示例7: IsExpandable

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
def IsExpandable(self):
		# All keys are expandable, even if they currently have zero children.
		return 1
##		hkey = win32api.RegOpenKey(self.keyRoot, self.keyName)
##		try:
##			keys, vals, dt = win32api.RegQueryInfoKey(hkey)
##			return (keys>0)
##		finally:
##			win32api.RegCloseKey(hkey) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:regedit.py

示例8: FormatMessage

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
def FormatMessage( eventLogRecord, logType="Application" ):
    """Given a tuple from ReadEventLog, and optionally where the event
    record came from, load the message, and process message inserts.

    Note that this function may raise win32api.error.  See also the
    function SafeFormatMessage which will return None if the message can
    not be processed.
    """

    # From the event log source name, we know the name of the registry
    # key to look under for the name of the message DLL that contains
    # the messages we need to extract with FormatMessage. So first get
    # the event log source name...
    keyName = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (logType, eventLogRecord.SourceName)

    # Now open this key and get the EventMessageFile value, which is
    # the name of the message DLL.
    handle = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, keyName)
    try:
        dllNames = win32api.RegQueryValueEx(handle, "EventMessageFile")[0].split(";")
        # Win2k etc appear to allow multiple DLL names
        data = None
        for dllName in dllNames:
            try:
                # Expand environment variable strings in the message DLL path name,
                # in case any are there.
                dllName = win32api.ExpandEnvironmentStrings(dllName)

                dllHandle = win32api.LoadLibraryEx(dllName, 0, win32con.LOAD_LIBRARY_AS_DATAFILE)
                try:
                    data = win32api.FormatMessageW(win32con.FORMAT_MESSAGE_FROM_HMODULE,
                                    dllHandle, eventLogRecord.EventID, langid, eventLogRecord.StringInserts)
                finally:
                    win32api.FreeLibrary(dllHandle)
            except win32api.error:
                pass # Not in this DLL - try the next
            if data is not None:
                break
    finally:
        win32api.RegCloseKey(handle)
    return data or u'' # Don't want "None" ever being returned. 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:43,代碼來源:win32evtlogutil.py

示例9: UnregisterHelpFile

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
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 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:28,代碼來源:regutil.py

示例10: SetServiceCustomOption

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
def SetServiceCustomOption(serviceName, option, value):
    try:
        serviceName = serviceName._svc_name_
    except AttributeError:
        pass
    key = win32api.RegCreateKey(win32con.HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\%s\\Parameters" % serviceName)
    try:
        if type(value)==type(0):
            win32api.RegSetValueEx(key, option, 0, win32con.REG_DWORD, value);
        else:
            win32api.RegSetValueEx(key, option, 0, win32con.REG_SZ, value);
    finally:
        win32api.RegCloseKey(key) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:win32serviceutil.py

示例11: GetServiceCustomOption

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
def GetServiceCustomOption(serviceName, option, defaultValue = None):
    # First param may also be a service class/instance.
    # This allows services to pass "self"
    try:
        serviceName = serviceName._svc_name_
    except AttributeError:
        pass
    key = win32api.RegCreateKey(win32con.HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\%s\\Parameters" % serviceName)
    try:
        try:
            return win32api.RegQueryValueEx(key, option)[0]
        except win32api.error:  # No value.
            return defaultValue
    finally:
        win32api.RegCloseKey(key) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:17,代碼來源:win32serviceutil.py

示例12: GetSubList

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
def GetSubList(self):
        # Explicit lookup in the registry.
        ret = []
        key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, "TypeLib")
        win32ui.DoWaitCursor(1)
        try:
            num = 0
            while 1:
                try:
                    keyName = win32api.RegEnumKey(key, num)
                except win32api.error:
                    break
                # Enumerate all version info
                subKey = win32api.RegOpenKey(key, keyName)
                name = None
                try:
                    subNum = 0
                    bestVersion = 0.0
                    while 1:
                        try:
                            versionStr = win32api.RegEnumKey(subKey, subNum)
                        except win32api.error:
                            break
                        try:
                            versionFlt = float(versionStr)
                        except ValueError:
                            versionFlt = 0 # ????
                        if versionFlt > bestVersion:
                            bestVersion = versionFlt
                            name = win32api.RegQueryValue(subKey, versionStr)
                        subNum = subNum + 1
                finally:
                    win32api.RegCloseKey(subKey)
                if name is not None:
                    ret.append(HLIRegisteredTypeLibrary((keyName, versionStr), name))
                num = num + 1
        finally:
            win32api.RegCloseKey(key)
            win32ui.DoWaitCursor(0)
        ret.sort()
        return ret 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:43,代碼來源:combrowse.py

示例13: _set_subkeys

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
def _set_subkeys(keyName, valueDict, base=win32con.HKEY_CLASSES_ROOT):
  hkey = win32api.RegCreateKey(base, keyName)
  try:
    for key, value in valueDict.iteritems():
      win32api.RegSetValueEx(hkey, key, None, win32con.REG_SZ, value)
  finally:
    win32api.RegCloseKey(hkey) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:register.py

示例14: close

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
def close(self):
        try:
            win32api.RegCloseKey(self.keyhandle)
        except:
            pass 
開發者ID:ActiveState,項目名稱:code,代碼行數:7,代碼來源:recipe-174627.py

示例15: modifyVariableInRegister

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegCloseKey [as 別名]
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 ) 
開發者ID:ActiveState,項目名稱:code,代碼行數:7,代碼來源:recipe-576431.py


注:本文中的win32api.RegCloseKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。