弱弱的问下ShellExecute
A程序利用ShellExecute用B.exe和C.exe,那如何A退出的候B、C也同!!!
[解决办法]
procedure MCloseWindow(AClass, ACaption: string);
var
hPreWnd:HWND;
begin
hPreWnd:=FindWindow(PChar(AClass),PChar(ACaption));
if hPreWnd <> 0 then
PostMessage(hPreWnd,WM_QUIT,0,0);
end;//AClass是类名,ACaption是标题
MClossWindow( '这是A程序的主窗口类名如TForm1 ', '这是A程序的主窗口标题 ');
[解决办法]
兄弟你还真吝啬
var
lppe:tprocessentry32;
sshandle:thandle;
hh:hwnd;
found:boolean;
begin
sshandle:=createtoolhelp32snapshot(TH32CS_SNAPALL,0);
found:=process32first(sshandle,lppe);
while found do
begin
if uppercase(extractfilename(lppe.szExeFile))= 'PROJECT2.EXE ' then
begin
hh:=OpenProcess(PROCESS_ALL_ACCESS,true,lppe.th32ProcessID);
TerminateProcess(hh,0);
end;
found:=process32next(sshandle,lppe);
end;
end;