Click to Rate and Give Feedback
MSDN
MSDN Library
COM
COM Fundamentals
Reference
Functions
 CoRegisterMessageFilter Function

  Switch on low bandwidth view
CoRegisterMessageFilter Function

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 multi-threaded apartments cannot have message filters.

Syntax

C++
HRESULT CoRegisterMessageFilter(
  __in_opt   LPMESSAGEFILTER lpMessageFilter,
  __out_opt  LPMESSAGEFILTER *lplpMessageFilter
);

Parameters

lpMessageFilter [in, optional]

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.

lplpMessageFilter [out, optional]

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.

Remarks

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

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderObjbase.h
LibraryOle32.lib
DLLOle32.dll

See Also

IMessageFilter

Send comments about this topic to Microsoft

Build date: 7/9/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Behavior if current IMessageFilter is NULL?      Arno_S ... Thomas Lee   |   Edit   |   Show History
What is the behavior if CoRegisterMessageFilter( NULL, ... ) is set? My guess would be it is like

HandleInComingCall:
return SERVERCALL_ISHANDLED;

RetryRejectedCall:
return (DWORD)-1;

MessagePending:
return PENDINGMSG_WAITDEFPROCESS;


Does anyone know any better?

vb.net syntax      dmex   |   Edit   |   Show History
<DllImport("ole32.dll", ExactSpelling:=True)> _
Public Shared Function CoRegisterMessageFilter(ByVal newFilter As IntPtr, ByRef oldMsgFilter As IntPtr) As Integer End Function
Flag as ContentBug
C# syntax      dmex   |   Edit   |   Show History
[DllImport("ole32.dll", ExactSpelling=true)]
public static extern int CoRegisterMessageFilter(IntPtr newFilter, ref IntPtr oldMsgFilter);
Tags What's this?: c# (x) Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker