# CreateAntiMoniker

Creates and supplies a new anti-moniker.

WINOLEAPI CreateAntiMoniker(

LPMONIKER FAR *ppmk | //Indirect pointer to the anti-moniker
); |

Parameter

ppmk
  [out] Indirect pointer to the IMoniker interface on the new anti-moniker. When successful, the function has called IUnknown::AddRef on the parameter and the caller is responsible for calling IUnknown::Release. When an error occurs, the pointer is NULL.

Return Values

This function supports the standard return value E_OUTOFMEMORY, as well as the following:

S_OK
  The anti-moniker has been created successfully.

Remarks

You would call this function only if you are writing your own moniker class (implementing the IMoniker interface). If you are writing a new moniker class that has no internal structure, you can use CreateAntiMoniker in your implementation of the IMoniker::Inverse method, and then check for an anti-moniker in your implementation of IMoniker::ComposeWith.

Like the “..” directory in MS-DOS file systems, which acts as the inverse to any directory name just preceding it in a path, an anti-moniker acts as the inverse of a simple moniker that precedes it in a composite moniker. An anti-moniker is used as the inverse of simple monikers with no internal structure. For example, the system-provided implementations of file monikers, item monikers, and pointer monikers all use anti-monikers as their inverse; consequently, an anti-moniker composed to the right of one of these monikers composes to nothing.

A moniker client (an object that is using a moniker to bind to another object) typically does not know the class of a given moniker, so the client cannot be sure that an anti-moniker is the inverse. Therefore, to get the inverse of a moniker, you would call IMoniker::Inverse rather than CreateAntiMoniker.

To remove the last piece of a composite moniker, you would do the following:

1. Call IMoniker::Enum on the composite, specifying FALSE as the first parameter. This creates an enumerator that returns the component monikers in reverse order.

2. Use the enumerator to retrieve the last piece of the composite.

3. Call IMoniker::Inverse on that moniker. The moniker returned by IMoniker::Inverse will remove the last piece of the composite.

See Also

IMoniker::Inverse, IMoniker::ComposeWith, IMoniker - Anti-Moniker Implementation