Que te parece algo asi:
Código Delphi
[-]
function EnumWindowsProc(Handle: Thandle; lParam: LPARAM): BOOL; stdcall;
var
Buffer: PChar;
Size: Integer;
Lista: TStringList;
i: integer;
begin
Result:= TRUE;
GetMem(Buffer,Length('IEFrame') + 1);
try
GetClassname(Handle,Buffer,Length('IEFrame') + 1);
if StrIComp(Buffer,'IEFrame') <> 0 then
Exit;
finally
FreeMem(Buffer);
end;
Size:= GetWindowTextLength(Handle) + 1;
GetMem(Buffer,Size);
try
GetWindowText(Handle,Buffer,Size);
StrUpper(Buffer);
Lista:= TStringList(Pointer(LParam));
for i := 0 to Lista.Count - 1 do
begin
if Pos(Lista[i],String(Buffer)) > 0 then
begin
PostMessage(Handle,WM_Close,0,0);
Exit;
end;
end;
finally
Freemem(Buffer);
end;
end;
var
Lista: TStringList;
begin
Lista:= TstringList.Create;
try
Lista.Add('Google');
Lista.Text:= Uppercase(Lista.Text);
EnumWindows(@EnumWindowsProc, LParam(Pointer(Lista)));
finally
Lista.Free;
end;
end;
El único problema que veo es que la ventana no se quiera cerrar, por ejemplo si estas en una sesión de webmessenger saldrá un mensaje pidiendo confirmación para cerrar la sesión. Yo en estos caso lo que hago es matar el proceso, pero eso ya es otra historia ...