比如procedure TForm1.Button1Click(Sender: TObject);
begin
  ShellExecute(handle,'open',‘c:\bz.exe','nil','nil',SW_SHOWNORMAL);
end;
现在希望在关闭FORM1时,或关闭FORM1所在的工程时,C:\BZ.EXE 能够自动关闭。

解决方案 »

  1.   

    To obtain information about the application that is launched as a result of calling ShellExecute, use ShellExecuteEx. 
    ///////////////////////////////////////////
    WINSHELLAPI BOOL WINAPI ShellExecuteEx(
        LPSHELLEXECUTEINFO lpExecInfo
    ); Performs an action on a file. Returns a nonzero value if successful, or zero otherwise. To get extended error information, call theGetLastError function. 
    lpExecInfo 
    Address of a SHELLEXECUTEINFO structure that contains and receives information about the application being executed. 
    If the function succeeds, it sets the hInstApp member of the SHELLEXECUTEINFO structure to the instance handle to the application that the function started. If the function fails, hInstApp is one of the SE_ERR_ error values indicating the cause of the failure. (An instance handle will always be greater than 32 and an error value less than 32.) Note that the SE_ERR_ error values are for compatibility with the ShellExecute function; use theGetLastError function to retrieve error information. 
      

  2.   

    gold_future(金色未来) 
      同志:稍微给点中文解释吗,我有点菜啊,仿佛已经看到正确答案了,麻烦了