|
|
|
当前的位置 >> 返回首页 >> 营销方案 |
|
软件开发实现自动锁屏和关屏 |
|
发布者:西安软件公司 发布时间:2019/2/27 阅读:16次 |
|
西安软件开发实现锁屏代码 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();
|
|