System statements in C

Newbie Member
18Jul2008,12:39   #1
Virtualz's Avatar
Hi.

I need help with some coding in C

I want to extract some registry info from HKCU (Current user) named "Volatile Environment"

Here's how to do it:

c:\>reg save "hkcu\volatile environment" <filename>

This is to extract the info.

Now the problem.....

/code

#include<stdio.h>

main()
{
system("reg save "hkcu\volatile environment" <filename>");
}


It does not want to accept the above as valid code in Dev-cpp.

Anyone know how to do this?

Thanx
Mentor
18Jul2008,16:48   #2
xpi0t0s's Avatar
Can't see any reason why that shouldn't work, if the command is exactly the same as the command line version. Don't forget that if you try to include a " inside a string that will actually terminate the string, so if the code is exactly as pasted I bet you're getting errors about some unknown symbol hkcu. \ is the escape character so \" will get you an embedded quote in a string, and of course the backslash in \v will need escaping as well.
Newbie Member
18Jul2008,16:55   #3
Virtualz's Avatar
Thanx mate, I got it right!!