代码如下:
       PROCESS_INFORMATION piProcInfo; 
STARTUPINFO siStartInfo; CreateProcess(
NULL,
"c:\\program files\\tencent\\qq\\coralqq.exe",
NULL, // process security attributes
NULL, // primary thread security attributes
NORMAL_PRIORITY_CLASS, // handles are inherited
0, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&piProcInfo); // receives PROCESS_INFORMATION应该没有问题啊?
另外我用
        ShellExecute(NULL,  NULL,
"c:\\program files\\tencent\\qq\\coralqq.exe",
NULL,  NULL,  SW_SHOW); 
却可以成功!
但是     将"c:\\program files\\tencent\\qq\\coralqq.exe"
换成"c:\program files\tencent\qq\\coralqq.exe"就不行了?
这是为什么呢??

解决方案 »

  1.   

    你应该这样写
    CreateProcess(
    NULL,
    "\"c:\\program files\\tencent\\qq\\coralqq.exe\",
    NULL, // process security attributes
    NULL, // primary thread security attributes
    NORMAL_PRIORITY_CLASS, // handles are inherited
    0, // creation flags
    NULL, // use parent's environment
    NULL, // use parent's current directory
    &siStartInfo, // STARTUPINFO pointer
    &piProcInfo); // receives PROCESS_INFORMATION
      

  2.   

    如Leanderhe(家俊) 所说,的确要用转义符哈,不然编译器会乱翻译的,呵呵
      

  3.   

    我也遇到了两样的问题呀,各位高手,我这么做还是没有反应呀。
    PROCESS_INFORMATION  piProcInfo; 
    STARTUPINFO   siStartInfo;CreateProcess(
    NULL,
    "\"c:\\program files\\tencent\\qq\\coralqq.exe\",
    NULL, // process security attributes
    NULL, // primary thread security attributes
    NORMAL_PRIORITY_CLASS, // handles are inherited
    0, // creation flags
    NULL, // use parent's environment
    NULL, // use parent's current directory
    &siStartInfo, // STARTUPINFO pointer
    &piProcInfo); // receives PROCESS_INFORMATION
    请高手们再指点一下,最好能给个例子呀,谢谢!!!
      

  4.   

    我的EMAIL是[email protected],谢谢了!!!
      

  5.   

    晕哦,查查msdn不就知道了吗void main( VOID )
    {
        STARTUPINFO si;
        PROCESS_INFORMATION pi;    ZeroMemory( &si, sizeof(si) );
        si.cb = sizeof(si);
        ZeroMemory( &pi, sizeof(pi) );    // Start the child process. 
        if( !CreateProcess( NULL, // No module name (use command line). 
            "MyChildProcess", // Command line. 
            NULL,             // Process handle not inheritable. 
            NULL,             // Thread handle not inheritable. 
            FALSE,            // Set handle inheritance to FALSE. 
            0,                // No creation flags. 
            NULL,             // Use parent's environment block. 
            NULL,             // Use parent's starting directory. 
            &si,              // Pointer to STARTUPINFO structure.
            &pi )             // Pointer to PROCESS_INFORMATION structure.
        ) 
        {
            ErrorExit( "CreateProcess failed." );
        }    // Wait until child process exits.
        WaitForSingleObject( pi.hProcess, INFINITE );    // Close process and thread handles. 
        CloseHandle( pi.hProcess );
        CloseHandle( pi.hThread );
    }
    这是msdn上的例子
    "\"c:\\program files\\tencent\\qq\\coralqq.exe\",这样写是不对的,应该是
    "c:\\program files\\tencent\\qq\\coralqq.exe"
      

  6.   

    不是转意符的问题,你的写法是对的("c:\\program files\\tencent\\qq\\coralqq.exe")
    是该如楼上的所说,加上一句 si.cb = sizeof(si);
    STARTUPINFO.cb是说明结构的大小。
    微软在结构中加这个字段,估计是为了以后扩展着想。
    当改变 startupinfo 的定义时,可以根据这个成员的值判别是哪个版本。
      

  7.   

    sorry "\"c:\\program files\\tencent\\qq\\coralqq.exe\"这种写法是要带参数的时候照 yuantao(cfan)说的那样,这个是MSDN上的例程