我很菜!在没有Wake UP,Sleep,Power的键盘上如何实现它们,谢谢!
现在看《Windows程序设计》到第六章。我的键盘多媒体是没有Wake UP,Sleep,Power键。另外多了几个多媒体键用第六章的KEYVIEW1显示为173,174,175。我想把它们设成Wake UP,Sleep,Power键。Message    Key        RepeatWake Up    255    1     99    yes no 
Sleep      95     1     95    yes no
Power      255    1     94    yes no用别人的键盘Wake UP,Sleep,Power有用。给点思路!LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{  
case WM_KEYDOWN:
   switch (wParam)
   {
      case 174:
        SetSystemPowerState(FALSE,TRUE);//没有待机,能具体点吗!
//谢谢!

解决方案 »

  1.   

    try send WM_POWERBROADCAST message, read MSDN for more
    Info, read also on SetSystemPowerState(...)...
      

  2.   

    keybd_event(0x5f,0,0,0);
    keybd_event(0x5f,0,KEYEVENTF_KEYUP,0);
    这样不可以吗?
      

  3.   

    换个有Wake UP,Sleep,Power键的键盘,试试可以吗?可能电源没有设置
      

  4.   

    keybd_event(0x5f,0,0,0);
    keybd_event(0x5f,0,KEYEVENTF_KEYUP,0);
    待不了机???换了别人的键盘可以待机和关机!!!!!!!程序如下:LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {    
         HDC         hdc ;
         PAINTSTRUCT ps ;
         RECT        rect;
     MCIERROR    error;     switch (message)
         {
           case WM_KEYDOWN:
              switch (wParam)
              {
                 //可以开光驱!
        case 167:
                error = mciSendString( "set cdaudio door open", NULL, 0, NULL);
        //"set cdaudio door open"
        break;
                
      case 166:
                error = mciSendString( "set cdaudio door closed", NULL, 0, NULL);
               //"set cdaudio door open"
        break;
        //可以开网页!
        case 175:
    ShellExecute(NULL, "open", "http://www.163.com", NULL,NULL,SW_SHOWNORMAL); break;         //待不了机???
    case 174: SetSystemPowerState(FALSE,TRUE );
             keybd_event(0x5f,0,KEYEVENTF_KEYUP,0);
    break;

    }
             return 0;
      

  5.   

    我用SendInput();   不知为何 Error!!!
    具体还不知怎么用 !Compiling...
    hello.cpp
    D:\VC++6.0\WinAPI\-2003-1-19\hello\hello.cpp(102) : error C2065: 'SendInput' : undeclared identifier
    Error executing cl.exe.不明白为什么没定义。
    #include <winuser.h>    //我加了
    User32.lib              //我加了
      

  6.   

    you should define _WIN32_WINNT 0x0500
    see 
    http://expert.csdn.net/Expert/topic/1613/1613033.xml?temp=.7814295
      

  7.   

    INPUT in;
         KEYBDINPUT kbdIn;  
          memset(&in,0,sizeof(INPUT));  
          memset(&kbdIn,0,sizeof(KEYBDINPUT));    
           UINT nInputs = 1;  
          int size = sizeof(INPUT);   
          in.type = INPUT_KEYBOARD;  
          kbdIn.dwFlags = KEYEVENTF_KEYUP;      kbdIn.wVk = 0x5f;
          in.ki = kbdIn;   
         switch (message)
         {
            case WM_KEYDOWN:
              switch (wParam)
              {
                  case 174:    
                   SendInput(1,&in,size);
     
            break;
    都试过,还是待不了机。能否具体点。谢谢!