Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Registry: Invalid DWORD value

Posted on 1997-08-19
2
Medium Priority
?
1,854 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
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…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

730 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