How to Start Microsoft Internet Explorer

Since Internet Explorer is a part of Microsoft Windows 95 (OSR 2 and OSR 2.1), 98, ME, NT, 2000, XP or Windows Vista you may want to add a link to your home page that will start Microsoft Internet Explorer (MSIE). Here’s the code to do so:

uses
  Windows, {$ifdef ver90} OLEAuto {$else} ComObj {$endif};
...
procedure StartIE(sURL: string);
var
  hwndHandle: HWnd;
  vIE: Variant;
begin
  if VarIsEmpty(vIE) then begin
    vIE := CreateOleObject('InternetExplorer.Application');
    vIE.Visible := True;
    vIE.Navigate(sUrl);
  end else begin
    hwndHandle := FindWindow('IEFrame', nil);
    if hwndHandle <> 0 then begin
      vIE.Navigate(sURL);
      SetForegroundWindow(hwndHandle);
    end else
      ShowMessage('Can''t open Microsoft Internet Explorer!');
  end;
end;

Example:

StartIE('http://www.delphifaq.net/');

Tags: , , , , , , , , , , , , , , , , , ,

No Comments Yet

You can be the first to comment!

Leave a comment

OpenID Login

Standard Login