IMoniker::Hash

HRESULT IMoniker::Hash(pdwHash)

Return a 32-bit integer associated with this moniker. This integer is useful for maintaining tables of monikers: the moniker can be hashed to determine a hash bucket in the table, then compared with IMoniker::IsEqual against all the monikers presently in that hash bucket.

It must always be the case that two monikers that compare as equal in either order hash to the same value. In effect, implementations of IMoniker::IsEqual() and IMoniker::Hash are intimate with one another; they must always be written together.

The value returned by IMoniker::Hash is invariant under marshaling: if a moniker is marshaled to a new context, then IMoniker::Hash invoked on the unmarshaled moniker in the new context must return the same value as IMoniker::Hash invoked on the original moniker. This is the only way that a global table of monikers such as the Running Object Table can be maintained in shared space, yet accessed from many processes. The obvious implementation technique this indicates is that IMoniker::Hash should not rely on the memory address of the moniker, but only its internal state.

Argument

Type

Description

pdwHash

DWORD*

The place in which to put the returned hash value.

return value

HRESULT

S_OK