Click here to Skip to main content
15,935,728 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all ,
I am trying to change the date format in registry key :
keys HKCU\ControlPnael\\International\shortDate

I have done like this ,but it is not changing is there some thing which i need to do to change it.

Registry.CurrentUser.SetValue(@"Control Panel\International\sShortDate", "dd.MM.yyyy");

Please Excuse me if i am asking a very wierd question
Updated 28-Nov-15 5:31am

1 solution

Start by looking at your code, and executing it in the debugger.
Is there an exception? Are you swallowing it?
It's quite likely that it's throwing an UnauthorizedAccessException because you aren't running in admin mode.

But...why are you doing this? If an application started changing the basic settings on my PC - which doesn't use dd.MM.yyyy format - it would be unistalled post haste, and I'd be looking for my money back. You should not be changing user settings, not even "trivial" ones like the short date format - you can seriously annoy some users, and there is normally no good reason for do so. You certainly shouldn't be do it if all you want is to temporarily change an output format - there are much better ways to do that.
Share this answer
vAS21 28-Nov-15 12:00pm    
Thanks Griff..

Tha abpve code is in try block but i havent encountered any exception to catch it...the debugger just executed the coe ithout any exceptions..

And the purpose is to we have some QTP AtPs where we set the time to german local and test the functionality which is done on a Virtual machine...The script mainly tests this functionality we have migrated to tool which runs using C# code so I need to chnage the registry using C# code
vAS21 29-Nov-15 2:01am    
i have got the solution and the following code worked for me
RegistryKey rkey = Registry.CurrentUser.OpenSubKey(@"Control Panel\International", true);
rkey.SetValue("sShortDate", "dd.MM.yyyy");

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