Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using the GetActiveObject\GetActiveOleObject routines On Internet Explorer

104 views
Skip to first unread message

Victor Hason

unread,
Dec 30, 2000, 3:44:14 PM12/30/00
to
Hi!

I'm trying to access the already-running instance of Internet Explorer
Using the routines listed above -
and it does'nt work.

here's my code :

procedure TForm1.FlatButton1Click(Sender: TObject);
var
unk: IUnknown;
di: IDispatch;
inst: IWebBrowser2;
begin

GetActiveObject(CLASS_InternetExplorer, nil, Unk);
Inst:= Unk as Iwebbrowser2;
// Unk stays nil

di:= GetActiveOleObject('InternetExplorer.Application');
// the code raises an OleException
inst:= di as IWebBrowser2;
end;

I find this phenomenon rather strage, since the same code worked on Word and
Excel.
I used the constant CLASS_InternetExplorer based on what's in the type
library,
and tried using the Original GUID from the registry - still with no success.

I even tried using other constants, such as CLASS_WebBrowser_V1 and
CLASS_WebBrowser, and that didn't work either.

Ideas?

thanks,

Victor.

Deborah Pate (TeamB)

unread,
Dec 31, 2000, 5:07:09 AM12/31/00
to
<<Victor Hason:

I'm trying to access the already-running instance of Internet Explorer
>>

IE doesn't register itself in the running object table, so
GetActiveObject doesn't work. You can use the IShellWindows interface to
get a running instance:

function GetRunningInstance: IWebBrowser2;
var
ShWindows: IShellWindows;
i: integer;
begin
ShWindows := CoShellWindows.Create;
for i := 0 to ShWindows.Count - 1 do
begin
Result := ShWindows.Item(i) as IWebBrowser2;
if Result.LocationURL =
'http://www.djpate.freeserve.co.uk/' then
Break;
end;
end;

--
Deborah Pate (TeamB)
http://delphi-jedi.org
Sorry, no email please.

0 new messages