Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

A monikeris a COM object that identifies an object and provides services to allow for other components to obtain a pointer to that object. There are two ways of viewing monikers: as a moniker client, which is a component that uses a moniker to get a pointer to another object, and as a moniker provider. This is a component that supplies monikers identifying its objects to moniker clients.

Procedures

To create a URL moniker for an application
  1. Implement the IBindStatusCallbackinterface and create an instance of your IBindStatusCallbackinterface.

  2. Call CreateURLMonikerwith the URL and get the IMonikerinterface.

  3. Call CreateAsyncBindCtxand get the IBindCtxinterface.

  4. Call RegisterBindStatusCallbackwith the IBindCtxand IBindStatusCallbackinterfaces.

  5. Call one of the IMonikerbinding methods ( IMoniker::BindToStorageor IMoniker::BindToObject) with the IBindCtxinterface. In the asynchronous case, where IBindStatusCallbackis implemented, the client application can get a pointer to the IStreamor IStorageinterface. The client application should call the IUnknown::Releasemethod on the interface and use the interface returned in the IBindStatusCallback::OnDataAvailablecall.

  6. The IMonikerbinding method calls IBindStatusCallback::GetBindInfomethod to get the bind information.

  7. The IBindStatusCallback::OnStartBindingmethod will be called.

  8. The IBindStatusCallback::OnProgressmethod will be called.

  9. If IMoniker::BindToStoragewas used, IBindStatusCallback::OnDataAvailablemethod will be called. If IMoniker::BindToObjectwas used, IBindStatusCallback::OnObjectAvailablewill be called.

Steps 8 and 9 are repeated until the binding is completed. When binding is complete, the IBindStatusCallback::OnStopBindingmethod will be called.

To create a URL moniker for a control
  1. Implement the IBindStatusCallbackinterface and create an instance of the IBindStatusCallbackinterface.

  2. Call CreateAsyncBindCtxand get a pointer to the IBindCtxinterface.

  3. Call IBindHost::CreateMonikerwith the IBindCtxinterface and get a pointer to the IMonikerinterface.

  4. Call one of the IBindHostbinding methods ( IBindHost::MonikerBindToStorageor IBindHost::MonikerBindToObject) with the IBindCtx, IMoniker, and IBindStatusCallbackinterfaces.

  5. The IMonikerbinding method calls the IBindStatusCallback::GetBindInfomethod to get the bind information.

  6. The IBindStatusCallback::OnStartBindingmethod will be called.

  7. The IBindStatusCallback::OnProgressmethod will be called.

  8. Either IBindStatusCallback::OnDataAvailable(if IBindHost::MonikerBindToStoragewas used) or IBindStatusCallback::OnObjectAvailable(if IBindHost::MonikerBindToObjectwas used) will be called.

  9. If IBindStatusCallbackis implemented, steps 8 and 9 are repeated until the binding is completed. When binding is completed the IBindStatusCallback::OnStopBindingmethod will be called.

    Note:
    MSHTML does not support the IBindStatusCallbackinterface. Applications that are hosting MSHTML and want to get callbacks on the progress of the bind operation should implement the IPropertyNotifySinkinterface.

Handling BINDINFO Structures

The BINDINFOstructure is used by methods, such as IBindStatusCallback::GetBindInfo, to pass information that specifies how a bind operation should be handled. To correctly write information to this structure, the client application should clear the BINDINFOstructure and check the size of the BINDINFOstructure to determine what version was passed.

Clearing the BINDINFOstructure, before writing information into it, prevents members that are not being used from containing incorrect data.

The following code example shows how to clear the structure.

Copy Code
// pbindinfo is a pointer to a BINDINFO structure.
DWORD cbSize = pbindinfo->cbSize; 
memset(pbindinfo,0,cbSize);
pbindinfo->cbSize = cbSize;

Because the size of the BINDINFOstructure increased effective with Microsoft Internet Explorer 4.0, client applications should check the size of the structure that is passed into their implementation of any methods that use this structure.

The following code example shows how to check the size of the structure for accessing members of the BINDINFOstructure beyond cbstgmedData.

Copy Code
if (pbindinfo->cbSize >= offsetof(BINDINFO, dwReserved))
{
	// Write to additional fields.
}
else
{
	// Added functionality is not available, so make any
adjustments necessary.
}

See Also