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

x
?
Solved

How to modify value data of registry using API

Posted on 1997-07-08
9
Medium Priority
?
353 Views
Last Modified: 2013-12-03
Hi, can anyone tell me how to use the API
 ( RegSetValueEx) to change the registry value data?

I had tried using RegSetValueEx to change the value data.  The result is that a new value is added with my data instead of changing the value that I've specified.  

Example:  Default
<No Name>:REG_NONE <data>

After my function,
<No Name>:REG_NONE <data>
<No Name>:REG_NONE <my data>

My question is, how do I change the above data without adding a new value?  The subkeys and value name I type in should be correct.  Below is the full path to the value I want to change.

HKEY_LOCAL_MACHINE\\SECURITY\\Policy\\
PolAdtEv\\<No Name>

Any sugestion/advice?
Thanks!
0
Comment
Question by:talee
[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
  • 4
  • 4
9 Comments
 
LVL 7

Accepted Solution

by:
faster earned 80 total points
ID: 1400324
Any value is associated with a name.  As long as you specify an existing name correctly in the API, the value will be replaced.

If you still have no success, show me your code.
0
 
LVL 3

Expert Comment

by:vinniew
ID: 1400325
<No Name> is your problem.  It's either a key or a value, not in between.

0
 

Author Comment

by:talee
ID: 1400326
What I'm trying to say is that the value I see using the regedt32 is <No Name>.  Not like value names such as "LegalNoticeText", but only "<No Name>" and inside this value actually contains the data I want to change.

Thanks!
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 7

Expert Comment

by:faster
ID: 1400327
Every key can have a default value which requires no name.  On my machine, it will appear as "default", maybe that is equivalent to "no name".

Again, if you have any problem, you'd better show your code calling the registry API, then we will know what's exactly your problem.
0
 

Author Comment

by:talee
ID: 1400328
int array1[9]= {0x00142101,0x00000000,0x00000002,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000007};

HKEY hKeyPolAdtEv;

RegOpenkeyEx( HKEY_LOCAL_MACHINE,
"SECURITY\\Policy\\PolAdtEv", 0, KEY_ALL_ACCESS
&hKeyPolAdtEv);

RegSetValueEx(hKeyPolAdtEv,"<No Name>", 0 , REG_NONE, (byte * ) array1,sizeof(array1));

RegCloseKey( hKeyPolAdtEv);
0
 
LVL 7

Expert Comment

by:faster
ID: 1400329
The code itself is correct, provided that the key "HKEY_LOCAL_MACHINE\\SECURITY\\Policy\\PolAdtEv" already exist.

However it is very uncommon to use "<No Name>" as the NAME of a value, although it is possible.  I don't know why you choose this name.  But anyway, using your code will set this value, and if you change the array value and execute it again, the value is modified.  So I don't know where's your problem.  If the previous value already exist and can't be overwritten, that is strange, but are you sure the name is "<No Name>"?  Maybe it only appears to be so (e.g. it has some trailing space that you did not notice).
0
 

Author Comment

by:talee
ID: 1400330
FYI, the subkeys & value already exist on my system by default.

The <No Name> is the value that I see in the registry.  It's not created by me.  It's created by default.  This value contains the data that I want to set.  I'm using NT workstation 4.00.  If we are using the same version and running on normal PC, your registry should also show the same value under the subkeys that I had specified before....which is <No Name>.  Maybe your "default" is the same as my "<No Name>".  

Currently, I've been trying to change the data of this value, but unsuccessful.  Results in creating another value which is the same name as previous ("<No Name>").  

I've also tried putting different spaces in the value.  But it still creates another value.  Doesn't change the data  I want in that value.
0
 
LVL 7

Expert Comment

by:faster
ID: 1400331
Use NULL instead of "<No Name>" in the following API.

RegSetValueEx(hKeyPolAdtEv,"<No Name>", 0 , REG_NONE, (byte * ) array1,sizeof(array1));
0
 

Author Comment

by:talee
ID: 1400332
I  also found out that <No Name> means no need to enter any value or NULL in this morning and finally get my program to work,Thanks a lot for your help and your answer.

regards.  
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

715 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