Solved

How to modify value data of registry using API

Posted on 1997-07-08
9
346 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
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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error email attachment VB2010 5 39
MSDN Subscription - Azure and NFP's 3 71
Is COM supported from Apache 1 55
VIDEO DATASOURCE Control Resize issue 2 20
This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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