在Windows 7上以编程方式启用输入语言

时间:2012-07-29 18:51:12

标签: windows-7 input-language

我正在为依赖于启用西班牙语输入语言的应用程序编写Windows安装程序,这在Windows 7上不是默认语言。有没有办法可以编程方式检测运行Win 7的主机上是否启用了西班牙语输入语言并启用它,如果它不是?

2 个答案:

答案 0 :(得分:0)

您可以通过Windows注册表阅读默认设置或将其设置为默认语言,以下是密钥和语言代码的链接:http://www.windowsitpro.com/article/configuration/where-in-the-registry-is-the-language-setting-for-each-user-stored-

例如,如果您希望使用python来设置注册表,这是一个示例:

            from _winreg import *

            print r"*** Reading from SOFTWARE\Microsoft\Windows\CurrentVersion\Run ***"
            aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)

            aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run") 
            for i in range(1024):                                           
                try:
                    n,v,t = EnumValue(aKey,i)
                    print i, n, v, t
                except EnvironmentError:                                               
                    print "You have",i," tasks starting at logon..."
                    break          
            CloseKey(aKey)                                                  

            print r"*** Writing to SOFTWARE\Microsoft\Windows\CurrentVersion\Run ***"
            aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE)
            try:   
               SetValueEx(aKey,"MyNewKey",0, REG_SZ, r"c:\winnt\explorer.exe") 
            except EnvironmentError:                                          
                print "Encountered problems writing into the Registry..."
            CloseKey(aKey)

            CloseKey(aReg)    

答案 1 :(得分:0)