小工具太多,想做个类似于批量处理数据的批量运行可执行文件(.exe),关键点是:
1 如何让代码去实现执行exe程序,而不是手动去双击该执行程序;
2 如何知道exe已经开始运行及已经运行完成了。

解决方案 »

  1.   

    1:用ShellExecute。
    2:判断进程,查找窗体等等........
      

  2.   

    用ShellExecuteEx(或者用CreateProcess)函数来执行每个exe程序,该函数的参数lpExecInfo成员hProcess表示进程句柄,用函数WaitForSingleObject 等待进程结束,然后再执行下一个exe程序
      

  3.   

    1.winexec,createprocess,system等都可以
    2.ls说的都可以
      

  4.   


            SHELLEXECUTEINFO ShExecInfo = {0}; 
    ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); 
    ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; 
    ShExecInfo.hwnd = NULL; 
    ShExecInfo.lpVerb = NULL; 
    ShExecInfo.lpFile = "E:\\运行程\\check.exe"; 
    ShExecInfo.lpParameters = ""; 
    ShExecInfo.lpDirectory = NULL; 
    ShExecInfo.nShow = SW_SHOW; 
    ShExecInfo.hInstApp = NULL; 
    ShellExecuteEx(&ShExecInfo); 
    WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
    并没使得check.exe正常运行完才结束,而是很快就结束了
      

  5.   

    现在的麻烦是在开始执行ShellExecute的同时exe程序就立马结束了
      

  6.   


    在我机器上测试正常,ShellExecuteEx函数执行正确吗?
      

  7.   

        SHELLEXECUTEINFO ShExecInfo = {0}; 
        ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); 
        ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; 
        ShExecInfo.hwnd = NULL; 
        ShExecInfo.lpVerb = NULL; 
        ShExecInfo.lpFile = "E:\\运行程\\check.exe"; 
        ShExecInfo.lpParameters = ""; 
        ShExecInfo.lpDirectory = NULL; 
        ShExecInfo.nShow = SW_SHOW; 
        ShExecInfo.hInstApp = NULL; 
        ShellExecuteEx(&ShExecInfo); 
        WaitForSingleObject(ShExecInfo.hProcess, INFINITE);代码是可以的,是你的程序很快就结束了,你找个有界面的试试,符合你的需要。
      

  8.   

    控制台也可以
    ShellExecute(NULL, _T("open"), _T("F:\\vc6.0\\全中文-MFC类库详解.chm"), NULL, NULL, SW_SHOWNORMAL);
      

  9.   

    win32下hProcess不能wait,会马上返回。
    一个办法是搞些16位的东西进去。
    如果exe是自己写的就好办了,退出时signal一个命名事件即可。
      

  10.   

    http://support.microsoft.com/kb/125212/EN-US
      

  11.   

    控制台的可以先做一个bat , 再在程序里 system("your.bat");
      

  12.   

    SHELLEXECUTEINFO ShExecInfo = {0};  
      ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);  
      ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;  
      ShExecInfo.hwnd = NULL;  
      ShExecInfo.lpVerb = NULL;  
      ShExecInfo.lpFile = "E:\\运行程\\check.exe";  
      ShExecInfo.lpParameters = "";  
      ShExecInfo.lpDirectory = NULL;  
      ShExecInfo.nShow = SW_SHOW;  
      ShExecInfo.hInstApp = NULL;  
      ShellExecuteEx(&ShExecInfo);  
      WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
      

  13.   

    对执行对话框和文档型的exe都没有问题,就是对付控制台的没效果。使用bat也没效果,出现的描述如下:
    this application has requested the Runtime to terminate it in an unusual way.