• Chapter04获取主机版本系统和验证系统是否是Vista


    //打印出系统版本信息
    void PrintOSVersionInfo()
    {
    	//系统版本系统结构体:OSVERSIONINFO
    	OSVERSIONINFO  osvi;
    
    	//将其内容置为0,并设置其大小
    	ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
    	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    
    	//调用该函数获取系统版本信息
    	GetVersionEx(&osvi);
    	_tprintf(TEXT("dwBuildNumber: %d\n"),osvi.dwBuildNumber);
    	_tprintf(TEXT("MajorVersion: %d\n"),osvi.dwMajorVersion);
    	_tprintf(TEXT("dwMinorVersion: %d\n"),osvi.dwMinorVersion);
    	_tprintf(TEXT("dwPlatformId: %d\n"),osvi.dwPlatformId);
    	_tprintf(TEXT("szCSDVersion: %d\n"),osvi.szCSDVersion);
    }
    
    //验证系统是否是Vista
    void VerifyOSVersionIsVista()
    {
    	//在osver变量中设置vista对应的版本信息。
    	OSVERSIONINFOEX osver;
    	osver.dwOSVersionInfoSize = sizeof(osver);
    	osver.dwMajorVersion = 6;
    	osver.dwMinorVersion = 0;	//验证vista时该值设置为0,验证win7时该值设置为1
    	osver.dwPlatformId = VER_PLATFORM_WIN32_NT;
    	
    	// Prepare the condition mask.
    	DWORDLONG dwlConditionMask = 0;// You MUST initialize this to 0.
    
    	//通过VER_SET_CONDITION宏设置要验证的信息掩码
    	VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_EQUAL);
    	VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_EQUAL);
    	VER_SET_CONDITION(dwlConditionMask, VER_PLATFORMID, VER_EQUAL);
    	
    	//调用VerifyVersionInfo函数进行验证。
    	if (VerifyVersionInfo(&osver, VER_MAJORVERSION 
    		| VER_MINORVERSION | VER_PLATFORMID, dwlConditionMask)) {
    			// The host system is Windows Vista exactly.
    			_tprintf(TEXT("It is Vista\n"));
    	} 
    	else 
    	{
    		// The host system is NOT Windows Vista.
    		_tprintf(TEXT("It is not Vista\n"));
    	}
    }
    
    void main()
    {
    	
    	PrintOSVersionInfo();
    	getchar();
    
    	VerifyOSVersionIsVista();
    	getchar();
    }
  • 相关阅读:
    Vue Router详细教程
    Vue CLI使用
    百度点选识别,单字90+
    CPU毫秒级 | 极验点选识别
    Linux内核之进程管理
    Linux内核之基本概念
    MySQL InnoDB技术内幕:内存管理、事务和锁
    ZooKeeper简介
    分布式一致性协议之ZAB
    图解HTTP读书笔记
  • 原文地址:https://www.cnblogs.com/java20130722/p/3207225.html
Copyright © 2020-2023  润新知