php中文网 | cnphp.com

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 665|回复: 0

c++类确定windows版本

[复制链接]

3138

主题

3148

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

UID
1
威望
0
积分
7946
贡献
0
注册时间
2021-4-14
最后登录
2024-11-21
在线时间
763 小时
QQ
发表于 2022-3-31 16:33:49 | 显示全部楼层 |阅读模式
WindowsVersion.h

[mw_shl_code=cpp,true]//
// Provided by Chilkat Software, Inc.  (http://www.chilkatsoft.com)
//
// Makers of ActiveX and .NET components:
//
// Zip Compression Component
// Email Component
// Encryption Component
// S/MIME Component
// HTML Email Component
// Character Encoding Conversion Component
// FTP Component (Free)
// Super-Fast XML Parser Component (Free)
// ASP Email Component
// ASP Super-Fast XML Parser Component (Free)
// Free SSL Component (Free)
// Real-time Compression Component (Free)
// DirectX Game Development C++ Library (Free, Open Source)
// XML Messaging Component
// EXE Stuffer Component (Embed anything in an EXE)
// Digital Certificates Component (Free)
// "Mail This Page!" utility (Free)
// Zip 2 Secure EXE (Free) for creating self-extracting EXEs
//
// WindowsVersion.h: interface for the WindowsVersion class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_WINDOWSVERSION_H__5AE736F3_769F_46E9_BB6E_23749CFA06EB__INCLUDED_)
#define AFX_WINDOWSVERSION_H__5AE736F3_769F_46E9_BB6E_23749CFA06EB__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class WindowsVersion  
{
    private:
        OSVERSIONINFO m_info;

    public:
        WindowsVersion();
        virtual ~WindowsVersion();

        bool isWindows95(void);
        bool isWindows98(void);
        bool isWindowsME(void);
        bool isWindowsXP(void);
        bool isWindows2000(void);
        bool isWindowsNT4(void);

};

#endif // !defined(AFX_WINDOWSVERSION_H__5AE736F3_769F_46E9_BB6E_23749CFA06EB__INCLUDED_)[/mw_shl_code]

WindowsVersion.cpp


[mw_shl_code=cpp,true]//
// Provided by Chilkat Software, Inc.  (http://www.chilkatsoft.com)
//
// Makers of ActiveX and .NET components:
//
// Zip Compression Component
// Email Component
// Encryption Component
// S/MIME Component
// HTML Email Component
// Character Encoding Conversion Component
// FTP Component (Free)
// Super-Fast XML Parser Component (Free)
// ASP Email Component
// ASP Super-Fast XML Parser Component (Free)
// Free SSL Component (Free)
// Real-time Compression Component (Free)
// DirectX Game Development C++ Library (Free, Open Source)
// XML Messaging Component
// EXE Stuffer Component (Embed anything in an EXE)
// Digital Certificates Component (Free)
// "Mail This Page!" utility (Free)
// Zip 2 Secure EXE (Free) for creating self-extracting EXEs
//
// WindowsVersion.cpp: implementation of the WindowsVersion class.
//
//////////////////////////////////////////////////////////////////////

#include <windows.h>
#include "WindowsVersion.h"


WindowsVersion::WindowsVersion()
{
    m_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    GetVersionEx(&m_info);
}

WindowsVersion::~WindowsVersion()
{

}

bool WindowsVersion::isWindows95(void)
    {
    if (m_info.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)
        {
        return false;
        }
    return m_info.dwMinorVersion == 0;
    }

bool WindowsVersion::isWindows98(void)
    {
    if (m_info.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)
        {
        return false;
        }
    return m_info.dwMinorVersion == 10;
    }

bool WindowsVersion::isWindowsME(void)
    {
    if (m_info.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)
        {
        return false;
        }
    return m_info.dwMinorVersion == 90;
    }

bool WindowsVersion::isWindowsXP(void)
    {
    if (m_info.dwPlatformId != VER_PLATFORM_WIN32_NT)
        {
        return false;
        }
    return m_info.dwMajorVersion == 5 && m_info.dwMinorVersion >= 1;
    }

bool WindowsVersion::isWindows2000(void)
    {
    if (m_info.dwPlatformId != VER_PLATFORM_WIN32_NT)
        {
        return false;
        }
    return m_info.dwMajorVersion == 5 && m_info.dwMinorVersion == 0;
    }

bool WindowsVersion::isWindowsNT4(void)
    {
    if (m_info.dwPlatformId != VER_PLATFORM_WIN32_NT)
        {
        return false;
        }
    return m_info.dwMajorVersion == 4;
    }[/mw_shl_code]

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|php中文网 | cnphp.com ( 赣ICP备2021002321号-2 )

GMT+8, 2024-11-22 02:14 , Processed in 0.299789 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

申明:本站所有资源皆搜集自网络,相关版权归版权持有人所有,如有侵权,请电邮(fiorkn@foxmail.com)告之,本站会尽快删除。

快速回复 返回顶部 返回列表