Esempio n. 1
0
        private IntPtr Main_Power_Hook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            // C# doesn't have definitions for power messages, so we'll get them via C++/CLI. It returns a
            // simple UInt16 that defines only the things we care about.
            var pmsg = PowerManagement.message(msg, wParam, lParam);

            if (pmsg == PowerManagementMessage.Suspend)
            {
                _mgr.suspend();
                handled = true;
            }
            else if (pmsg == PowerManagementMessage.Resume)
            {
                var vstate = _mgr.resume();

                if (vstate == ResumeVaultState.Locked)
                {
                    LockVault();
                }

                handled = true;
            }

            return(IntPtr.Zero);
        }