锁屏,在Windows Mobile下,我是采取模拟按键操作实现的:
public class SystemCall
{
public const byte VK_NONAME = 0xFC;
public const byte VK_ESC = 0x1B;
public const byte VK_F4 = 0x73;
public const byte VK_APP6 = 0xC6;
public const byte VK_F22 = 0x85;
public const byte VK_F16 = 0x7F;
public const byte VK_OFF = 0x7F;
public static void SendKey(byte key)
{
const int KEYEVENTF_KEYUP = 0x02;
const int KEYEVENTF_KEYDOWN = 0x00;
keybd_event(key, 0, KEYEVENTF_KEYDOWN, 0);
keybd_event(key, 0, KEYEVENTF_KEYUP, 0);
}
[DllImport("CoreDll.dll", SetLastError = true)]
private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
}
锁定屏幕:
SystemCall.SendKey(SystemCall.VK_F22);