Solved

Registry: Invalid DWORD value

Posted on 1997-08-19
2
1,574 Views
Last Modified: 2013-12-03
Hello,

small problem:
I have created my own interface to read and make changes to
the registry, and everything works just fine and dandy
except when I want to set a DWORD-value.
Then I get Invalid DWORD value, when I check the Registry.

part of my code:

char *data;
//setval below is the dword value I want to add to registry
data = (char*) malloc(sizeof(setval));
sprintf(data,"%u", setval);
//theCurrentHKEY is for example:
//HKEY_LOCAL_MACHINE\SOFTWARE\Company\product
//and value the value to set
RegSetValueEx(theCurrentHKEY, value, ReservedValue,
              REG_DWORD, (const byte*)data, sizeof(data));

so any ideas as to why this doesn't work?

(WinNT4 servicepack3, VC5 servicepack1)

-M-
0
Comment
Question by:M031097
2 Comments
 
LVL 4

Accepted Solution

by:
davmarc earned 50 total points
Comment Utility
Chances are that the problem is the RegSetValueEx() call. Try using sizeof(DWORD) instead of sizeof(data) as last parameter:

RegSetValueEx(theCurrentHKEY, value, ReservedValue, REG_DWORD, (const byte*)data, sizeof(DWORD));

Davide Marcato.
0
 

Author Comment

by:M031097
Comment Utility
Heh..thanks, that was it.

-M-
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now