Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MonikerCommonPrefixWith function

Creates a new moniker based on the common prefix that this moniker (the one comprising the data of this moniker object) shares with another moniker.

This function is intended to be called only in implementations of IMoniker::CommonPrefixWith.


HRESULT MonikerCommonPrefixWith(
  _In_  LPMONIKER pmkThis,
  _In_  LPMONIKER pmkOther,
  _Out_ LPMONIKER *ppmkCommon


pmkThis [in]

A pointer to the IMoniker interface on one of the monikers for which a common prefix is sought; usually the moniker in which this call is used to implement IMoniker::CommonPrefixWith.

pmkOther [in]

A pointer to the IMoniker interface on the moniker to be compared with the first moniker.

ppmkCommon [out]

The address of an IMoniker* pointer variable that receives the interface pointer to the moniker based on the common prefix of pmkThis and pmkOther. When successful, the function has called AddRef on the moniker and the caller is responsible for calling Release. If an error occurs, the supplied interface pointer value is NULL.

Return value

This function can return the standard return values E_OUTOFMEMORY and E_UNEXPECTED, as well as the following values.

Return codeDescription

A common prefix exists that is neither pmkThis nor pmkOther.


The entire pmkOther moniker is a prefix of the pmkThis moniker.


The entire pmkThis moniker is a prefix of the pmkOther moniker.


The pmkThis and pmkOther monikers are equal.


The monikers have no common prefix.


This function was called on a relative moniker. It is not meaningful to take the common prefix of relative monikers.



Your implementation of IMoniker::CommonPrefixWith should first check whether the other moniker is of a type that you recognize and handle in a special way. If not, you should call MonikerCommonPrefixWith, passing itself as pmkThis and the other moniker as pmkOther. MonikerCommonPrefixWith correctly handles the cases where either moniker is a generic composite.

You should call this function only if pmkThis and pmkOther are both absolute monikers (where an absolute moniker is either a file moniker or a generic composite whose leftmost component is a file moniker, and where the file moniker represents an absolute path). Do not call this function on relative monikers.


Minimum supported client

Windows 2000 Professional [desktop apps | UWP apps]

Minimum supported server

Windows 2000 Server [desktop apps | UWP apps]







See also




© 2018 Microsoft