Solved

Registry: Invalid DWORD value

Posted on 1997-08-19
2
1,601 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
ID: 1404417
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
ID: 1404418
Heh..thanks, that was it.

-M-
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

929 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