📄 dtwinver.h
字号:
/*
Module : DTWINVER.H
Purpose: Declaration of a comprehensive class to perform OS version detection
Created: PJN / 11-05-1996
Copyright (c) 1997 - 2008 by PJ Naughter (Web: www.naughter.com, Email: pjna@naughter.com)
All rights reserved.
Copyright / Usage Details:
You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise)
when your product is released in binary form. You are allowed to modify the source code in any way you want
except you cannot modify the copyright details at the top of each module. If you want to distribute source
code with your application, then you are only allowed to distribute versions released by the author. This is
to maintain a single distribution point for the source code.
*/
////////////////////////////////// Defines ////////////////////////////////////
#ifndef __DTWINVER_H__
#define __DTWINVER_H__
#define COSVERSION_SUITE_SMALLBUSINESS 0x00000001
#define COSVERSION_SUITE_ENTERPRISE 0x00000002
#define COSVERSION_SUITE_PRIMARY_DOMAIN_CONTROLLER 0x00000004
#define COSVERSION_SUITE_BACKUP_DOMAIN_CONTROLLER 0x00000008
#define COSVERSION_SUITE_TERMINAL 0x00000010
#define COSVERSION_SUITE_DATACENTER 0x00000020
#define COSVERSION_SUITE_PERSONAL 0x00000040
#define COSVERSION_SUITE_WEBEDITION 0x00000080
#define COSVERSION_SUITE_EMBEDDEDNT 0x00000100
#define COSVERSION_SUITE_REMOTEADMINMODE_TERMINAL 0x00000200
#define COSVERSION_SUITE_UNIPROCESSOR_FREE 0x00000400
#define COSVERSION_SUITE_UNIPROCESSOR_CHECKED 0x00000800
#define COSVERSION_SUITE_MULTIPROCESSOR_FREE 0x00001000
#define COSVERSION_SUITE_MULTIPROCESSOR_CHECKED 0x00002000
#define COSVERSION_SUITE_MEDIACENTER 0x00004000
#define COSVERSION_SUITE_TABLETPC 0x00008000
#define COSVERSION_SUITE_STARTER_EDITION 0x00010000
#define COSVERSION_SUITE_R2_EDITION 0x00020000
#define COSVERSION_SUITE_COMPUTE_SERVER 0x00040000
#define COSVERSION_SUITE_STORAGE_SERVER 0x00080000
#define COSVERSION_SUITE_SECURITY_APPLIANCE 0x00100000
#define COSVERSION_SUITE_BACKOFFICE 0x00200000
#define COSVERSION_SUITE_ULTIMATE 0x00400000
#define COSVERSION_SUITE_N 0x00800000
#define COSVERSION_SUITE_HOME_BASIC 0x01000000
#define COSVERSION_SUITE_HOME_PREMIUM 0x02000000
#define COSVERSION_SUITE_HYPERV 0x04000000
#define COSVERSION_SUITE_BUSINESS 0x08000000
#define COSVERSION_SUITE_HOME_SERVER 0x10000000
#define COSVERSION_SUITE_SERVER_CORE 0x20000000
#define COSVERSION_SUITE_ESSENTIAL_BUSINESS_SERVER_MANAGEMENT 0x40000000
#define COSVERSION_SUITE_ESSENTIAL_BUSINESS_SERVER_MESSAGING 0x80000000
#define COSVERSION_SUITE2_ESSENTIAL_BUSINESS_SERVER_SECURITY 0x00000001
#define COSVERSION_SUITE2_CLUSTER_SERVER 0x00000002
#define COSVERSION_SUITE2_SMALLBUSINESS_PREMIUM 0x00000004
#define COSVERSION_SUITE2_STORAGE_EXPRESS_SERVER 0x00000008
#define COSVERSION_SUITE2_STORAGE_WORKGROUP_SERVER 0x00000010
#define COSVERSION_SUITE2_STANDARD 0x00000020
////////////////////////////////// Classes ////////////////////////////////////
class COSVersion
{
public:
//Enums
enum OS_PLATFORM
{
Dos = 0,
Windows3x = 1,
Windows9x = 2,
WindowsNT = 3,
WindowsCE = 4,
};
enum OS_TYPE
{
Workstation = 0,
Server = 1,
DomainController = 2,
};
enum PROCESSOR_TYPE
{
UNKNOWN_PROCESSOR = 0,
IA32_PROCESSOR = 1,
MIPS_PROCESSOR = 2,
ALPHA_PROCESSOR = 3,
PPC_PROCESSOR = 4,
IA64_PROCESSOR = 5,
AMD64_PROCESSOR = 6,
ALPHA64_PROCESSOR = 7,
MSIL_PROCESSOR = 8,
ARM_PROCESSOR = 9,
SHX_PROCESSOR = 10,
};
//Defines
typedef struct _OS_VERSION_INFO
{
#ifndef UNDER_CE
//What version of OS is being emulated
DWORD dwEmulatedMajorVersion;
DWORD dwEmulatedMinorVersion;
DWORD dwEmulatedBuildNumber;
OS_PLATFORM EmulatedPlatform;
PROCESSOR_TYPE EmulatedProcessorType; //The emulated processor type
#ifdef _WIN32
TCHAR szEmulatedCSDVersion[128];
#else
char szEmulatedCSDVersion[128];
#endif
WORD wEmulatedServicePackMajor;
WORD wEmulatedServicePackMinor;
#endif
//What version of OS is really running
DWORD dwUnderlyingMajorVersion;
DWORD dwUnderlyingMinorVersion;
DWORD dwUnderlyingBuildNumber;
OS_PLATFORM UnderlyingPlatform;
#ifdef _WIN32
TCHAR szUnderlyingCSDVersion[128];
#else
char szUnderlyingCSDVersion[128];
#endif
WORD wUnderlyingServicePackMajor;
WORD wUnderlyingServicePackMinor;
DWORD dwSuiteMask; //Bitmask of various OS suites
DWORD dwSuiteMask2; //Second set of Bitmask of various OS suites
OS_TYPE OSType; //The basic OS type
#ifndef UNDER_CE
PROCESSOR_TYPE UnderlyingProcessorType; //The underlying processor type
#endif
#ifdef UNDER_CE
TCHAR szOEMInfo[256];
TCHAR szPlatformType[256];
#endif
} OS_VERSION_INFO, *POS_VERSION_INFO, FAR *LPOS_VERSION_INFO;
//Constructors / Destructors
COSVersion();
~COSVersion();
//Methods:
BOOL GetVersion(LPOS_VERSION_INFO lpVersionInformation);
//Please note that the return values for all the following functions
//are mutually exclusive for example if you are running on
//95 OSR2 then IsWindows95 will return FALSE
BOOL IsWindows30(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindows31(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindows311(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindowsForWorkgroups(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindowsCE(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindows95(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindows95SP1(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindows95B(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindows95C(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindows98(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindows98SP1(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindows98SE(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindowsME(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindowsNT31(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindowsNT35(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindowsNT351(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindowsNT4(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindows2000(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindowsXPOrWindowsServer2003(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindowsVista(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindows7(LPOS_VERSION_INFO lpVersionInformation);
//Returns the various flavours of the "os" that is installed. Note that these
//functions are not completely mutually exlusive
BOOL IsWin32sInstalled(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsNTPreWin2k(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsNTWorkstation(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsNTStandAloneServer(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsNTPDC(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsNTBDC(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsNTEnterpriseServer(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsNTDatacenterServer(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWin2000Professional(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWin2000Server(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWin2000AdvancedServer(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWin2000DatacenterServer(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWin2000DomainController(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindowsXP(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsXPPersonal(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsXPProfessional(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWebWindowsServer2003(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsWindowsServer2003(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsStandardWindowsServer2003(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsEnterpriseWindowsServer2003(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsDatacenterWindowsServer2003(LPOS_VERSION_INFO lpVersionInformation);
BOOL IsDomainControllerWindowsServer2003(LPOS_VERSION_INFO lpVersionInformation);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -