«« Site Rescued »»

While the site is still going to move from its current host, a new site will now take its place. More Info.

The new site may have less content, but the core will now remain. And it will now play nicely with phones! Keep an eye on the DelphiDabbler Blog for news.

» Help

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

   

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 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.

Author: Peter Johnson
Contributor: Michael Rockett
Added: 2014-01-23
Last updated: 2014-01-23

« Return to contents »