CoRegisterMessageFilter function (objbase.h)

Registers with OLE the instance of an IMessageFilter interface, which is to be used for handling concurrency issues on the current thread. Only one message filter can be registered for each thread. Threads in multithreaded apartments cannot have message filters.


HRESULT CoRegisterMessageFilter(
  [in, optional]  LPMESSAGEFILTER lpMessageFilter,
  [out, optional] LPMESSAGEFILTER *lplpMessageFilter


[in, optional] lpMessageFilter

A pointer to the IMessageFilter interface on the message filter. This message filter should be registered on the current thread, replacing the previous message filter (if any). This parameter can be NULL, indicating that no message filter should be registered on the current thread.

Note that this function calls AddRef on the interface pointer to the message filter.

[out, optional] lplpMessageFilter

Address of the IMessageFilter* pointer variable that receives the interface pointer to the previously registered message filter. If there was no previously registered message filter for the current thread, the value of *lplpMessageFilter is NULL.

Return value

If the instance was registered or revoked successfully, the return value is S_OK; otherwise, it is S_FALSE.


To revoke the registered message filter, pass the previous message filter (possibly NULL) as the lpMessageFilter parameter to CoRegisterMessageFilter.


Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header objbase.h
Library Ole32.lib
DLL Ole32.dll

See also