Click here to Skip to main content
15,860,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I would to know if it's possible to change the regional settings for the localsystem account like the current user for a normal connection with windows by code (c#/c++)?

My goal is to change the culture information like a normal user account.

I have succeed that step manualy from the windows settings (apply all settings from the current user and to the default user).

Thanks,
Posted
Comments
Chuck O'Toole 23-Dec-11 16:42pm    
Just curious, how would you like it if every time you ran my application, I set your PC's settings to US-English, Eastern Time Zone, US $ currency?

I don't think this is a decent task for an application. You see, the user knows better what culture she or he would prefer to stick with. The system is designed to provide a user some means to do that, what else would one need. The user herself/himself or a system administrator should change such system settings, nobody else.

Would you rather consider changing the culture just for your application? If would be totally transparent and independent from the current system settings.
C#
// culture of French, France:
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("fr-FR");
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
System.Threading.Thread.CurrentThread.CurrentUiCulture = culture;


During run rime, you can take the required culture from your application configuration file, provide some UI for selection of the culture by the user, or something like that. That would be much more appropriate.

See also my recent answer to a similar question: Question about convert number format[^].

—SA
 
Share this answer
 
Comments
Chuck O'Toole 23-Dec-11 16:40pm    
Absolutely agree. The application does not "own" the PC it runs on and it is quite arrogant to think that the application can and should change things like the global culture, language, number format, etc.
hemigueti 23-Dec-11 16:55pm    
j'ai déjà pensé à cette solution mais le problème est que j'ai une application qui lance un programme et ce programme lance un programme via un service (service windows).
Le pogramme lancé par ce service windows (compte system) a une culture différente de celui de l'utilisateur normal et il n'est pas possible de changer la culture simplement en faisant "System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("fr-FR");
System.Threading.Thread.CurrentThread.CurrentCulture = culture;"
You know what i want to do?
Chuck O'Toole 23-Dec-11 17:02pm    
Thank God for Google Translate:

I've thought about this solution but the problem is that I have an application that runs a program and this program is launching a program through a service (windows service).
The pogramme launched by the service windows (system account) has a different culture from that of the normal user and it is not possible to change the culture simply by "System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo ("en-US");
System.Threading.Thread.CurrentThread.CurrentCulture = culture; "
You know what i want to do?.
Chuck O'Toole 23-Dec-11 17:05pm    
Haha, Google Translate even changed the "fr-FR" to "en-US" in the code part. Good one :)
Sergey Alexandrovich Kryukov 23-Dec-11 17:08pm    
Really!!! Wow! I did not notice. I used it too in my reply.
I agree with you. Thank you for your notes and the vote.
--SA
The settings lie in
HTML
HKEY_USERS\.DEFAULT\Control Panel\International

You can use registry apis to modify them.
 
Share this answer
 
v2
I had a similar question pertaining to an IIS hosted website, not a distributable application.
Check out this article from Microsoft on how to Apply regional and language settings to reserved accounts, and you don't need to change a single line of code :-)
This worked for me on a Windows Server 2008 R2 Standard server, steps in the article describes the settings window you should see a bit differently to what it actually looks like in Win 2008 R2 Standard...

http://windows.microsoft.com/en-XM/windows-vista/Apply-regional-and-language-settings-to-reserved-accounts
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900