IMoniker - Anti-Moniker Implementation
Anti-monikers are the inverse of the COM implementations of file, item, and pointer monikers. That is, an anti-moniker composed to the right of a file moniker, item moniker, or pointer moniker composes to nothing.
When To Use
If you're a moniker client, you typically do not need to use anti-monikers. When you need the inverse of a moniker, you should call IMoniker::Inverse. For example, if you need an inverse to remove the last piece of a composite moniker, use IMoniker::Enum to enumerate the pieces of the moniker and call IMoniker::Inverse on the rightmost piece. You shouldn't use an anti-moniker for this purpose because you can't be sure that the rightmost piece of a composite considers an anti-moniker to be its inverse.
The only situation in which you should explicitly use an anti-moniker is if you are writing a new moniker class and if you have no special requirements for constructing inverses to your monikers. In that situation, you can return anti-monikers from your implementation of IMoniker::Inverse. In your implementation of IMoniker::ComposeWith, you should then annihilate one of your monikers for every anti-moniker you encounter.
Remarks
-
IMoniker::BindToObject
-
This method is not implemented. It returns E_NOTIMPL.
-
IMoniker::BindToStorage
-
This method is not implemented. It returns E_NOTIMPL.
-
IMoniker::Reduce
-
This method returns MK_S_REDUCED_TO_SELF and passes back the same moniker.
-
IMoniker::ComposeWith
-
If fOnlyIfNotGeneric is TRUE, this method sets ppmkComposite to NULL moniker and returns MK_E_NEEDGENERIC; otherwise, the method returns the result of combining the two monikers into a generic composite. Note that composing a file, item, or pointer moniker to the right of an anti-moniker produces a generic composite rather than composing to nothing, as would be the case if the order of composition were reversed.
-
IMoniker::Enum
-
This method returns S_OK and sets *ppenumMoniker to NULL.
-
IMoniker::IsEqual
-
This method returns S_OK if both are anti-monikers; otherwise, it returns S_FALSE.
-
IMoniker::Hash
-
This method calculates a hash value for the moniker.
-
IMoniker::IsRunning
-
This method checks the ROT to see if the object is running.
-
IMoniker::GetTimeOfLastChange
-
This method is not implemented (that is, it returns E_NOTIMPL).
-
IMoniker::Inverse
-
This method returns MK_E_NOINVERSE and sets *ppmk to NULL.
-
IMoniker::CommonPrefixWith
-
If the other moniker is also an anti-moniker, the method returns MK_S_US and sets ppmkPrefix to this moniker. Otherwise, the method calls the MonikerCommonPrefixWith function. This function correctly handles the case where the other moniker is a generic composite.
-
IMoniker::RelativePathTo
-
This method returns MK_S_HIM and sets *ppmkRelPath to the other moniker.
-
IMoniker::GetDisplayName
-
For each anti-moniker contained in this moniker, this method return one instance of "\.."
-
IMoniker::ParseDisplayName
-
This method is not implemented (that is, it returns E_NOTIMPL).
-
IMoniker::IsSystemMoniker
-
This method returns S_OK and indicates MKSYS_ANTIMONIKER.
See Also
CreateAntiMoniker, IMoniker