hi friends,
How will the path inside the '\' before again add.
thanks.
Codes:
#include
void main(int argc,char *argv[])
{
char *appPath=argv[0]; /*How will the path inside the '\' before again add '\' */
HKEY hKey;
RegCreateKeyEx(
HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Windows\\CurrentVersion\\Run ",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hKey,
0);
RegSetValueExA(
hKey,
"this demo",
0,
REG_SZ,
(CONST BYTE*) appPath,
50);
RegCloseKey(hKey);
}
How will the path inside the '\' before again add.

thanks.
Codes:
#include
void main(int argc,char *argv[])
{
char *appPath=argv[0]; /*How will the path inside the '\' before again add '\' */
HKEY hKey;
RegCreateKeyEx(
HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Windows\\CurrentVersion\\Run ",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hKey,
0);
RegSetValueExA(
hKey,
"this demo",
0,
REG_SZ,
(CONST BYTE*) appPath,
50);
RegCloseKey(hKey);
}


VulpesRank #55 · 29.2K reputationPosted Aug 8, 2012, 12:47 AM EDT
You only need to do this when you're including the path in a string literal because otherwise the C compiler would conclude that the backslash was beginning an escape sequence such as \n, \t etc.
Notice though that if a command line argument includes embedded spaces, then you should enclose the whole argument in double quotes.
Ken HRank #2,315 · 610 reputationPosted Aug 8, 2012, 7:19 PM EDT