DOS命令是 【D:\压缩文件.exe < D:password.txt】 可执行因是带密码的压缩文件,每次执行要输入密码。
所以把密码放入文本文件中。可是用下列代码不起作用procedure ShellExecute_AndWait(CMDLine: string; Params: string);
var
  exInfo: TShellExecuteInfo; //引用uses shellapi
  Ph: DWORD;
  cmdbuffer: array [0..MAX_PATH] of Char;
begin
  FillChar(exInfo, SizeOf(exInfo), 0);
  with exInfo do begin
    cbSize := SizeOf(exInfo);
    fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT;
    Wnd := GetActiveWindow();
    ExInfo.lpVerb := 'open';
    ExInfo.lpParameters := PChar(Params);
    lpFile := PChar(CMDLine);
    nShow := SW_SHOWNORMAL;
  end;  if ShellExecuteEx(@exInfo) then
    Ph := exInfo.HProcess
  else begin
    ShowMessage(SysErrorMessage(GetLastError));
    Exit;
  end;  while WaitForSingleObject(ExInfo.hProcess, 50) <> WAIT_OBJECT_0 do
    Application.ProcessMessages;  CloseHandle(Ph);
end;——————————————————————————————
若是【D:\压缩文件.exe】没问题,
但是【D:\压缩文件.exe < D:password.txt】 出错。Help me! 

解决方案 »

  1.   

    winexec('D:\压缩文件.exe < D:password.txt',SW_HIDE);
      

  2.   

    用参数 压缩文件.exe password
      

  3.   

    压缩文件.exe password   我早试过了根本不认!我把【D:\压缩文件.exe < D:password.txt】写成批处理,可执行了。——————————————————————————————————
    可是又出现新的问题了。
    当密码不对时,该执行文件会让重新输入密码。如何取到可执行文件的结果,并给它输入密码。
      

  4.   

    在Delphi中, 用ShellExecute启动的可执行文件,怎么控制打开的MS-Dos画面呀?
      

  5.   

    ShellExecute用这个吧ShellExectue('D:\压缩文件.exe','< D:password.txt',.....);这样就行了...