ShellAPI.ShellExecute(SW_SHOW,nil,pchar(Form1.临时文件夹位置+'Install.bat'),nil,nil,0);
/////////////////////////////////////////////////
for i := 0 to memo.Lines.Count - 1 do想让Install.bat运行完了再运行下面语句该怎么办?先谢谢了!

解决方案 »

  1.   

    使用CreateProcess运行,然后用WaitForSingleObject等待其结束
      

  2.   

    BOOL ShellExecuteEx(          
       LPSHELLEXECUTEINFO lpExecInfo
    );typedef struct _SHELLEXECUTEINFO {
        DWORD cbSize;
        ULONG fMask;
        HWND hwnd;
        LPCTSTR lpVerb;
        LPCTSTR lpFile;
        LPCTSTR lpParameters;
        LPCTSTR lpDirectory;
        int nShow;
        HINSTANCE hInstApp;
        LPVOID lpIDList;
        LPCTSTR lpClass;
        HKEY hkeyClass;
        DWORD dwHotKey;
        union {
            HANDLE hIcon;
            HANDLE hMonitor;
        } DUMMYUNIONNAME;
        HANDLE hProcess;
    } SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;Note ShellExecuteEx does not always return an hProcess, even if a process is launched as the result of the call. For example, an hProcess does not return when you use SEE_MASK_INVOKEIDLIST to invoke IContextMenu.This member is set on return and is always NULL unless fMask is set to SEE_MASK_NOCLOSEPROCESS. Even if fMask is set to SEE_MASK_NOCLOSEPROCESS, hProcess will be NULL if no process was launched. For example, if a document to be launched is a URL and an instance of Microsoft Internet Explorer is already running, it will display the document. No new process is launched, and hProcess will be NULL.得到hProcess之后WaitForSingleObject