下面给出一段在 Delphi 中关闭“计算器”程序为例:
...
var
CountHWnd: HWnd;
begin
CountHWnd:=FindWindow(nil, '计算器');
if HWndCalculator <> 0 then
SendMessage(CountHWnd, WM_CLOSE, 0, 0);
end;
谢谢。
var
CountHWnd: HWnd;
begin
CountHWnd:=FindWindow(nil, '计算器');
if HWndCalculator <> 0 then
SendMessage(CountHWnd, WM_CLOSE, 0, 0);
end;
HWndCalculator 是是么?
procedure TForm1.Button1Click(Sender: TObject);
var
H:THandle;
PWORD;
begin
H:=FindWindow(nil,'无标题 - 记事本');
if H<>0 then
begin
GetWindowThreadProcessId(H,@P);
if P<>0 then
TerminateProcess(OpenProcess(PROCESS_TERMINATE,False,P),$FFFFFFFF);
end;
end;