zoukankan      html  css  js  c++  java
  • 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();
    }
  • 相关阅读:
    LeetCode之“数学”:Plus One
    LeetCode之“动态规划”:Dungeon Game
    LeetCode之“排序”:Largest Number
    LeetCode之“字符串”:ZigZag Conversion
    LeetCode之“数组”:Rotate Array
    HTML 5 简介、视频、Video + DOM、音频、拖放
    HTML 多媒体、Object 元素、音频、视频
    HTML5 Canvas、内联 SVG、Canvas vs. SVG
    HTML5 语义元素、迁移、样式指南和代码约定
    HTML5 简介、浏览器支持、新元素
  • 原文地址:https://www.cnblogs.com/java20130722/p/3207225.html
Copyright © 2011-2022 走看看