PROGID$ function

Purpose

Return the unique alphanumeric PROGID string (text) associated with a unique CLSID string of a COM object or component.  A COM object/component must include an alphanumeric PROGID string in order to be used by PowerBASIC (and Visual Basic).

Syntax

a$ = PROGID$(ClassID$)

Remarks

A PROGID string is the unique alphanumeric text name associated with a given COM object/component.  For example, "Word.Application.8".

You convert the 16-byte (128-bit) binary class ID of a COM object/component into a PROGID string with the PROGID$ function.

PROGID$ takes the (16-byte) binary string ClassID$ representing the GUID or UUID of a COM object/component, and examines the system registry in order to determine the PROGID string associated with the ClassID$ string.  ClassID$ may be a dynamic string or fixed-length string of at least 16 bytes, or (typically) a GUID variable.

If the ClassID$ cannot be found, or any error occurs in the lookup process, PROGID$ will not set the ERR system variable, but will return an empty string.

PROGID$ is the complement to the CLSID$ function.  Using these two functions together, it is possible to extract the precise capitalization of the PROGID from the system registry.  See the example below.

See also

DIM, CLSID$, GUID$, GUIDTXT$, INTERFACE/END INTERFACE, ISNOTHING, ISOBJECT, OBJECT, OBJACTIVE, OBJPTR, OBJRESULT, SET

Example

DIM MSWordClassID AS GUID

MSWordClassID = CLSID$("Word.Application")

IF TRIM$(MSWordClassID, $NUL) <> "" THEN

  'Success getting the CLSID$ of MSWord

  a$ = PROGID$(MSWordClassID)

  'a$ now contains "Word.Application.8"

  b$ = GUIDTXT$(MSWordClassID)

  'b$ holds "{000209FF-0000-0000-C000-000000000046}"

END IF