Is it possible to set the language or locale of a Windows program at runtime?

穿精又带淫゛_ 提交于 2020-06-25 10:45:12

问题


We have some existing software (C++ Windows applications) that have had their resources translated into a number of languages for various customers. The application picks up the locale from the Windows locale and runs in the appropriate language.

Following a recent order, we translated the resources into German, however we have just found out that the customers are installing Windows in English, but want our software to still run in German. Apparently the rest of the software running on the PC has not been globalized and is only German.

Is there any way in Windows that we can override the locale so that the software believes it is running on a German install of Windows? We do not now have time to make changes to the software to override the locale, and would be reluctant to fork the application for this one customer anyway.

Any suggestions?


回答1:


I don't know of any straightforward way that does not involve changing your program, but I can offer a workaround:

On the machines where your app is running, create another user, and set that user's locale to German. Then, have your program run with that user's credentials (using runas or psexec). The program will then run with the German locale, while the user will keep working on an English environment. This is going to be annoying, though, if the user tries to save or open files - the desktop and documents folder are going to be those of the German user rather than the English one.




回答2:


Yes you can use the win32 call SetThreadLocale from WinMain or whatever the entry point of your application is. Any child threads will inherit the parent locale. Details here:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd374051%28v=vs.85%29.aspx



来源:https://stackoverflow.com/questions/7770325/is-it-possible-to-set-the-language-or-locale-of-a-windows-program-at-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!