Example #1
0
        private void PerformDispose()
        {
            if (_hHook != IntPtr.Zero)
            {
                // uninstall hook
                UnhookWindowsHookEx(_hHook);
                _hHook = IntPtr.Zero;
            }

            _hookCallback = null;
        }
Example #2
0
		private void PerformDispose()
		{
			if (_hHook != IntPtr.Zero)
			{
				// uninstall hook
				UnhookWindowsHookEx(_hHook);
				_hHook = IntPtr.Zero;
			}

			_hookCallback = null;
		}
Example #3
0
        /// <summary>
        /// Initializes a new instance of <see cref="CommonDialogHook"/>. Don't forget to <see cref="Dispose"/> it!
        /// </summary>
        public CommonDialogHook()
        {
            const int WH_CALLWNDPROCRET = 12;

#pragma warning disable 618,612
            // we have to use the unmanaged thread ID, and it should remain stable for the short lifetime of this hook anyway
            var unmanagedThreadId = AppDomain.GetCurrentThreadId();
#pragma warning restore 618,612

            _hookCallback = new CallWndRetProc(WndProcRetCallback);                                             // must be written this way to ensure the delegate instance does not go out of scope early
            _hHook        = SetWindowsHookEx(WH_CALLWNDPROCRET, _hookCallback, IntPtr.Zero, unmanagedThreadId); // install WndProcRet hook
        }
Example #4
0
		/// <summary>
		/// Initializes a new instance of <see cref="CommonDialogHook"/>. Don't forget to <see cref="Dispose"/> it!
		/// </summary>
		public CommonDialogHook()
		{
			const int WH_CALLWNDPROCRET = 12;

#pragma warning disable 618,612
			// we have to use the unmanaged thread ID, and it should remain stable for the short lifetime of this hook anyway
			var unmanagedThreadId = AppDomain.GetCurrentThreadId();
#pragma warning restore 618,612

			_hookCallback = new CallWndRetProc(WndProcRetCallback); // must be written this way to ensure the delegate instance does not go out of scope early
			_hHook = SetWindowsHookEx(WH_CALLWNDPROCRET, _hookCallback, IntPtr.Zero, unmanagedThreadId); // install WndProcRet hook
		}
Example #5
0
 private static extern IntPtr SetWindowsHookEx(int hookType, CallWndRetProc lpfn, IntPtr hMod, int dwThreadId);
Example #6
0
		private static extern IntPtr SetWindowsHookEx(int hookType, CallWndRetProc lpfn, IntPtr hMod, int dwThreadId);