在delphi 中调用bcp进行数据导入导出,如何知道该进程是否执行完毕。
好像delphi只是发出了命令,而不管结果

解决方案 »

  1.   

    procedure WaitForExecute(Command: string; Show: Boolean = False);
    var
      StartInfo: TStartupInfo;
      ProcessInfo: TProcessInformation;
    begin
      Screen.Cursor := crHourGlass;  FillChar(StartInfo, SizeOf(StartInfo), 0);
      StartInfo.cb := Sizeof(StartupInfo);
      StartInfo.dwFlags := STARTF_USESHOWWINDOW;
      if Show then
        StartInfo.wShowWindow := SW_SHOW
      else
        StartInfo.wShowWindow := SW_HIDE;  if CreateProcessA(nil, PChar(Command), nil,
        nil, True, 32, nil, nil, StartInfo, ProcessInfo) then
      begin
        WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
      end;
      Screen.Cursor := crDefault;
    end;