将
C:\Documents and Settings\ADMINI~1~XUX\LOCALS~1\Temp\Setup.exe
替换成
C:\\Documents and Settings\\ADMINI~1~XUX\\LOCALS~1\\Temp\\Setup.exe并用WinExec()执行,winExec()中怎么书写多谢!
C:\Documents and Settings\ADMINI~1~XUX\LOCALS~1\Temp\Setup.exe
替换成
C:\\Documents and Settings\\ADMINI~1~XUX\\LOCALS~1\\Temp\\Setup.exe并用WinExec()执行,winExec()中怎么书写多谢!
'\\'仅仅是给编译器看的,其他时候'\'就是'\'。
WinExec("C:\\Documents and Settings\\ADMINI~1~XUX\\LOCALS~1\\Temp\\Setup.exe
", WS_HIDE)
例子:
CString strHelpFile="hh.exe "+CYJ::strYJFolder+"\\网络组版说明书.chm";
WinExec(strHelpFile,SW_SHOW);
CString strFile="C:\\Documents and Settings\\ADMINI~1~XUX\\LOCALS~1\\Temp\\Setup.exe"
ShellExecute(NULL,"open",strFile,NULL,NULL,SW_SHOW);
所有的'\'都被忽略,那替换根本就无从谈起.
GetModuleFileName(NULL,exeFullPath,MAX_PATH);//获得本程序所在的目录及程序名
char temp[MAX_PATH];
int n=0,i=0;
while(1)
{
if(exeFullPath[i]!=92)
temp[n]=exeFullPath[i];
else
{
temp[n]=92;
temp[n+1]=92;
++n;
}
i++;
n++;
if(exeFullPath[i]=='\n')
break;
if(i>=MAX_PATH)
break;
}
AfxMessageBox(temp);
", SW_SHOW);
", SW_SHOW);\\ 相当于转义字符,某些特殊进行字符串赋值的时候都需要.此相当于一个看看\t,\n,你应该会更明白.具体还有些其它转义字符,你可以查查相关资料.