如果知道用winexec()创建的进程何时结束。
具体如下:
WinExec("cmd /c dir *.txt>a.txt",SW_HIDE);
如果知道何时a.txt创建结束。
如果不能够知道,用其它方法是否可以实现。
请给个小例子,高分。

解决方案 »

  1.   

    或如何判断a.txt已经成功创建完毕。谢谢
      

  2.   

    最好不要用winexec,这是不推荐使用的东东。
    可以用CreateProcess,如下:
    STARTUPINFO si;    
    PROCESS_INFORMATION pi;    
    ZeroMemory( &si, sizeof(si) );
        si.cb = sizeof(si);    // Start the child process. 
        if( !CreateProcess( NULL, // No module name (use command line). 
            "traszip.exe", // 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.    
     
        {        
    AfxMessageBox("CreateProcess failed." );    
    return;
    }
        // Wait until child process exits.
        WaitForSingleObject( pi.hProcess, INFINITE );