|
|
 |
當前的位置 >> 返回首頁 >> 營銷方案 |
 |
軟件開發(fā)實現(xiàn)自動鎖屏和關(guān)屏 |
 |
發(fā)布者:西安軟件公司 發(fā)布時間:2019/2/27 閱讀:16次 |
 |
西安軟件開發(fā)實現(xiàn)鎖屏代碼 public Form1( bool aLock ) { if (aLock) { //鎖屏+關(guān)屏 LockWorkStation(); SendMessage( this.Handle, (uint)0x0112, (IntPtr)0xF170, (IntPtr)2 ); } else { //禁止鼠標鍵盤動作+關(guān)屏 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 ); } //關(guān)屏 [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();
|
|