Solved

How to modify value data of registry using API

Posted on 1997-07-08
9
343 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
  • 4
  • 4
9 Comments
 
LVL 7

Accepted Solution

by:
faster earned 20 total points
Comment Utility
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
Comment Utility
<No Name> is your problem.  It's either a key or a value, not in between.

0
 

Author Comment

by:talee
Comment Utility
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
 
LVL 7

Expert Comment

by:faster
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:talee
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

11 Experts available now in Live!

Get 1:1 Help Now