1 private const int sc_screensave = 0xf140 2 private const int wm_queryendsession = 0x0011 ; 3 private bool isscreensave = false 4 private bool iswindowstopclosing = false ;
variables
No nonsense, just paste the code, in the constructor
Public xx{
1 // 2 IntPtr hwnd = new Windowinterophelper (this ). Handle; 3 display the contents of WPF in the Win32 window 4 HwndSource src = Hwndsource.fromhwnd (HWND); 5 handler implementation for receiving window messages (based on System.Windows.Interop.HwndSourceHook delegate) 6 Src. Addhook (new HwndSourceHook (WndProc));
Register
}
1 /// <summary>2 ///re-WndProc3 /// </summary>4 /// <param name= "hwnd" >window Handle</param>5 /// <param name= "MSG" >Message ID</param>6 /// <param name= "WParam" >the WParam value of the message</param>7 /// <param name= "LParam" >the LParam value of the message</param>8 /// <param name= "handled" >A value that indicates whether the message has been processed. If the message is processed, set the value to true, otherwise set it to false</param>9 /// <returns></returns>Ten PrivateINTPTR WndProc (INTPTR hwnd,intMSG, IntPtr WParam, IntPtr LParam,ref BOOLhandled) One { A if(msg = =wm_queryendsession) - { - using(varWCF =Newkefuservicesclient ()) the { - WCF. Updateuserstate (Mainpanelwindow.clientserviceid, userstates.unline); - } - } + returnIntPtr.Zero; -}
capturing operating system shutdown events
. NET Technology Exchange Group 199281001. Welcome to join.