C# Registry.GetValue cannot get the correct value
In my code, I need to get the time zone of Venezuela from Reg开发者_如何学Cistry. What I want is the Index value under the key "Venezuela Standard Time". I use the following code to do that, but seems it do not work correctly. The number returned is "-2147483573", but the correct number is "2147483723". could anyone help to figure out what is wrong.
The value 0x8000004B is larger than an integer. You need to treat it as an unsigned integer.
So:
var t = subKey.GetValue("Index");
uint ut = (uint)t;
And then take ut.ToString()
.
Updated example:
int t = -2147483573; // Simulates your call to subKey.GetValue
uint ut = (uint)t;
string s = ut.ToString();
Console.WriteLine(s);
The output is 2147483723.
精彩评论