コード例 #1
0
        protected override void OnClosed(EventArgs e)
        {
            if (_getMsgHook != null)
            {
                _getMsgHook.Stop();
            }

            if (_shellHook != null)
            {
                _shellHook.Stop();
            }

            if (_cbtHook != null)
            {
                _cbtHook.Stop();
            }

            if (_windows != null)
            {
                foreach (Window window in _windows)
                {
                    window.Dispose();
                }
            }

            Window.ForceAllMessageLoopsToWakeUp();

#if WIN32
            if (_systemTrayMenu != null)
            {
                _systemTrayMenu.Icon.Visible = false;
            }

            if (Environment.Is64BitOperatingSystem && _64BitProcess != null && !_64BitProcess.HasExited)
            {
                foreach (var handle in _64BitProcess.GetWindowHandles())
                {
                    NativeMethods.PostMessage(handle, NativeConstants.WM_CLOSE, 0, 0);
                }

                if (!_64BitProcess.WaitForExit(5000))
                {
                    _64BitProcess.Kill();
                }

                try
                {
                    File.Delete(_64BitProcess.StartInfo.FileName);
                }
                catch
                {
                }
            }
#endif
            base.OnClosed(e);
        }
コード例 #2
0
        protected override void OnClosed(EventArgs e)
        {
            _callWndProcHook?.Stop();
            SendNotifyMessage((IntPtr)HWND_BROADCAST, WM_NULL, 0, 0);
            _getMsgHook?.Stop();
            SendNotifyMessage((IntPtr)HWND_BROADCAST, WM_NULL, 0, 0);
            _shellHook?.Stop();
            SendNotifyMessage((IntPtr)HWND_BROADCAST, WM_NULL, 0, 0);
            _cbtHook?.Stop();
            SendNotifyMessage((IntPtr)HWND_BROADCAST, WM_NULL, 0, 0);

            if (_windows != null)
            {
                foreach (Window window in _windows)
                {
                    window.Dispose();
                }
            }

            WindowUtils.ForceAllMessageLoopsToWakeUp();

#if WIN32
            _systemTrayMenu?.Dispose();
            _hotKeyHook?.Dispose();

            if (Environment.Is64BitOperatingSystem && _64BitProcess != null && !_64BitProcess.HasExited)
            {
                foreach (var handle in _64BitProcess.GetWindowHandles())
                {
                    PostMessage(handle, WM_CLOSE, 0, 0);
                }

                if (!_64BitProcess.WaitForExit(5000))
                {
                    _64BitProcess.Kill();
                }

                try
                {
                    File.Delete(_64BitProcess.StartInfo.FileName);
                }
                catch
                {
                }
            }
#endif
            base.OnClosed(e);
            SendNotifyMessage((IntPtr)HWND_BROADCAST, WM_NULL, 0, 0);
        }
コード例 #3
0
        protected override void OnClosed(EventArgs e)
        {
            if (_getMsgHook != null)
            {
                _getMsgHook.Stop();
            }
            if (_shellHook != null)
            {
                _shellHook.Stop();
            }
            if (_cbtHook != null)
            {
                _cbtHook.Stop();
            }
            if (_windows != null)
            {
                foreach (Window window in _windows)
                {
                    window.Dispose();
                }
            }

            Window.ForceAllMessageLoopsToWakeUp();

#if WIN32
            if (_systemTrayMenu != null)
            {
                _systemTrayMenu.Icon.Visible = false;
            }

            if (Environment.Is64BitOperatingSystem && _64BitProcess != null && !_64BitProcess.HasExited)
            {
                Window.CloseAllWindowsOfProcess(_64BitProcess.Id);
                if (!_64BitProcess.WaitForExit(5000))
                {
                    _64BitProcess.Kill();
                }
                try
                {
                    File.Delete(_64BitProcess.StartInfo.FileName);
                }
                catch
                {
                }
            }
#endif
            base.OnClosed(e);
        }