次の方法で共有


IMoniker::CommonPrefixWith (Windows Embedded CE 6.0)

1/6/2010

Thismethod finds the prefix that the moniker has in common with another moniker.

Syntax

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 the 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 the IUnknown::AddRef method on the resulting moniker; it is the caller's responsibility to call the IUnknown::Release method.

    If an error occurs or if there is no common prefix, the implementation should set *ppmkPrefix to NULL.

Return Value

The method supports the standard return value E_OUTOFMEMORY.

The following table shows the additional return values for this method.

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.

To determine whether the platform supports this interface, see Determining Supported COM APIs.

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

Header objidl.h, objidl.idl
Library ole32.lib, uuid.lib
Windows Embedded CE Windows CE 2.0 and later

See Also

Reference

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