怎么调用外部应用程序?比如调用Windows的计算器
能让外部应用程序成为我的程序的一部分吗,就像Form1.ShowModal等

解决方案 »

  1.   

    执行一个程序,并等待此程序的运行结束
    function WinExecAndWait32(FileName:String; Visibility :
    integer):integer;
    var
     zAppName:array[0..512] of char;
     zCurDir:array[0..255] of char;
     WorkDir:String;
     StartupInfo:TStartupInfo;
     ProcessInfo:TProcessInformation;
    begin
     StrPCopy(zAppName,FileName);
     GetDir(0,WorkDir);
     StrPCopy(zCurDir,WorkDir);
     FillChar(StartupInfo,Sizeof(StartupInfo),#0);
     StartupInfo.cb := Sizeof(StartupInfo);
     StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
     StartupInfo.wShowWindow := Visibility;
     if not CreateProcess(nil,
     zAppName, { pointer to command line string }
     nil, { pointer to process security
    attributes }
     nil, { pointer to thread security
    attributes }
     false, { handle inheritance flag }
     CREATE_NEW_CONSOLE or { creation flags }
     NORMAL_PRIORITY_CLASS,
     nil, { pointer to new environment block }
     nil, { pointer to current directory name }
     StartupInfo, { pointer to STARTUPINFO }
     ProcessInfo) then Result := -1 { pointer to PROCESS_INF }
     else begin
     WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
     GetExitCodeProcess(ProcessInfo.hProcess,Result);
     end;
    end;
    转贴,没测
      

  2.   

    WinExec(外部程序名包括全部径进信息SW_SHOW;
    一般是没有办法让外部程序成为自己程序的一部分的。
      

  3.   

    你有没有Delphi6开发人员指南,如果有的话,看一下第十一章,它有一个调用外程序的控件制作方法
      

  4.   

    我做Delphi没怎么看书的,直接装上就开始做,边做边学,所以很多东西还不是很懂