procedure WinExecExt(ProgramToStart: string; Params: string; Show: Integer);
var
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
begin
  if (Params <> '') and (Params[1] <> ' ') then
    Params := ' ' + Params;
  FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
  StartupInfo.cb := SizeOf(TStartupInfo);
  StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartupInfo.wShowWindow := Show;
  if not (CreateProcess(PChar(ProgramToStart), PChar(Params), nil,
    nil, False, NORMAL_PRIORITY_CLASS, nil, nil,
    StartupInfo, ProcessInfo)) then
    RaiseLastWin32Error;
end;

解决方案 »

  1.   

    var 
      fldname:array[0..200] of char;
      tmps:string;
    if fileexists(extractfilepath(application.exename)+'aaaa.exe') then
    begin
        tmps:=extractfilepath(application.ExeName)+'aaaa.exe';
        strpcopy(fldname,tmps);
        try
          winexec(fldname,SW_SHOWNORMAL);
        except
          application.MessageBox(pchar('调用程序错误:'#13#13'调用运行程序失败。'),'系统错误',mb_iconwarning);
        end;
      end else application.MessageBox('没有发现执行程序!','程序提示',mb_ok or mb_iconinformation);
    end;