Documente Academic
Documente Profesional
Documente Cultură
o Style : LongInt;
o Buff, ProgTitle, AlternativeTitle : Array[0..6] of Char; {limit
size to first 6 characters}
begin
o StrPLCopy(ProgTitle,Title,6); {convert string title to nullterm. char ProgTitle}
o StrPLCopy(AlternativeTitle,AltTitle,6); {convert string title to
null-term. char ProgTitle}
o {Wnd := EnumWindow(Handle,)}{is this a better tool????}
o Wnd := GetWindow(Handle, gw_HWndLast);
o GetWindowText(Wnd,buff,sizeof(buff)); {initialise buff}
o While ((Wnd <> 0) and not((Buff = ProgTitle) or (Buff =
AlternativeTitle))) do
{get list of all open windows except this programs
window handle}
begin
if (Wnd <> Handle) and isWindowVisible(Wnd) and
(GetWindow(Wnd, gw_Owner) = 0) and
(GetWindowText(Wnd,buff, sizeof(buff)) <> 0) then
GetWindowText(Wnd,buff,sizeof(buff));
if ((buff = ProgTitle) or (Buff = AlternativeTitle)) then
begin
postMessage(Wnd, $10, 0, 0);{gives window close
command but closure is under application control}
{ToolHelp.TerminateApp(Wnd,NO_UAE_BOX); }
{forcibly closes app but may not free all
resources}
{DestroyWindow(Wnd);}{close application - is
there a better way???}
showMessage('One instance closed');
end;
Wnd := GetWindow(Wnd, gw_hWndPrev);
end;
end;