我正在为一个应用程序编写一个windows安装程序,该应用程序依赖于启用的西班牙语输入语言,而西班牙语输入语言在Windows7上不是默认的。有没有一种方法可以用程序检测运行Win 7的主机上是否启用了西班牙语输入语言,如果没有,则启用它?
您可以通过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 SOFTWAREMicrosoftWindowsCurrentVersionRun ***"
aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
aKey = OpenKey(aReg, r"SOFTWAREMicrosoftWindowsCurrentVersionRun")
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 SOFTWAREMicrosoftWindowsCurrentVersionRun ***"
aKey = OpenKey(aReg, r"SOFTWAREMicrosoftWindowsCurrentVersionRun", 0, KEY_WRITE)
try:
SetValueEx(aKey,"MyNewKey",0, REG_SZ, r"c:winntexplorer.exe")
except EnvironmentError:
print "Encountered problems writing into the Registry..."
CloseKey(aKey)
CloseKey(aReg)
此资源可能会帮助您:
http://msdn.microsoft.com/en-us/library/system.windows.forms.inputlanguage(v=vs.71).aspx