IMoniker::CommonPrefixWith

This method finds the prefix that the moniker has in common with another moniker.

HRESULT CommonPrefixWith( 
IMoniker *pmkOther, 
IMoniker **ppmkPrefix);

Parameters

  • pmkOther
    [in] Pointer to the IMoniker interface on another moniker to be compared with this one to determine whether there is a common prefix.
  • ppmkPrefix
    [out] Address of IMoniker* pointer variable that receives the interface pointer to the moniker that is the common prefix of this moniker and pmkOther. When successful, the implementation must call IUnknown::AddRef on the resulting moniker; it is the caller's responsibility to call IUnknown::Release. If an error occurs or if there is no common prefix, the implementation should set *ppmkPrefix to NULL.

Return Values

The method supports the standard return value E_OUTOFMEMORY, as well as the values described in the following table.

Value Description
S_OK A common prefix exists that is neither this moniker nor pmkOther.
MK_S_NOPREFIX No common prefix exists.
MK_S_HIM The entire pmkOther moniker is a prefix of this moniker.
MK_S_US The two monikers are identical.
MK_S_ME This moniker is a prefix of the pmkOther moniker.
MK_E_NOTBINDABLE This method was called on a relative moniker. It is not meaningful to take the common prefix on a relative moniker.

Remarks

IMoniker::CommonPrefixWith creates a new moniker that consists of the common prefixes of the moniker on this moniker object and another moniker. If, for example, one moniker represents the path "c:\projects\secret\art\pict1.bmp" and another moniker represents the path "c:\projects\secret\docs\chap1.txt," the common prefix of these two monikers would be a moniker representing the path "c:\projects\secret."

Notes to Callers

The IMoniker::CommonPrefixWith method is primarily called in the implementation of the IMoniker::RelativePathTo method. Clients using a moniker to locate an object rarely need to call this method.

Call this method only if pmkOther and this moniker are both absolute monikers. An absolute moniker is either a file moniker or a generic composite whose leftmost component is a file moniker that represents an absolute path. Do not call this method on relative monikers, because it would not produce meaningful results.

Notes to Implementers

Your implementation should first determine whether pmkOther is a moniker of a class that you recognize and for which you can provide special handling (for example, if it is of the same class as this moniker). If so, your implementation should determine the common prefix of the two monikers. Otherwise, it should pass both monikers in a call to the MonikerCommonPrefixWith function, which correctly handles the generic case.

Requirements

Runs On Versions Defined in Include Link to
Windows CE OS 2.0 and later Oaidl.h    

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

MonikerCommonPrefixWith, IMoniker, IMoniker::RelativePathTo, IUnknown::AddRef, IUnknown::Release

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.