Microsoft.Win32.RegistryKey.SetValue() and large values
On Friday my intern ran into the problem setting a registry DWORD to a large value - a value larger than 2,147,483,647. The value gets set as a string and not a DWORD even though the DWORD should have UINT's range from 0 to 4,294,967,295. This is the same problem mentioned by Alexandr Khilov in his article on the The Code Project. We have a workaround, but I am curious to know if anyone else has run into this.
Comments
- Anonymous
January 20, 2004
I ran into this one and need to develop a fix (I have to be able to write values up to UInt32.MaxValue). What kind of workaround did you use? - Anonymous
March 03, 2004
I am looking for a fix for this too. You state a work around, but decline to TYPE IT IN. How bout TYPING IT IN? - Anonymous
March 04, 2004
The workaround is to use an UInt32 and then before calling SetValue, cast it to Int32.
RegistryKey key = Registry.CurrentUser.CreateSubKey("Test");
RegistryKey subKey = key.CreateSubKey("SubKey");
System.UInt32 ui = 3147483657;
subKey.SetValue("It's a DWORD", (Int32)ui);
Here's the KB article about this:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;317873
Hope this helps.
- T -