当前位置: 首页>>代码示例>>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;未经允许,请勿转载。