python修改注册表,支持ocx控件

IE_SET=['1004','1200','1201','1405','1803','2201']
pathS=r'c:\vision'

def modiIeSetting():

    global IE_SET
    #_winreg.OpenKey()
    index = 0
    while index < 4:
        try:
            key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones" +
                                   os.path.sep + str(index) ,0,_winreg.KEY_WRITE)
            
            for kname in IE_SET:
                _winreg.SetValueEx(key,kname,0,_winreg.REG_DWORD,0)
        
            
            _winreg.CloseKey(key)
    
            index = index + 1
        except WindowsError:
            print r'Message: No Ndi\Interfaces Key'
    
    #add key
    key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"Software",0,_winreg.KEY_WRITE)
    keynew = _winreg.CreateKey(key,u'VideoLAN' + os.path.sep + u'VLC')
    _winreg.SetValueEx(keynew,"InstallDir",0,_winreg.REG_SZ,pathS.replace('\\', '\\\\'))
    _winreg.CloseKey(keynew)
    _winreg.CloseKey(key)
    return

你可能感兴趣的:(python修改注册表,支持ocx控件)