• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >vc/mfc > 判断目前操作系统版本的变量_WIN32_WINNT的值应被定义为多少是WINDOWXP

判断目前操作系统版本的变量_WIN32_WINNT的值应被定义为多少是WINDOWXP

作者:佚名 字体:[增加 减小] 来源:互联网 时间:2017-06-04

佚名通过本文主要向大家介绍了 判断目前操作系统版本的变量_WIN32_WINNT的值应被定义为多少是WINDOWXP等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 判断目前操作系统版本的变量 _WIN32_WINNT的值应被定义为多少 是 WINDOW XP
描述:

UP


解决方案1:

我这里有一个程序,你参考一下!
获得版本信息
void COsInfoDlg::CheckOSVersion ()
{
int stat = 0;
char buffer[20];
TCHAR data [64];
DWORD dataSize;
DWORD win95Info;
OSVERSIONINFO versionInfo;
HKEY hKey;
LONG result;
//设定OSVERSIONINFO的大小
versionInfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
// 获得版本信息
if (!::GetVersionEx (&versionInfo)) {
m_stInfo = (_T ("Not able to get OS information"));
return;
}
// 如果是NT,检查是Server还是WorkStation
if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) 
{
m_stInfo =  (_T ("Windows NT"));
dataSize = sizeof (data);
//打开注册表
result = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE,
"System\\CurrentControlSet\\Control\\ProductOptions",
0, KEY_QUERY_VALUE, &hKey);
if (result != ERROR_SUCCESS)
{
SetLastError (result);
return;
}
result = ::RegQueryValueEx (hKey, _T("ProductType"), NULL, NULL,
(LPBYTE) data, &dataSize);
//关闭注册表
RegCloseKey (hKey);
if (result != ERROR_SUCCESS) {
SetLastError (result);
return;
}
if (lstrcmpi (data, "WinNT") == 0) {
m_stInfo = _T ("Windows NT Workstation");
}
else if (lstrcmpi (data, "ServerNT") == 0) {
m_stInfo = _T ("Windows NT Server");
}
else {
m_stInfo = _T ("Windows NT Server - Domain Controller");
}
// 检查版本号
if (versionInfo.dwMajorVersion == 3 || versionInfo.dwMinorVersion == 51) {
m_stMinorVer = _T ("3.51");
}
else {
m_stMinorVer = _T ("4.0");
}
// 获得 build number.
_itoa( versionInfo.dwBuildNumber, buffer, 10 );
m_stBuildNumber = CString (buffer);
}
else if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
m_stInfo = _T ("Windows 95");
if ((versionInfo.dwMajorVersion > 4) || ((versionInfo.dwMajorVersion == 4)
&& (versionInfo.dwMinorVersion > 0))) {
m_stInfo = _T ("Windows 98");
}
//对win95,build number是低字节
win95Info = (DWORD)(LOBYTE(LOWORD(versionInfo.dwBuildNumber)));
_itoa( win95Info, buffer, 10 );
m_stBuildNumber = CString (buffer);
}
else {
m_stInfo = _T ("Windows 3.1");
}
// 获得service pack信息
m_stServPack = CString (versionInfo.szCSDVersion);
m_stServPack.FreeExtra ();
}

解决方案2:

Using the SDK Headers
This version of the Microsoft® Platform SDK enables you to create applications that run on Microsoft Windows® 95, Microsoft Windows NT® 4.0, Windows® 98, Windows Millennium Edition (Windows Me), Windows 2000, Windows XP, and Windows .NET Server 2003 family. You can also create 64-bit applications. The header files use data types that allow you to build both 32- and 64-bit versions of your application from a single source code base. For more information, see Getting Ready for 64-bit Windows.
Microsoft® Visual C++® includes content from the edition of the Platform SDK that was current at the time Visual C++ was released. Therefore, if you install the latest Platform SDK, you may end up with multiple versions of the same header files on your computer. To ensure that you are using the latest version of the SDK header files, follow the directions included in Installing the Platform SDK with Visual Studio. Otherwise, you will receive the following error when compiling code that uses features that were introduced after Visual C++ was released: error C2065: undeclared identifier.
Certain functions that depend on a particular version of Windows are declared using conditional code. This enables you to use the compiler to detect whether your application uses functions that are not supported on its target version(s) of Windows. To compile an application that uses these functions, you must define the appropriate macros. Otherwise, you will receive the C2065 error message. The following table indicates the macros you must define to target each system.
Minimum system required Macros to define 
Windows .NET Server 2003 family _WIN32_WINNT>=0x0502 
Windows XP _WIN32_WINNT>=0x0501 
Windows 2000 _WIN32_WINNT>=0x0500 
Windows NT 4.0 _WIN32_WINNT>=0x0400 
Windows Me _WIN32_WINDOWS=0x0490 
Windows 98 _WIN32_WINDOWS>=0x0410 
Internet Explorer 6.0 _WIN32_IE>=0x0600 
Internet Explorer 5.01, 5.5 _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 
For example, to use the features specifically marked for Windows 2000 in the header files, you need to explicitly define _WIN32_WINNT as 0x0500 or greater. You can define the symbols using the #define statement in each source

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

相关文章

  • 2017-06-05 lua调用dll过程中出现的问题
  • 2017-06-05 activex控件对鼠标按键的响应,传到子控件CTreeCtrl问题
  • 2017-06-05 控件中两个对话框传值失败???
  • 2017-06-04 OCX在网页上面怎么显示Tooltip?
  • 2017-06-04 关于VC下Activex
  • 2017-06-04 求助,COM里的类能怎么使用构造函数
  • 2017-06-04 _bstr_t类型的数据如何转化成long类型?
  • 2017-06-05 关于调用IWebBrowser2不能打印网页的问题
  • 2017-06-05 ---到底用的什么函数绘制?
  • 2017-06-04 RegisterEventHandler怎么用的?

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 技术问题!急,up有分~~~~~~~~~~~也想知道的帮我顶
    • LPDISPATCH到底指向什么?是函数地址吗?
    • ATL对话框的透明度-setwindowlong
    • 如何获取web页面上mediaplayer的数据
    • VC调用EXCEL程序后,如何发布到无EXCEL环境中!
    • 使用ATL向导向现有的MFC的MDI工程中添加COM接口,为什么很多MFC的函数不好用了?
    • 如何在DLL中使用ActiveX控件
    • 事务问题-我在COMVC++一个接口中打开两个数据库,系统提示远程系统事务不可用---向高手求助!!
    • NSISWin7注册DLL的问题
    • 一些关于ATL的宏的问题。

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有