Obtains a running instance of the specified object from the running object table (ROT).
Assembly: mscorlib (in mscorlib.dll)
- Type: System::String
The programmatic identifier (ProgID) of the object that was requested.
Return ValueType: System::Object
The object that was requested; otherwise nullptr. You can cast this object to any COM interface that it supports.
exposes the COM GetActiveObject Function 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 function. For a description of platform invoke, see Consuming Unmanaged DLL Functions.
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.
The following example was run on a computer that was configured with a running instance of Microsoft Word. There were no instances of Microsoft Excel running.
The example calls twice. The first call tries to retrieve a reference to an instance of Microsoft Word (an instance of the Word.Application object). The second call tries to retrieve a reference to an instance of Microsoft Excel (an instance of an Excel.Application object).
The code retrieves a reference to an instance of Microsoft Word successfully. However, because Microsoft Excel is not running, the attempt to retrieve the second object raises a COMException.
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2