COM
Expand Minimize

CreateObjrefMoniker function

Creates an OBJREF moniker based on a pointer to an object.

Syntax


HRESULT CreateObjrefMoniker(
  _In_opt_  LPUNKNOWN punk,
  _Out_     LPMONIKER *ppmk
);

Parameters

punk [in, optional]

A pointer to the IUnknown interface on the object that the moniker is to represent.

ppmk [out]

Address of a pointer to the IMoniker interface on the OBJREF moniker that was created.

Return value

This function can return the standard return values E_OUTOFMEMORY, E_UNEXPECTED, and S_OK.

Remarks

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:

OBJREF:nnnnnnnn

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)

The script engine internally makes the calls to MkParseDisplayName and IMoniker::BindToObject, and the script can then use objMyInstance to refer directly to the running object.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps | Windows Store apps]

Minimum supported server

Windows 2000 Server [desktop apps | Windows Store apps]

Header

Objbase.h

Library

Ole32.lib

DLL

Ole32.dll

See also

IMoniker

 

 

Community Additions

ADD
Show:
© 2014 Microsoft