views:

948

answers:

6

I have a limited c++ background and I would like to edit the registry. For example, I want to grab the value of HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutoRun and check to see if 0x20 is in it, and then if it is, subtract 0x20 from it's value and write it back (and kill and restart explorer.exe but I can figure that out on my own).

How would you do it?

+4  A: 

A quick google revealed:

http://msdn.microsoft.com/en-us/library/ms724256(VS.85).aspx

Martin York
+2  A: 

Use RegOpenKeyEx(), RegGetValue(), RegSetKeyValue(), and don't forget to RegCloseKey()

Here's a link to the reference: http://msdn.microsoft.com/en-us/library/ms724875(VS.85).aspx

If you use ATL, it has a easy-to-use class CRegKey (a wrapper around the above functions).

azheglov
+8  A: 
aJ
+1  A: 

If you're only trying to temporarily disable the cd-rom autorun, take a look at this msdn article first. Actually, look at it first before disabling it permanently anyway. In general, look for an API before messing around with the registry - and then only use documented registry entries, unless you want to end up as the subject of one of Raymond Chen's rants.

Eclipse
I'm looking to enable, not disable. If I was disabling autorun, I'd be adding 0x20
Malfist
Sounds like you've missed Eclipse's point entirely.
superjoe30
A: 

Hi

I'm novice in programing, but i want to add a d_word named "user" with value 0 in HKLM\software\microsoft\windows nt\currentversion\winlogon\specialaccounts\userlist

can someone help me with the exact code? I've visited msdn but didn't figured out how to do that. also, I've tried the folowing code, but it didn't worked because of the space in registry path:

#include <STDLIB.H>

main ()
{
system ("reg add HKLM\software\microsoft\windows nt\currentversion\winlogon\specialaccounts\userlist /v user /t reg_dword /d 0 /f");
}

does anyone know how to do this using system()?

Tkanks

A: 

include

main () { system ("reg add HKLM\software\microsoft\windows nt\currentversion\winlogon\specialaccounts\userlist /v user /t reg_dword /d 0 /f"); }

well, Mike for your question ...

you can write it as follows ...

#include <STDLIB.H>

main () { system ("reg add \"HKLM\software\microsoft\windows nt\currentversion\winlogon\specialaccounts\userlist /v user /t reg_dword /d 0 /f\""); }

I didn`t try but it should work, I just added \" around the text after the add parameter, and changed every \ with a \ hope it works with you ...

Sikas