I want to get the the state
key value from below address in hex
RegistryKey winTrust = Registry.CurrentUser.OpenSubKey(
@"Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust Providers\Software Publishing", true);
Then compare it with 23c00
value, and if it's not the same, set it to 23c00
string currentKey = winTrust.GetValue("State").ToString();
if (!currentKey.Equals("23c00"))
{
winTrust.SetValue("State", "23c00", RegistryValueKind.DWord);
winTrust.Close();
}
It's not working as it gets and compare the decimal value.
How can I do it?
I found my solution.
// Convert value as a hex in a string variable
string currentKey = Convert.ToInt32(winTrust.GetValue("State").ToString()).ToString("x");
if (!currentKey.Equals("23c00"))
{
winTrust.SetValue("State", 0x00023c00, RegistryValueKind.DWord);
winTrust.Close();
}