代码如下,请各位高人指点
keybd_event(MapVirtualKey(29,1),29,NULL,NULL); //control
keybd_event(MapVirtualKey(56,1),56,NULL,NULL); //alt
keybd_event(MapVirtualKey(83,1),83,NULL,NULL); //delkeybd_event(MapVirtualKey(29,1),29,KEYEVENTF_KEYUP,NULL); //control
keybd_event(MapVirtualKey(56,1),56,KEYEVENTF_KEYUP,NULL); //alt
keybd_event(MapVirtualKey(83,1),83,KEYEVENTF_KEYUP,NULL);                //del

解决方案 »

  1.   

    开始"的那个键的扫描码是什么 :VK_LWIN,VK_RWIN
      

  2.   

    说错了,VK_LWIN,VK_RWIN是虚拟键码,我的键盘上它们的扫描码是0x5B,0x5C。另外,调出任务管理器不用这么麻烦,直接启动它就是了
    ShellExecute(NULL, "open", "taskmgr.exe", NULL, "C:\\windows\\system32", SW_SHOWNORMAL);
      

  3.   

    是模拟Ctrl+Alt+Del吗?
    那么普通的Keybd_Event是不可以的,因为这个是一个系统级的热键。
    2k,xp下挺麻烦的,要用OpenDesktop等API对Winlogon这个桌面发送Ctrl+Alt+Del消息来实现,另外进程要作为服务来运行。
      

  4.   

    .运用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权限,
    把它注册成服务,然后效果实现。
      

  5.   

    每个键盘设置不一样吗,怎么才能在每个机器上都好使`````````用virtual key就一致了,scan code,不同键盘可能不一样
      

  6.   

    怎么找到virtual key,我看msdn了上面只有scan code
      

  7.   

    应该是没有scancode,有virtual key吧:
    这个链接:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/virtualkeycodes.asp