0
votes

In c#, I tried to read the values of short date format from the Windows registry in HKEY_CURRENT_USER but instead I get the values from HKEY_USERS.

I used the following codes to read the subkeys of HKEY_CURRENT_USER

    RegistryKey RegKey = Registry.CurrentUser.OpenSubKey(@"Control Panel\International\");
    var DateFormat = RegKey.GetValue("sShortDate");

How do I get the HKEY_CURRENT_USER subkey values?

1
This needs clarification. What values did you get, and what values did you expect to get? What makes you think there is a problem?Harry Johnston
I changed the date format to dd-MM-yyyy and it can be seen in HKEY_CURRENT_USER but in HKEY_USERS, the date format still in dd/MM/yyyy. I need to get this format dd-MM-yyyy by using the above code. Is there any other way to get it?BhaRathi RajaMani
There is no such key as HKEY_USERS\Control Panel, what is the actual path to the key that contains the old dd/MM/yyyy value?Harry Johnston

1 Answers

0
votes

You're getting the correct values.

HKEY_CURRENT_USER is just an alias for HKEY_USERS\<sid_of_current_user>, where changes depending on who is logged in. So any time you get a key

HKCU\key\subkey\value

Windows internally rewrites it to be

HKEY_USERS\<sid_of_current_user>\key\subkey\value

The HKEY_CURRENT_USER registry hive is just a convenient shortcut provided by Windows, because it's so useful to get the keys for the currently logged in user.