EXEC在MFC中怎么用?作用是什么?

解决方案 »

  1.   

    我是想在windows下执行这样的一个命令,调用exec不可以吗?命令是个这个,如下:ebook-convert t.txt t.epub --no-default-epub-cover --base-font-size=10 -v --authors=wabob --comments="just a test" 难道ShellExecute是干这个事情的吗?谢谢。
      

  2.   

    lz是想在MFC中start 外部的exe程序???用CreateProcess()来启动进程,ShellExecute()太老了,就别用了吧
      

  3.   

    是的呀,楼上。
    呵呵用CreateProcess这个函数的话,执行我的那个命令可以吗? 这个函数的后面那些参数,也就是放置我的那些参数了吧? 呵呵。。
      

  4.   

    WinExec/ShellExecute/CreateProcess都可以..
      

  5.   

    真的都可以吗?能不能把代码写出来? 很期望知道代码。谢谢。用createprocess函数就行。
      

  6.   

    WinExec("ebook-convert t.txt t.epub --no-default-epub-cover --base-font-size=10 -v --authors=wabob --comments=\"just a test\"");
      

  7.   

    #include <windows.h>
    #include <stdio.h>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). 
            TEXT("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.
        ) 
        {
            printf( "CreateProcess failed (%d).\n", GetLastError() );
            return;
        }    // Wait until child process exits.
        WaitForSingleObject( pi.hProcess, INFINITE );    // Close process and thread handles. 
        CloseHandle( pi.hProcess );
        CloseHandle( pi.hThread );
    }
    code from msdn