Rick C. Hodgin
Rick C. Hodgin

Reputation: 503

Is there a way to query if a message filter is already in effect?

Due to enhanced security requirements, in order to use the WM_COPYDATA message in modern versions of Windows you need to first call the ChangeWindowMessageFilter() function to MSGFLT_ADD it to the filter allowance.

See MSDN ChangeWindowMessageFilter()

Is there a way to query if it already is allowed (without using SendMessage() or PostMessage() to wait and see if it comes through)?

Upvotes: 1

Views: 172

Answers (1)

WilliamClements
WilliamClements

Reputation: 350

The answer is yes. I researched it on MSDN.

Use ChangeWindowMessageFilterEx instead of ChangeWindowMessageFilter, which is due to be deprecated anyway. Pass in pChangeFilterStruct to contain extended result. See https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-changefilterstruct

See if ExtStatus contains the value MSGFLTINFO_ALREADYALLOWED_FORWND

Upvotes: 3

Related Questions