| 
 
 签到天数: 473 天 连续签到: 1 天 [LV.9]Lyoko 黄金勇士 - UID
 - 107 
 - 经验点数
 - 1160 点 
 - 人气点数
 - 104 点 
 - 能量点数
 - 47 点 
 - 阅读权限
 - 1 
 - 在线时间
 - 525 小时 
 
  | 
嘛我也真是很久没逛论坛了,回来一下吧  就是想问一下怎么把键盘所按的按键的数值调出来用(int) 
看了很多例子,最接近的就是这个了 
 
 
 
 
#include "stdafx.h" 
#include <windows.h> 
#include <stdio.h> 
#include <iostream> 
using namespace std; 
HHOOK g_hKeyboard; 
 
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) 
{ 
 if (nCode >= 0) 
 { 
  PMSLLHOOKSTRUCT pmll = (PMSLLHOOKSTRUCT) lParam; 
 
  printf("msg: %lu, x:%ld, y:%ld\n", wParam, pmll->pt.x, pmll->pt.y); 
 
 } 
 
 return CallNextHookEx(g_hKeyboard, nCode, wParam, lParam); 
} 
int main(void) 
{ 
 MSG msg; 
 
 g_hKeyboard = SetWindowsHookEx( WH_KEYBOARD_LL, KeyboardProc, GetModuleHandle(NULL), 0 ); 
 if (!g_hKeyboard) printf("Hook error: %d\n", GetLastError()); 
 
while ( GetMessage(&msg, NULL, 0, 0) ) 
 { 
         TranslateMessage(&msg); 
         DispatchMessage(&msg); 
 } 
 
 UnhookWindowsHookEx(g_hKeyboard); 
 return (int) msg.wParam; 
} 
 
  
 
 
但是就是不知道怎么把key的数值换成int,想请各位高手提点一下 
 
 
 
附件:msdn 上对于这些数值的定义 
 
LRESULT   CALLBACK   KeyboardProc(   
    int   code,               //   hook   code   
    WPARAM   wParam,     //   virtual-key   code   
    LPARAM   lParam       //   keystroke-message   information   
);   
wParam     
[in]   Specifies   the   virtual-key   code   of   the   key   that   generated   the   keystroke   message.     
lParam     
[in]   Specifies   the   repeat   count,   scan   code,   extended-key   flag,   context   code,   previous   key-state   flag,   and   transition-state   flag.   This   parameter   can   be   one   or   more   of   the   following   values   
 |   
 
 
 
 |