我在一个程序A中用ShellExecute去调用另一个程序B,然后A隐藏,怎么做到等B关闭后A再Show出来呢?
先谢谢大家!

解决方案 »

  1.   

    不停的FINDWINDOW,如果找不到B,就Show出来
      

  2.   

    function Compression(p:pointer):dword;stdcall;//WINRAR压缩文件,你也可以换成别的文件
    var
     SHExecInfo:SHELLEXECUTEINFO;
     tmpdir:string;
     ExitCode: cardinal;
    begin
    tmpdir:=GetTempDirectory;
    SHExecInfo.cbSize :=sizeof(SHELLEXECUTEINFO);
    SHExecInfo.fMask:=SEE_MASK_NOCLOSEPROCESS;
    SHExecInfo.Wnd:=MainFm.Handle;
    SHExecInfo.lpVerb:='open';
    SHExecInfo.lpFile:='WinRAR.exe';//文件名
    SHExecInfo.lpParameters:= pchar('a -s -y '+'"'+tmpdir+'tmp.rar'+'"  "'+rec.Maindir+'"');//参数设置
    SHExecInfo.lpDirectory:=nil;
    SHExecInfo.nShow:= SW_HIDE;
    SHExecInfo.hInstApp:=MainFm.Handle;;
    ShellExecuteEx(@SHExecInfo);
    GetExitCodeProcess(SHExecInfo.hProcess,ExitCode);
    while ExitCode=STILL_ACTIVE do begin  //循环等待直到winrar压缩完成
    GetExitCodeProcess(SHExecInfo.hProcess,ExitCode);
    sleep(10);
    Application.ProcessMessages;
    end;
    CloseHandle(SHExecInfo.hProcess);
    end;CompressionHandle :=CreateThread(nil,0,@Compression,nil,0,ID1);
    //这里写隐藏程序的代码
    if WaitForSingleObject(CompressionHandle , INFINITE) = WAIT_OBJECT_0 then //等待压缩完毕
    begin
    //这里写显示程序的代码
    end;
      

  3.   

    SHExecInfo.nShow:= SW_HIDE;  这里是隐藏,你要换成正常显示 叫shownormal吧