From: PromisedOyster on 4 Jan 2010 20:30 I need to add/update a registry value with a dword that is greater than System.Int32.MaxValue. The value is 0x80000024 and is used for setting the BrowserFlags value for software\\classes\\BrowserFlags. I can go into the registry editor and set it that way, but NOT using the .NET framework: Here is my sample code: RegistryKey rk = Registry.LocalMachine.OpenSubKey("software\\classes\ \BrowserFlags", true); rk.SetValue(key, System.Int32.MaxValue, RegistryValueKind.DWord); // works rk.SetValue(key, 0x80000024, RegistryValueKind.DWord); // gives an error Any advice on how to achieve this? (This value still fits into 32 bits, it is just that it is a uint not an int).
From: Peter Duniho on 4 Jan 2010 21:08 PromisedOyster wrote: > [...] > rk.SetValue(key, 0x80000024, RegistryValueKind.DWord); // gives an > error It would have be better for you to include the exact error and text in your post. > Any advice on how to achieve this? > > (This value still fits into 32 bits, it is just that it is a uint not > an int). Huh. Bizarre. Given that the argument is "Object", I would've thought a boxed uint would've worked fine, since the method has to convert the type somehow, and you're providing DWORD as the value type. That said, you can get it to work fine just by casting to an int: rk.SetValue(key, unchecked((int)0x80000024), RegistryValueKind.DWord); Or, of course, by providing a signed int value that is equivalent: rk.SetValue(key, -2147483612, RegistryValueKind.DWord); (decimal because hex literals are always unsigned). By the way, your variable name is messed up. You're using "key" to describe a value that holds the name of a registry _value_, not a key. That's going to confuse someone some day, and it might be you! :) Pete
From: Patrice on 5 Jan 2010 05:21 Hi, Here BrowserFlags seems to be a value name under another key such as Aplication.Manifest. Are you sure the registry lcoation is correct ? As Peter said it's best to always provide the exact error message you have as even on a single line of code, there are multiple possible causes (for now I have an error with your code but IMO this is not the one you have and it could be caused by a typo in your code, having the exact error message would allow to make sure if I reproduced the same error)... -- Patrice "PromisedOyster" <PromisedOyster(a)hotmail.com> a �crit dans le message de news:004a3822-e43b-46f7-9f8a-71b46d753e74(a)u7g2000yqm.googlegroups.com... >I need to add/update a registry value with a dword that is greater > than System.Int32.MaxValue. The value is 0x80000024 and is used for > setting the BrowserFlags value for software\\classes\\BrowserFlags. > > I can go into the registry editor and set it that way, but NOT using > the .NET framework: > > Here is my sample code: > > RegistryKey rk = Registry.LocalMachine.OpenSubKey("software\\classes\ > \BrowserFlags", true); > rk.SetValue(key, System.Int32.MaxValue, RegistryValueKind.DWord); // > works > rk.SetValue(key, 0x80000024, RegistryValueKind.DWord); // gives an > error > > Any advice on how to achieve this? > > (This value still fits into 32 bits, it is just that it is a uint not > an int). >
|
Pages: 1 Prev: Rules engine, pipeline or what? Next: UI Automation with MSAA |