当前位置: 首页>>代码示例>>Python>>正文


Python win32con.HKEY_LOCAL_MACHINE属性代码示例

本文整理汇总了Python中win32con.HKEY_LOCAL_MACHINE属性的典型用法代码示例。如果您正苦于以下问题:Python win32con.HKEY_LOCAL_MACHINE属性的具体用法?Python win32con.HKEY_LOCAL_MACHINE怎么用?Python win32con.HKEY_LOCAL_MACHINE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在win32con的用法示例。


在下文中一共展示了win32con.HKEY_LOCAL_MACHINE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DumpRegistry

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [as 别名]
def DumpRegistry(root, level=0):
    # A recursive dump of the remote registry to test most functions.
    h = wincerapi.CeRegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, None)
    level_prefix = " " * level
    index = 0
    # Enumerate values.
    while 1:
        try:
            name, data, typ = wincerapi.CeRegEnumValue(root, index)
        except win32api.error:
            break
        print "%s%s=%s" % (level_prefix, name, repr(str(data)))
        index = index+1
    # Now enumerate all keys.
    index=0
    while 1:
        try:
            name, klass = wincerapi.CeRegEnumKeyEx(root, index)
        except win32api.error:
            break
        print "%s%s\\" % (level_prefix, name)
        subkey = wincerapi.CeRegOpenKeyEx(root, name)
        DumpRegistry(subkey, level+1)
        index = index+1 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:26,代码来源:cerapi.py

示例2: _GetServiceShortName

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [as 别名]
def _GetServiceShortName(longName):
    # looks up a services name
    # from the display name
    # Thanks to Andy McKay for this code.
    access = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
    hkey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services", 0, access)
    num = win32api.RegQueryInfoKey(hkey)[0]
    longName = longName.lower()
    # loop through number of subkeys
    for x in range(0, num):
    # find service name, open subkey
        svc = win32api.RegEnumKey(hkey, x)
        skey = win32api.RegOpenKey(hkey, svc, 0, access)
        try:
            # find display name
            thisName = str(win32api.RegQueryValueEx(skey, "DisplayName")[0])
            if thisName.lower() == longName:
                return svc
        except win32api.error:
            # in case there is no key called DisplayName
            pass
    return None

# Open a service given either it's long or short name. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:26,代码来源:win32serviceutil.py

示例3: __FindSvcDeps

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:win32serviceutil.py

示例4: get_system_path

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [as 别名]
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() 
开发者ID:51x,项目名称:WHP,代码行数:20,代码来源:windows-privesc-check.py

示例5: _GetRegistryValue

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [as 别名]
def _GetRegistryValue(key, val, default = None):
	# val is registry value - None for default val.
	try:
		hkey = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, key)
		return win32api.RegQueryValueEx(hkey, val)[0]
	except win32api.error:
		try:
			hkey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, key)
			return win32api.RegQueryValueEx(hkey, val)[0]
		except win32api.error:
			return default 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:app.py

示例6: FindTabNanny

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [as 别名]
def FindTabNanny():
	try:
		return __import__("tabnanny")
	except ImportError:
		pass
	# OK - not in the standard library - go looking.
	filename = "tabnanny.py"
	try:
		path = win32api.RegQueryValue(win32con.HKEY_LOCAL_MACHINE, "SOFTWARE\\Python\\PythonCore\\%s\\InstallPath" % (sys.winver))
	except win32api.error:
		print "WARNING - The Python registry does not have an 'InstallPath' setting"
		print "          The file '%s' can not be located" % (filename)
		return None
	fname = os.path.join(path, "Tools\\Scripts\\%s" % filename)
	try:
		os.stat(fname)
	except os.error:
		print "WARNING - The file '%s' can not be located in path '%s'" % (filename, path)
		return None

	tabnannyhome, tabnannybase = os.path.split(fname)
	tabnannybase = os.path.splitext(tabnannybase)[0]
	# Put tab nanny at the top of the path.
	sys.path.insert(0, tabnannyhome)
	try:
		return __import__(tabnannybase)
	finally:
		# remove the tab-nanny from the path
		del sys.path[0] 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:31,代码来源:scriptutils.py

示例7: ListAllHelpFiles

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [as 别名]
def ListAllHelpFiles():
	ret = []
	ret = _ListAllHelpFilesInRoot(win32con.HKEY_LOCAL_MACHINE)
	# Ensure we don't get dups.
	for item in _ListAllHelpFilesInRoot(win32con.HKEY_CURRENT_USER):
		if item not in ret:
			ret.append(item)
	return ret 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:help.py

示例8: DumpPythonRegistry

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [as 别名]
def DumpPythonRegistry():
    try:
        h = wincerapi.CeRegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\PythonPath" % sys.winver)
    except win32api.error:
        print "The remote device does not appear to have Python installed"
        return 0
    path, typ = wincerapi.CeRegQueryValueEx(h, None)
    print "The remote PythonPath is '%s'" % (str(path), )
    h.Close()
    return 1 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:cerapi.py

示例9: RemoveSourceFromRegistry

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [as 别名]
def RemoveSourceFromRegistry(appName, eventLogType = "Application"):
    """Removes a source of messages from the event log.
    """

    # Delete our key
    try:
        win32api.RegDeleteKey(win32con.HKEY_LOCAL_MACHINE, \
                     "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (eventLogType, appName))
    except win32api.error, exc:
        if exc.winerror != winerror.ERROR_FILE_NOT_FOUND:
            raise 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:win32evtlogutil.py

示例10: FormatMessage

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [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

示例11: UnregisterHelpFile

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [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

示例12: LocatePythonServiceExe

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [as 别名]
def LocatePythonServiceExe(exeName = None):
    if not exeName and hasattr(sys, "frozen"):
        # If py2exe etc calls this with no exeName, default is current exe.
        return sys.executable

    # Try and find the specified EXE somewhere.  If specifically registered,
    # use it.  Otherwise look down sys.path, and the global PATH environment.
    if exeName is None:
        if os.path.splitext(win32service.__file__)[0].endswith("_d"):
            exeName = "PythonService_d.exe"
        else:
            exeName = "PythonService.exe"
    # See if it exists as specified
    if os.path.isfile(exeName): return win32api.GetFullPathName(exeName)
    baseName = os.path.splitext(os.path.basename(exeName))[0]
    try:
        exeName = win32api.RegQueryValue(win32con.HKEY_LOCAL_MACHINE,
                                         "Software\\Python\\%s\\%s" % (baseName, sys.winver))
        if os.path.isfile(exeName):
            return exeName
        raise RuntimeError("The executable '%s' is registered as the Python " \
                           "service exe, but it does not exist as specified" \
                           % exeName)
    except win32api.error:
        # OK - not there - lets go a-searchin'
        for path in [sys.prefix] + sys.path:
            look = os.path.join(path, exeName)
            if os.path.isfile(look):
                return win32api.GetFullPathName(look)
        # Try the global Path.
        try:
            return win32api.SearchPath(None, exeName)[0]
        except win32api.error:
            msg = "%s is not correctly registered\nPlease locate and run %s, and it will self-register\nThen run this service registration process again." % (exeName, exeName)
            raise error(msg) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:37,代码来源:win32serviceutil.py

示例13: InstallPythonClassString

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [as 别名]
def InstallPythonClassString(pythonClassString, serviceName):
    # Now setup our Python specific entries.
    if pythonClassString:
        key = win32api.RegCreateKey(win32con.HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\%s\\PythonClass" % serviceName)
        try:
            win32api.RegSetValue(key, None, win32con.REG_SZ, pythonClassString);
        finally:
            win32api.RegCloseKey(key)

# Utility functions for Services, to allow persistant properties. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:win32serviceutil.py

示例14: SetServiceCustomOption

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [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

示例15: GetServiceCustomOption

# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import HKEY_LOCAL_MACHINE [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


注:本文中的win32con.HKEY_LOCAL_MACHINE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。