Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Registry: Invalid DWORD value

Posted on 1997-08-19
2
Medium Priority
?
1,921 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 200 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

916 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