Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 C#3.0 C++ C#
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 23-Dec-11 10:27am
Comments
Chuck O'Toole at 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
good
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[^].
 
—SA
  Permalink  
Comments
Chuck O'Toole at 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 at 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 at 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 at 23-Dec-11 17:05pm
   
Haha, Google Translate even changed the "fr-FR" to "en-US" in the code part. Good one :)
SAKryukov at 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
SAKryukov at 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.
 
--SA
hemigueti at 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
good
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.
  Permalink  
v2
Rate this: bad
good
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 Smile | :)
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
  Permalink  
v3

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 510
1 CPallini 330
2 OriginalGriff 225
3 George Jonsson 120
4 ChauhanAjay 104
0 OriginalGriff 6,474
1 Sergey Alexandrovich Kryukov 6,190
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 17 Sep 2012
Copyright © CodeProject, 1999-2014
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