在第四章输出文字的那个sysmets1.c/.h,我运行了一下,出现了以下错误
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(258) : error C2065: 'SM_MOUSEWHEELPRESENT' : undeclared identifier
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(258) : error C2099: initializer is not a constant
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(258) : warning C4047: 'initializing' : 'int ' differs in levels of indirection from 'char [21]'
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(259) : error C2065: 'SM_XVIRTUALSCREEN' : undeclared identifier
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(259) : error C2099: initializer is not a constant
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(259) : warning C4047: 'initializing' : 'int ' differs in levels of indirection from 'char [24]'
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(261) : error C2065: 'SM_YVIRTUALSCREEN' : undeclared identifier
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(261) : error C2099: initializer is not a constant
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(263) : error C2065: 'SM_CXVIRTUALSCREEN' : undeclared identifier
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(263) : error C2099: initializer is not a constant
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(263) : warning C4047: 'initializing' : 'int ' differs in levels of indirection from 'char [19]'
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(265) : error C2065: 'SM_CYVIRTUALSCREEN' : undeclared identifier
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(265) : error C2099: initializer is not a constant
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(265) : warning C4047: 'initializing' : 'int ' differs in levels of indirection from 'char [22]'
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(267) : error C2065: 'SM_CMONITORS' : undeclared identifier
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(267) : error C2099: initializer is not a constant
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(269) : error C2065: 'SM_SAMEDISPLAYFORMAT' : undeclared identifier
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(269) : error C2099: initializer is not a constant
f:\sw\c_cpp\cpp\windows_prog\sysmets1\sysmets1.h(269) : warning C4047: 'initializing' : 'int ' differs in levels of indirection from 'char [21]'
Error executing cl.exe.我首先查了一下MSDN,发现这几个flag都是有的,而且拼写也没错
我直接在出错的SM_**上go to definition,但是没出现WINUSER.h
在没提示出错的SM_**上这样操作却出现了定义宏
于是我看了一下#IFNDEF等条件编译,发现了它有条件限制,即WINVER现在的问题是: (1)大家运行这个代码时有错吗?运行时是不是要配置一下?我用VC6.0
             (2)是不是直接在WINUSER.h中修改WINVER呢?还是GUI中有配置?或者不是这种解决思路
  我是VC新手,大家帮帮忙,谢谢了
             

解决方案 »

  1.   

    缺少定义的头文件,查下MSDN 看需要什么头文件就行了
      

  2.   

    我查了,就是一个user32.h,已经包含了但也发现了报错的标号的meaing前都有粗体的Windows 98/Me, Windows 2000/XP:不知道有什么不同?
      

  3.   

    不是缺头文件,是因为WINVER太低了,前面加一个#define   WINVER 0x0500试试,不行的话,可能还要改_WIN32_WINNT宏定义     
      

  4.   

    3楼 这个我试过,不行4楼 VC++ 6.0 sp6
      

  5.   

    文件最前面(#include <windows.h>之前)加上:
    #define WINVER 0x0500
      

  6.   

    在stdafx.h中最前面添加
    #define WINVER 0x0500如果还不行去微软下载新的SDK安装下
      

  7.   

    要不就直接修改winuser.h文件中的WINVER
      

  8.   

    我记得以前碰到过的,好像在   StdAfx.h   里加上下面几句   
      #ifdef   WINVER   
      #undef   WINVER   
      #endif   
        
      #define   WINVER   0x0500   
    就行了。
      

  9.   

    回6楼 你这样可以了我之前是将其放在#include "sysmetcs1.h"前/后,都出现重复定义错误提示,为什么放在那里就可以了呢?
    WINVER这个常量究竟有什么用?可以指点一下吗?
      

  10.   

    目前我看到的是
    OTE: WINVER has been defined as 0x0500 or greater which enables
    Windows NT 5.0 and Windows 98 features. When these headers were released,
    Windows NT 5.0 beta 1 and Windows 98 beta 2.1 were the current versions.
    For this release when WINVER is defined as 0x0500 or greater, you can only
    build beta or test applications.
      

  11.   

    放在windows.h前,就是放在条件编译指令前,我知道了