EvoCorp Home    Delphi::Advance

 

 

   

 

Interface Interrogator

Have you ever needed to find out what interfaces or services a particular COM class (or interface) supported? If you're like me then you like to investigate every third party object you use, what it can do and how it does what it does, simply because this provides an important boost to the educated development of your applications.

This is the sole reason I developed CoClassXplorer (CCX).

When creating my ActiveX Document Server for Internet Explorer I wanted something that could "scan" or interrogate the world around me - by investigating Internet Explorer's internal architecture you can better develop a server that integrates properly into that environment. So I developed the Interface Interrogator to automate the investigative work for me (and CoClassXplorer takes that one step further by visually presenting the information it finds).

Using the interface interrogator is easy. There are two functions, InterrogateInterfaces and InterrogateServices that scan the list of supported interfaces for you. Both of these interfaces accept a parameter identifying the interface you want to scan, a  parameter identifying where to obtain the list of interfaces to scan for and a third parameter containing the list of interfaces found during the scan (an object you must create yourself).

Please note that these two functions won't always return 100% of the interfaces supported - they can only return information regarding interfaces that the interrogator already knows about (as listed in IridiumXKnownIntfs.dat) or ones that are otherwise registered in the system registry.

Example

The following example shows how to use IntfScanner to obtain a list of interfaces supported by the IWebBrowser2 interface of the TWebBrowser control:

uses
  ..., ShDocVw, Dialogs, IntfScanner;
 
type
  TForm1 = class(TForm)
    Button1: TButton;
    WebBrowser1: TWebBrowser;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
  
procedure TForm1.Button1Click(Sender: TObject);
var Interfaces: TInterfaceItems;
    i: Integer;
begin
  Interfaces := TInterfaceItems.Create;
  try
    InterrogateInterfaces(WebBrowser1.DefaultInterface,
      [ssKnown, ssRegistry], Interfaces);
    if Interfaces.Count > 0 then
      for i := 0 to Interfaces.Count - 1 do
        // sIID contains the "friendly" representation
        // of the interface ID, for example "IUnknown".
        ShowMessage(Interfaces[i].sIID);
  finally
    Interfaces.Free;
  end;
end;

Requirements

  • Delphi 4
  • IridiumXKnownIntfs.dat
    This file contains a predefined list of known interfaces and their "friendly" names.

Download Code

IntfScanner.pas can be downloaded here.

Microsoft Internet Explorer is a registered trademark of Microsoft Corporation.