用PYTHON再WIN7中查看开机启动项

from win32api import *
from win32con import *
import string

def GetValues(fullname):
    name=string.split(fullname,'\\',1)

    if name[0]=='HKEY_CLASSES_ROOT':
                 key=RegOpenKey(HKEY_CLASSES_ROOT,name[1],0,KEY_READ)
    elif name[0]=='HKEY_CURRENT_USER':
                 key=RegOpenKey(HKEY_CURRENT_USER,name[1],0,KEY_READ)
    elif name[0]=='HKEY_LOCAL_MACHINE':
                 key=RegOpenKey(HKEY_LOCAL_MACHINE,name[1],0,KEY_READ)
    elif name[0]=='HKEY_USERS':
                key=RegOpenKey(HKEY_USERS,name[1],0,KEY_READ)
    elif name[0]=='HKEY_CURRENT_CONFIG':
                key=RegOpenKey(HKEY_CURRENT_CONFIG,name[1],0,KEY_READ)
    else:
        print "err,no key named%s"%name[0]
    Info=RegQueryInfoKey(key)
    for i in range(0,Info[1]):
        Info=RegEnumValue(key,i)
        print string.ljust(Info[0],20)
    RegCloseKey(key)
if __name__=='__main__':
    keys=['HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run',
         'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce',
          'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run',
          'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce'
          ]
    for c in keys:
        c
        GetValues(c)

你可能感兴趣的:(用PYTHON再WIN7中查看开机启动项)