System.Runtime.InteropServices.Marshal.GetActiveObject Method

Obtains a running instance of the specified object from the running object table (ROT).

Syntax

public static object GetActiveObject (string progID)

Parameters

progID
The programmatic identifier (ProgID) of the object that was requested.

Returns

The object that was requested; otherwise null. You can cast this object to any COM interface that it supports.

Remarks

Marshal.GetActiveObject(string) exposes the COM GetActiveObject function from OLEAUT32.DLL; however, the latter expects a class identifier (CLSID) instead of the programmatic identifier (ProgID) expected by this method. To obtain a running instance of a COM object without a registered ProgID, use platform invoke to define the COM GetActiveObject function. For a description of platform invoke, see [<topic://cpconconsumingunmanageddllfunctions>].

ProgID and CLSID

Keys in the HKEY_CLASSES_ROOT subtree of the registry contain a variety of subkey types. Most of the subkeys are ProgIDs, which map a user-friendly string to a CLSID. Applications often use these human-readable strings instead of the numeric CLSIDs. Often, a component has a version-independent ProgID that is mapped to the latest version of the component that is installed on the system.

Applications and components primarily use ProgIDs to retrieve their corresponding CLSIDs.

Requirements

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0