When we write remote control software, we will find that we have to unlock the Server side. We have to send these three keys.
Let me talk about the process
1. At first, decide to simulate the keyboard through keybd_event ()
keybd_event (VK_CONTROL, MapVirtualKey (VK_CONTROL, 0), 0,0); keybd_event (VK_MENU, MapVirtualKey (VK_MENU, 0), 0,0); keybd_event (VK_DELETE, MapVirtualKey (VK_DELETE, 0), 0,0); keybd_event ( VK_DELETE, MapVirtualKey (VK_DELETE, 0), KEYEVENTF_KEYUP, 0); keybd_event (VK_MENU, MapVirtualKey (VK_MENU, 0), KEYEVENTF_KEYUP, 0); keybd_event (VK_CONTROL, MapVirtualKey (VK_CONTROL, 0), KEYEVENTF_KEYUP, 0); and found only analog Ctrl Alt effects, however, the other two keys can simulate such as WIN D. I don't know if KeyBD_Event () can only simulate two keys or because of the special nature of Ctrl Alt Delete, it is visible here.
2. Apply PostMessage (hwnd_broadcast, wm_hotKey, 0, Makelong (MOD_ALT |)); to send a virtual keyboard, but we still have a lot of things in the system after Winnt, such as: OpenDesktop (), OpenInputDesktop () GetthreadDesktop (), setthreadDesktop (), Closedesktop (), getUserObjectInformation ()
code show as below:
#include "windows.h" BOOL simulateAltControlDel (); void main () {simulateAltControlDel ();} BOOL simulateAltControlDel () {HDESK hdeskCurrent; HDESK hdesk; HWINSTA hwinstaCurrent; HWINSTA hwinsta; // // Save the current Window station // hwinstaCurrent = GetProcessWindowStation (); if (hwinstaCurrent == NULL) return FALSE; // // Save the current desktop // hdeskCurrent = GetThreadDesktop (GetCurrentThreadId ()); if (hdeskCurrent == NULL) return FALSE; // // Obtain a handle to WinSta0 - service must be running // in the LocalSystem account // hwinsta = OpenWindowStation ( "winsta0", FALSE, WINSTA_ACCESSCLIPBOARD | WINSTA_ACCESSGLOBALATOMS | WINSTA_CREATEDESKTOP | WINSTA_ENUMDESKTOPS | WINSTA_ENUMERATE | WINSTA_EXITWINDOWS | WINSTA_READATTRIBUTES | WINSTA_READSCREEN | WINSTA_WRITEATTRIBUTES); if (hwinsta == NULL) return FALSE; // // Set the windowstation to be winsta0 // if (SetProcessWindowStation (hwinsta!)) Return FALSE;
// // Get the default desktop on winsta0 // hdesk = OpenDesktop ( "Winlogon", 0, FALSE, DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL | DESKTOP_JOURNALPLAYBACK | DESKTOP_JOURNALRECORD | DESKTOP_READOBJECTS | DESKTOP_SWITCHDESKTOP | DESKTOP_WRITEOBJECTS); if (hdesk == NULL) Return false; // // set the desktop to be "default" // if (! setthreadDesktop (hdesk)) Return False; PostMessage (hwnd_broadcast, wm_hotkey, 0, makelparam (mod_alt | mod_control, vk_delete));
//// RESET The window station and desktop // if (! SetProcessWindowStation (hwinstacurrent) Return False;
IF (! setthreadDesktop (hdeskcurrent) Return False;
/// Close the windowStation and desktop handles // if (! CloseWindowStation (hwinsta)) Return False; if (! CloseDesktop (HDESK)) Return False;}
Even start trials, I found unsuccessful, and later the Glacier brother told me that OpenDesktop ("Winlogon", ...) itself requires localsystem permissions, and then registers it into a service, then the effect is achieved. I believe how to register into a service, don't use me. OK, what we want is implemented.
3. There is also a method of full control of DOS down keyboard ------ a series of BIOS level keyboard control functions! I have no trial, I don't know if, which big brother tells me after the test.
Thank Hu Xin, big brother! !