Controlling Internet Explorer with Ada


With the help of the COM tools available here on AdaPower, you can take control of Internet Explorer in just a couple of easy steps. (The following directions are for GNAT, I will post directions for other compilers soon.)

1.

Run BindCOM on the file SHDOCVW.DLL located in the System32 directory on NT or the system directory on 95/98. (Make sure you download the AdaWin bindings and the BindCOM tool.)

BindCOM C:\winnt\system32\shdocvw.dll InternetExplorer

This will create a binding to the Microsoft Internet Controls type library.

2.

Paste the following code in to a file called AdaPowerBrowser.adb

with Ada.Text_IO; use Ada.Text_IO;

with InternetExplorer.IWebBrowser2_Interface;
use InternetExplorer.IWebBrowser2_Interface;


with AdaWin; use type AdaWin.VARIANT_BOOL;
with Interfaces.C; use type Interfaces.C.Int;
with AdaCOM.BSTR; use AdaCOM.BSTR;

procedure AdaPowerBrowser is
   Browser       : IWebBrowser2_Type;
   URL           : AdaWin.BSTR :=
     To_BSTR(String'("http://www.adapower.com/adapower1/power.html"));
begin
   Put_Line("Starting AdaPower Browser");
   Create(Browser, "InternetExplorer.Application");

   Put_AddressBar(Browser, 0);
   Put_MenuBar(Browser, 0);
   Put_StatusBar(Browser, 0);
   Put_ToolBar(Browser, 0);
   Put_Visible(Browser, -1);

   Navigate(Browser, URL);
   Free(URL);
end AdaPowerBrowser;

3.

Compile the application by typing:

gnatmake AdaPowerBrowser -I../AdaWin
Where ../AdaWin = the directory where the current version of AdaWin bindings are located.

4.

Just type AdaPowerBrowser to start up your custom InternetExplorer Application.


Contributed by: David Botton
Contributed on: September 9, 1999
Last Updated on: September 19, 1999
License: Public Domain

Back