System statements in C

Virtualz's Avatar
Newbie Member
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
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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.
0
Virtualz's Avatar
Newbie Member
Thanx mate, I got it right!!