Unable to write DWords to registry

Dec 16, 2009 at 7:52 PM
Edited Dec 16, 2009 at 7:53 PM


Awesome wrapper, love it!

Except I am unable to write DWord values to the registry using

SetValue("0000101a", 1, Microsoft.Win32.RegistryValueKind.DWord);


I get the error message, "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

I tried messing around with the DLL code a bit, but I haven't been able to figure it out. Any idea? Writing strings works fine. Thanks so much!

Dec 17, 2009 at 5:02 AM

Thanks for finding a significant bug. In fact, SetValue and GetValue for DWORD, QWORD, and String were broken. I will be posting the fix shortly.

Dec 17, 2009 at 1:59 PM

Writing to String was working just fine, now it is broken.


Thank you for such a quick response!

Dec 17, 2009 at 2:29 PM

To be more clear... when I write a string, it just shows up as a bunch of square characters in the registry.

Dec 18, 2009 at 5:35 PM

Two questions: 1) Is DWORD working now? 2) Are you running the code from a 32 or 64 bit system?

Dec 18, 2009 at 6:05 PM

1) Yes

2) 32-bit

Dec 18, 2009 at 6:13 PM

I tried using RAPI2.DLL version 1.1 and the string writing does not work in that, either. I am guessing it might have to do with unicode conversion?

Dec 18, 2009 at 6:33 PM

I figured it out. I was reading and writing in ANSI, not Unicode. All is corrected now. Added bonus is that handling multi-strings is now much simpler. Thanks for the catch.