C# DWORD and QWORD - signed and unsigned madness
问题 I've noticed that DWord and QWord values when written to the Registry supposed to be Signed Integers, not Unsigned. This code will throw an exception if value is UInt64 or UInt32: registryKey.SetValue(name, value); According to MSDN DWORD is a 32-bit unsigned integer (range: 0 through 4294967295 decimal) https://msdn.microsoft.com/en-us/library/cc230318.aspx So, to write new DWORD value to the Registry I need to cast it to signed integer like so: UInt32 unsignedValue = (UInt32)someValue;