資源簡介
c++ 檢測windows機型
代碼片段和文件信息
//?//?MyReadNumber_C.cpp?:?此文件包含?“main“?函數(shù)。程序執(zhí)行將在此處開始并結(jié)束。
#include??
#include?
#include?
#include??//?include?must?before?window.h
#include?
#include???
#include?
#pragma?comment(lib?“iphlpapi.lib“)
//警告
#pragma?warning(disable:?4996)?//?avoid?GetVersionEx?to?be?warned
//?*****?global?macros?*****?//
static?const?int?kMaxInfoBuffer?=?256;??//信息緩沖區(qū)大小
#define??GBYTES??1073741824??
#define??MBYTES??1048576??
#define??KBYTES??1024??
#define??DKBYTES?1024.0??
//******?獲取操作系統(tǒng)信息?******//
void?getOsInfo()
{
//?get?os?name?according?to?version?number
OSVERSIONINFO?osver?=?{?sizeof(OSVERSIONINFO)?};
GetVersionEx(&osver);
std::string?os_name;
if?(osver.dwMajorVersion?==?5?&&?osver.dwMino
評論
共有 條評論