加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

INPUT 未声明的标识符

(2011-10-12 16:35:56)
标签:

input

_win32_winnt

未声明的标识符

分类: VC

今天用到了。INPUT 来实现键盘功能下边是代码

     //变量定义
     INPUT Input[2];
     ZeroMemory(Input,sizeof(Input));

     //设置变量
     Input[1].ki.dwFlags=KEYEVENTF_KEYUP;  
     Input[0].type=Input[1].type=INPUT_KEYBOARD;
     Input[0].ki.wVk=Input[1].ki.wVk=wViraulCode;

     //模拟输入
     SendInput(CountArray(Input),Input,sizeof(INPUT));

 

下边是MSDN的声明:

typedef struct tagINPUT {
  DWORD type;
  union {
    MOUSEINPUT mi;
    KEYBDINPUT ki;
    HARDWAREINPUT hi;
  };
} INPUT, *PINPUT, FAR* LPINPUT;

 

可是在我的机器上怎么也编译不过。我加一下头文件也不行。

Requirements

OS Versions: Windows CE 2.0 and later.
Header: Winuser.h.

 

只是看到OS版本要WIN CE 2.0 以及以后的版本。根本没想到在头文件中当前的OS版本

查了下MSDN里 _WIN32_WINNT 的定义后

Minimum system required Macros to define
Windows Server 2008 NTDDI_VERSION >= NTDDI_LONGHORN
Windows Vista NTDDI_VERSION >= NTDDI_VISTA
Windows Server 2003 SP1 NTDDI_VERSION >= NTDDI_WS03SP1
Windows Server 2003 NTDDI_VERSION >= NTDDI_WS03
Windows XP SP2 NTDDI_VERSION >= NTDDI_WINXPSP2
Windows XP SP1 NTDDI_VERSION >= NTDDI_WINXPSP1
Windows XP NTDDI_VERSION >= NTDDI_WINXP
Windows 2000 SP4 NTDDI_VERSION >= NTDDI_WIN2KSP4
Windows 2000 SP3 NTDDI_VERSION >= NTDDI_WIN2KSP3
Windows 2000 SP2 NTDDI_VERSION >= NTDDI_WIN2KSP2
Windows 2000 SP1 NTDDI_VERSION >= NTDDI_WIN2KSP1
Windows 2000 NTDDI_VERSION >= NTDDI_WIN2K

M

inimum system required

Macros to define
Windows Server 2008 _WIN32_WINNT>=0x0600

WINVER>=0x0600

Windows Vista _WIN32_WINNT>=0x0600

WINVER>=0x0600

Windows Server 2003 _WIN32_WINNT>=0x0502

WINVER>=0x0502

Windows XP _WIN32_WINNT>=0x0501

WINVER>=0x0501

Windows 2000 _WIN32_WINNT>=0x0500

WINVER>=0x0500

Windows NT 4.0 _WIN32_WINNT>=0x0400

WINVER>=0x0400

Windows Me _WIN32_WINDOWS=0x0500

WINVER>=0x0500

Windows 98 _WIN32_WINDOWS>=0x0410

WINVER>=0x0410

Windows 95 _WIN32_WINDOWS>=0x0400

WINVER>=0x0400

Internet Explorer 7.0 _WIN32_IE>=0x0700
Internet Explorer 6.0 SP2 _WIN32_IE>=0x0603
Internet Explorer 6.0 SP1 _WIN32_IE>=0x0601
Internet Explorer 6.0 _WIN32_IE>=0x0600
Internet Explorer 5.5 _WIN32_IE>=0x0550
Internet Explorer 5.01 _WIN32_IE>=0x0501
Internet Explorer 5.0, 5.0a, 5.0b _WIN32_IE>=0x0500
Internet Explorer 4.01 _WIN32_IE>=0x0401
Internet Explorer 4.0 _WIN32_IE>=0x0400
Internet Explorer 3.0, 3.01, 3.02 _WIN32_IE>=0x0300

 

 

我又到 项目里stdafs.h头文件里看了下。。我的OS版本定义是:

#ifndef WINVER    // 允许使用特定于 Windows 95 和 Windows NT 4 或更高版本的功能。
#define WINVER 0x0400  // 将此更改为针对于 Windows 98 和 Windows 2000 或更高版本的合适的值。
#endif

#ifndef _WIN32_WINNT  // 允许使用特定于 Windows NT 4 或更高版本的功能。
#define _WIN32_WINNT 0x0400 // 将此更改为针对于 Windows 2000 或更高版本的合适的值。
#endif 

 

我的是  _WIN32_WINNT 是 0x0400  它支持的只有 Windows NT 4.0 一下的版本。

 

 

所以我把它改成以下:

#ifndef WINVER    // 允许使用特定于 Windows 95 和 Windows NT 4 或更高版本的功能。
#define WINVER 0x0500  // 将此更改为针对于 Windows 98 和 Windows 2000 或更高版本的合适的值。
#endif

#ifndef _WIN32_WINNT  // 允许使用特定于 Windows NT 4 或更高版本的功能。
#define _WIN32_WINNT 0x0500 // 将此更改为针对于 Windows 2000 或更高版本的合适的值。
#endif 

 

 

所有问题解决了。

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有