function Mynum(hand:HWND;lparam:Lparam):integer;stdcall;
function Mynum(hand:HWND;lparam:Lparam):integer;stdcall;
var
buff:Array[0..255] of char;
dc:HDC;
begin
if Hand<>0 then
begin
getwindowtext(hand,buff,255);
if trim(buff) <> '' then
FrmClose.LBxWinList.Items.Add(buff);
result:=hand;
end;
end;
procedure TFrmClose.FormShow(Sender: TObject);
begin
EnumWindows(@Mynum,0);
end;
procedure TFrmClose.Button1Click(Sender: TObject);
var
CloHan:HWND;
begin
CloHan:=FindWindow(nil,pchar(LbxWinList.Items.Strings[LbxWinList.ItemIndex]));
if CloHan <> 0 then
begin
postMessage(CloHan,WM_QUIT,0,0);
end
else showmessage('没有发现窗口!!');
LbxWinlist.Clear;
EnumWindows(@Mynum,0);
end;