Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   System statements in C (http://www.go4expert.com/forums/statements-c-t12218/)

Virtualz 18Jul2008 12:39

System statements in C
 
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

xpi0t0s 18Jul2008 16:48

Re: System statements in C
 
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.

Virtualz 18Jul2008 16:55

Re: System statements in C
 
Thanx mate, I got it right!!


All times are GMT +5.5. The time now is 12:43.