CreateObjrefMoniker function (objbase.h)
Creates an OBJREF moniker based on a pointer to an object.
HRESULT CreateObjrefMoniker( [in, optional] LPUNKNOWN punk, [out] LPMONIKER *ppmk );
[in, optional] punk
A pointer to the IUnknown interface on the object that the moniker is to represent.
Address of a pointer to the IMoniker interface on the OBJREF moniker that was created.
This function can return the standard return values E_OUTOFMEMORY, E_UNEXPECTED, and S_OK.
Clients use OBJREF monikers to obtain a marshaled pointer to a running object in the servers address space.
The server typically calls CreateObjrefMoniker to create an OBJREF moniker and then calls IMoniker::GetDisplayName, and finally releases the moniker. The display name for an OBJREF moniker is of the form:
Where nnnnnnnn is an arbitrarily long base-64 encoding that encapsulates the computer location, process endpoint, and interface pointer ID (IPID) of the running object
The display name can then be transferred to the client as text. For example, the display name can reside on an HTML page that the client downloads.
The client can pass the display name to MkParseDisplayName, which creates an OBJREF moniker based on the display name. A call to the monikers IMoniker::BindToObject method then obtains a marshaled pointer to the running instance on the server.
For example, a server-side COM component contained in an Active Server Page can create an OBJREF moniker, obtain its display name, and write the display name to the HTML output that is sent to the client browser. A script that runs on the client side can use the display name to get access to the running object itself. A client-side Visual Basic script, for instance, could store the display name in a variable called strMyName and include this line:
objMyInstance = GetObject(strMyName)
|Minimum supported client||Windows 2000 Professional [desktop apps | UWP apps]|
|Minimum supported server||Windows 2000 Server [desktop apps | UWP apps]|
|API set||ext-ms-win-com-ole32-l1-1-5 (introduced in Windows 10, version 10.0.15063)|