请教vc中如何判断操作系统是win9x还是win2000

jakieliu 2001-11-28 12:50:42
请教vc中如何判断操作系统是win9x还是win2000
...全文
89 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
我不是大明 2002-01-26
  • 打赏
  • 举报
回复
yeah!
jakieliu 2002-01-26
  • 打赏
  • 举报
回复
给分了!
qiwei 2001-11-28
  • 打赏
  • 举报
回复
GetVersion 与 GetVersionEx 都可以!
leepiaoping 2001-11-28
  • 打赏
  • 举报
回复
可以通过Windows API函数GetVersionEx来获得
masterlee 2001-11-28
  • 打赏
  • 举报
回复

Platform SDK: Windows System Information
GetVersion
The GetVersion function returns the current version number of the operating system.

Note This function has been superseded by GetVersionEx. New applications should use GetVersionEx or VerifyVersionInfo.

DWORD GetVersion(VOID);
Parameters
This function has no parameters.

Return Values
If the function succeeds, the return value is a DWORD value that contains the major and minor version numbers of the operating system in the low order word, and information about the operating system platform in the high order word.

For all platforms, the low order word contains the version number of the operating system. The low-order byte of this word specifies the major version number, in hexadecimal notation. The high-order byte specifies the minor version (revision) number, in hexadecimal notation.

To distinguish between operating system platforms, use the high order bit and the low order byte, as shown in the following table:

Platform High-order bit Next 7 bits Low-order byte
Windows NT 3.51 0 Build number 3
Windows NT 4.0 0 Build number 4
Windows 2000 or Whistler 0 Build number 5
Windows 95, Windows 98, or Windows Me 1 Reserved 4
Win32s with Windows 3.1 1 Build number 3


Remarks
The GetVersionEx function was developed because many existing applications err when examining the packed DWORD value returned by GetVersion, transposing the major and minor version numbers. GetVersionEx forces applications to explicitly examine each element of version information. VerifyVersionInfo eliminates further potential for error by comparing the required system version with the current system version for you.

The following code fragment illustrates how to extract information from the GetVersion return value:

dwVersion = GetVersion();

// Get the Windows version.

dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));

// Get the build number.

if (dwVersion < 0x80000000) // Windows NT/2000, Whistler
dwBuild = (DWORD)(HIWORD(dwVersion));
else if (dwWindowsMajorVersion < 4) // Win32s
dwBuild = (DWORD)(HIWORD(dwVersion) & ~0x8000);
else // Windows 95/98/Me
dwBuild = 0;
Requirements
Windows NT/2000 or later: Requires Windows NT 3.1 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also
System Information Overview, System Information Functions, GetVersionEx, VerifyVersionInfo

Platform SDK Release: February 2001 Contact Platform SDK Order a Platform SDK CD Online



Requirements
Windows NT/2000 or later: Requires Windows NT 3.1 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
See Also
System Information Overview, System Information Functions, GetVersionEx, VerifyVersionInfo
xxtliu 2001-11-28
  • 打赏
  • 举报
回复
好象用函数GetOSVersion()吧,具体怎么写的记不清楚了,你看一下MSDN吧
对了,好象还有一个宏可以判断,可惜也记不清楚了

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧