I am having two accounts in HKEY_USERS in registry entry for the same user.
These are:
HKEY_USERS\S-1-5-21-507921405-1993962763-682003330-1012
HKEY_USERS\S-1-5-21-507921405-1993962763-682003330-1014
The problem comes when I fetch the value for the current user using Registry.CurrentUser.OpenSubKey() method.
It fetches the value from HKEY_USERS\S-1-5-21-507921405-1993962763-682003330-1012 while HKEY_CURRENT_USER is mapped(or in sync) with HKEY_USERS\S-1-5-21-507921405-1993962763-682003330-1014.
So the actual values are not fetched. Can someone please help me out in this context as why two accounts exists in registry for the same user and how i can map(or do sync) for HKEY_CURRENT_USER with
HKEY_USERS\S-1-5-21-507921405-1993962763-682003330-1014.
My code is as follows:
string strKeyIESettings = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges";
string valRange1 = "", valRange2 = "", valRange3 = "", valRange4 = "";
using (Microsoft.Win32.RegistryKey keyIESettings = Registry.CurrentUser.OpenSubKey(strKeyIESettings))
{
foreach (string subkey_name in keyIESettings.GetSubKeyNames())
{
using (RegistryKey subkey = keyIESettings.OpenSubKey(subkey_name))
{
switch (subkey_name)
{
case "Range1" :
if (subkey.GetValue(":Range") != null)
{
valRange1 = subkey.GetValue(":Range").ToString();
}
break;
case "Range2" :
if (subkey.GetValue(":Range") != null)
{
valRange2 = subkey.GetValue(":Range").ToString();
}
break;
case "Range3":
if (subkey.GetValue(":Range") != null)
{
valRange3 = subkey.GetValue(":Range").ToString();
}
break;
case "Range4":
if (subkey.GetValue(":Range") != null)
{
valRange4 = subkey.GetValue(":Range").ToString();
}
break;
default:
break;
}
}
}
}
if (valRange1 == "10.237.24.165" && valRange2 == "10.237.24.166" && valRange3 == "10.237.24.167" && valRange4 == "10.237.24.168")
{
flagIESettings = true;
}
I have to fetch these values as my application pre-requisite.
I have found the solution for the above question. It is as follows:
I am having two accounts in HKEY_USERS in registry entry for the same user because I have installed ASP.NET.
One account is for ASP.NET
and Other one is my current user.
It is always the case when ASP.NET is installed on a user’s machine, there are two accounts for the current user in the registry. And one is mapped with HKCU.
Thanks