问题
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