_ChangeWindowMessageFilterEx() private method

private _ChangeWindowMessageFilterEx ( IntPtr hwnd, WM message, MSGFLT action, [ pChangeFilterStruct ) : bool
hwnd System.IntPtr
message WM
action MSGFLT
pChangeFilterStruct [
return bool
Beispiel #1
0
        public static HRESULT ChangeWindowMessageFilterEx(IntPtr hwnd, WM message, MSGFLT action, out MSGFLTINFO filterInfo)
        {
            filterInfo = MSGFLTINFO.NONE;

            if (!Utility.IsOSVistaOrNewer)
            {
                return(HRESULT.S_FALSE);
            }
            if (!Utility.IsOSWindows7OrNewer)
            {
                if (!NativeMethods._ChangeWindowMessageFilter(message, action))
                {
                    return((HRESULT)Win32Error.GetLastError());
                }
                return(HRESULT.S_OK);
            }
            else
            {
                CHANGEFILTERSTRUCT changefilterstruct = new CHANGEFILTERSTRUCT
                {
                    cbSize = (uint)Marshal.SizeOf(typeof(CHANGEFILTERSTRUCT))
                };
                if (!NativeMethods._ChangeWindowMessageFilterEx(hwnd, message, action, ref changefilterstruct))
                {
                    return((HRESULT)Win32Error.GetLastError());
                }
                filterInfo = changefilterstruct.ExtStatus;
                return(HRESULT.S_OK);
            }
        }