[转载]模拟ctrl+alt+delete三键解锁server端
2007-08-18 21:23
471 查看
信息来源:www.zahui.com
在我们编写远程控制软件的时候,我们会发现要想解锁server端我们就得发送这三个键的虚拟。
下面我说一下解决过程
1.一开始,决定通过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);
发现只能模拟ctrl+alt两个键的效果,然而其他的两个键的都可以模拟比如win+d。不知道是不是keybd_event()只能模拟两键还是因为
ctrl+alt+delete的特殊性,望高手告之,在此谢过。
2.运用PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL, VK_DELETE));来发送虚拟键盘,但是在winNT以后的系统里我们还有很多事情要做,比如:OpenDesktop()、OpenInputDesktop()、GetThreadDesktop()、SetThreadDesktop()、CloseDesktop()、GetUserObjectInformation()
代码如下:
#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;
return TRUE;
}
偶一开始试验了发现不成功,后来冰河大哥告诉我说OpenDesktop("Winlogon", ......)本身需要LocalSystem权限,
果然如此,把它注册成服务,然后效果实现。相信如何注册成服务不用我说了吧。ok,我们想要的功能实现了。
3.还有一种方法
Dos下键盘的完全控制 ------- 一系列的BIOS级别的键盘控制函数!
http://dev.csdn.net/develop/article/7/7181.shtm
我没有试验,不知道可否,哪位大哥试验后告诉我一声
相关文章推荐
- 模拟ctrl+alt+delete三键
- 模拟ctrl+alt+delete三键
- server 2008R2所有加入域的计算机不需要按录所有加入域的计算机不需要按ctrl+ALT+DELETE登录
- Windows vista以上模拟Alt Ctrl Delete
- windows 2003 Server 如何禁用启动时 ctrl+alt+delete/关机时原因查询?
- 模拟ctrl+alt+delete三键解锁server端
- 把开机时Ctrl+Alt+Delete取消掉了
- Windows 7 设定使用者登入前先按 Ctrl-Alt-Delete
- C++程序屏蔽windows2008系统安全界面(ctrl+alt+delete热键)
- window基础-1:win7开机按ctrl+alt+delete启动
- Mac虚拟机怎么打开 ctrl+alt+delete
- 如何解决取消win7登录时显示“ctrl+alt+delete"的问题
- Win上按Ctrl+Alt+Delete可调出任务管理器,Mac呢?
- 域用户登陆时总要先按Ctrl+Alt+Delete的问题也适用2000,2003系统
- linux中禁用Ctrl+Alt+Delete的配置方法
- C++程序屏蔽常规按键(ctrl+alt+delete除外)
- 【❤《键盘上Alt,Ctrl,Shift,Delete,Home,End,Backspace,Tab,~,+,Insert的特殊用途……》❤】
- Linux下屏蔽Ctrl+Alt+Delete
- 如何: 在Windows2000中动态禁用/启用Ctrl-Alt-Delete
- WIN2003 取消开机Ctrl+Alt+Delete And 取消关机跟踪提示及启动不用密码