How to check if a program is installed using its program identifier #233

The following code will return True if a program with the given program ID is installed and registered with the system or False if the program ID is not known.

function ProgIDInstalled(const PID: string): Boolean;
var
  WPID: WideString;  // PID as wide string
  Dummy: TGUID;      // unused out value from CLSIDFromProgID function
begin
  WPID := PID;
  Result := ActiveX.Succeeded(
    ActiveX.CLSIDFromProgID(PWideChar(WPID), Dummy)
  );
end;

To find if a program that registers a program ID is installed, just pass the ID to this routine. For example, the following routine checks if Internet Explorer installed:

function IsIEInstalled: Boolean;
begin
  Result := ProgIDInstalled('InternetExplorer.Application');
end;

Both the above routines are available from the DelphiDabbler Code Snippets Database.

The following program IDs for MS applications may be useful:

  • Access.Application
  • Excel.Application
  • FrontPage.Application
  • Outlook.Application
  • PowerPoint.Application
  • MSProject.Application
  • Word.Application

This tip was created by DelphiDabbler from code contributed by Michael Rockett.

Original resource:
Author: Peter Johnson
Contributor: Michael Rockett
Added: 2014/01/23
Last updated: 2014/01/23