Click here to Skip to main content
13,088,711 members (55,861 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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).

Posted 23-Dec-11 10:27am
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?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
// 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[^].

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 :)
SAKryukov 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.
SAKryukov 23-Dec-11 17:07pm
This is not what I know, this is what you should "want". You don't want to "want" something which makes no sense. There is not difference how your process is started, from a windows service or not; and the culture of your child process has nothing to do with the culture of the parent one, service or not. In all cases, you can always pass required culture as a parameter.

By the way, starting any process by a Windows Service is a really bad thing. You rather need to develop some plug-in mechanism and run it in-process. If you have a source code of the application you launch, this is not a problem, if not -- this is not a solution anyway.

hemigueti 23-Dec-11 18:43pm
it's a distributed application and i can't do another for the moment.
But i'm agree with to develop an another mechanism.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

The settings lie in
HKEY_USERS\.DEFAULT\Control Panel\International

You can use registry apis to modify them.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

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...

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 17 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100