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()中怎么书写多谢!

解决方案 »

  1.   

    假如要做Winexec参数,不要替换。
    '\\'仅仅是给编译器看的,其他时候'\'就是'\'。
      

  2.   

    CString.Replace("\\", "\\\\");
    WinExec("C:\\Documents and Settings\\ADMINI~1~XUX\\LOCALS~1\\Temp\\Setup.exe
    ", WS_HIDE)
      

  3.   

    我不知道你这个字符串是在文件中,还是在字符串变量里的。感觉没有替换的必要啊。
    例子:
    CString strHelpFile="hh.exe "+CYJ::strYJFolder+"\\网络组版说明书.chm";
    WinExec(strHelpFile,SW_SHOW);
      

  4.   

    WinExec参数的第一个是命令串。格式是:可执行程序(exe)+空格+执行的文件
      

  5.   

    另用WinExec(),用ShellExecute()吧!
    CString strFile="C:\\Documents and Settings\\ADMINI~1~XUX\\LOCALS~1\\Temp\\Setup.exe"
    ShellExecute(NULL,"open",strFile,NULL,NULL,SW_SHOW);
      

  6.   

    如果说你提供一个字符串为:"C:\Documents and Settings\ADMINI~1~XUX\LOCALS~1\Temp\Setup.exe"那是没有办法的,因为编译器根本就找不到其中含有'\',
    所有的'\'都被忽略,那替换根本就无从谈起.
      

  7.   

    替换的代码倒是很简单,举个例子:   char exeFullPath[MAX_PATH];
        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);
      

  8.   

    WinExec("C:\\Documents and Settings\\ADMINI~1~XUX\\LOCALS~1\\Temp\\Setup.exe
    ", SW_SHOW);
      

  9.   

    WinExec("C:\\Documents and Settings\\ADMINI~1~XUX\\LOCALS~1\\Temp\\Setup.exe
    ", SW_SHOW);\\ 相当于转义字符,某些特殊进行字符串赋值的时候都需要.此相当于一个看看\t,\n,你应该会更明白.具体还有些其它转义字符,你可以查查相关资料.