开发者

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.

C# Registry.GetValue cannot get the correct value

C# Registry.GetValue cannot get the correct value


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜