|
|
 |
當前的位置 >> 返回首頁 >> 營銷方案 |
 |
軟件開發實現自動鎖屏和關屏 |
 |
發布者:西安軟件公司 發布時間:2019/2/27 閱讀:10次 |
 |
西安軟件開發實現鎖屏代碼 public Form1( bool aLock ) { if (aLock) { //鎖屏+關屏 LockWorkStation(); SendMessage( this.Handle, (uint)0x0112, (IntPtr)0xF170, (IntPtr)2 ); } else { //禁止鼠標鍵盤動作+關屏 BlockInput( true ); System.Threading.Thread.Sleep( 10 ); SendMessage( this.Handle, (uint)0x0112, (IntPtr)0xF170, (IntPtr)2 ); BlockInput( false ); } this.Close(); //Application.Exit(); Environment.Exit( 0 ); } //關屏 [DllImport( "user32.dll", CharSet = CharSet.Auto )] static extern IntPtr SendMessage( IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam ); //禁止鼠標鍵盤動作 [return: MarshalAs( UnmanagedType.Bool )] [DllImport( "user32.dll", CharSet = CharSet.Auto, ExactSpelling = true )] public static extern bool BlockInput( [In, MarshalAs( UnmanagedType.Bool )] bool fBlockIt ); //鎖屏 [DllImport( "user32.dll" )] public static extern bool LockWorkStation();
|
|