Solved

Registry: Invalid DWORD value

Posted on 1997-08-19
2
1,661 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA Import all database objects 12 55
Is AWS.RDS considered a part of "Big Data"? 4 114
VS2015 Redefinition errors 4 67
How can my static class become undefined?? 8 62
This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

789 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