请问在一个程序中如何打开和关闭另一个程序,比如说一个按钮是打开,一个是关闭。

解决方案 »

  1.   

    winexec('calc.exe',sw_shownormal);
    或用
     shellexecute(handle,'open','calc.exe',nil,nil,sw_shownormal);
      

  2.   

    shellexecute(handle,'open','calc.exe',nil,nil,sw_shownormal);
    提示在USES中加上API
      

  3.   

    用 WinExec 或 ShellExecute 两个 API 可搞定(注意大小写不能错)
      

  4.   

    关闭外部程序可以用sendmessage发送一个消息。
      

  5.   

    打开
    var
      StartupInfo: TStartupInfo;
      ProcessInfo: TProcessInformation;
      CreateProcess(nil,
        'YourProg.exe',
        nil,
        nil,
        false,
        CREATE_NEW_CONSOLE or
        NORMAL_PRIORITY_CLASS,
        nil,
        nil,
        StartupInfo,
        ProcessInfo);关闭var
      HWndCalc: HWnd;    HWndCalc := FindWindow(nil, 'YourProg-caption');
        if HWndCalc <> 0 then
          SendMessage(HWndCalc, WM_CLOSE, 0, 0);