我的程序里用WinExec函数调用了一个外部程序,我想问一下,当我关闭我的程序时怎么同时关闭这个外部程序
解决方案 »
- Delphi MDI程序 父窗体如何调用当前活动子窗体的函数/过程
- 软件(MES/SFC/CRM/SAP)实施顾问请进
- 找出某个路径下的所有子目录和文件?
- 请问控制台程序如何转让控制权
- TServerSocket的阻塞模式时读取数据时的问题
- 又一個平庸的問題, 如何通過代碼將一個菜單中的items添加到另一個菜單中?
- 巨分悬赏,此程序哪里有错!关于EXCEL的简单问题
- 如何使pl处理过的数据返回到delphi编写的程序中
- 我想把unit1中一个过程的代码放到unit2中的某个过程中什么办?
- 一个问题困扰一周,有人解答,但还是....
- 问一个小问题:字段中出现“'”号时,如何处理?
- 打印机问题!!!急
procedure TForm1.Button1Click(Sender: TObject);
var
StartUpInfo: TStartUpInfo; // holds startup information
begin
{initialize the startup information}
FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
with StartupInfo do begin
cb := SizeOf(TStartupInfo);
dwFlags := STARTF_USESHOWWINDOW;
wShowWindow := SW_SHOWNORMAL;
end; {launch a process}
CreateProcess('c:\Windows\calc.exe', nil, nil, nil, False,
NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);
end;关闭
procedure TForm1.Button2Click(Sender: TObject);
var
ExitCode: DWORD; // holds the process exit codebegin
{terminate the process and retrieve the exit code}
TerminateProcess(ProcessInfo.HProcess, 10);
GetExitCodeProcess(ProcessInfo.HProcess, ExitCode); {display the exit code}
Label1.Caption := 'The exit code is '+Inttostr(ExitCode);
end;
var
HWndCalc: HWnd; // 窗口句柄
begin
// 查找“计算器”窗口
HWndCalc:= FindWindow(nil, '计算器');
if HWndCalc <> 0 then
SendMessage(HWndCalc, WM_CLOSE, 0, 0);
end;