The easiest way to judge the version of the operating system version in the VC

xiaoxiao2021-03-06  37

Pomelowu Original ©, please specify the source

I used to read "Windows Core Programming" notes, turned it out today, I have never remembered ... A lot of emotions, how can the theory and actual perspective? I doubt Chinese education again, and I will reflect on my learning attitude!

How to get the current system version information? Windows SDK API: Getversion / GetVersionex.

However, if you only need the simplest information, if you do Windows XP, Minor Version is, you don't have to call this API again. Ha ha ~~ I said "again" because VC has already done this thing. Let's take a look at a paragraph in "Windows Core Programming":

All C / C run start function is basically the same. Their difference is that they are dealing with an ANSI string or a UNICODE string, and they call which entry point function they call after initializing the C run library. Visual C is equipped with the source code of the C operation library. You can find the code of these 4 startup functions in the CRT0.C file.

See what code in CRT0.c directly:

/// herein preceding code independent #ifdef _WINMAIN_ #ifdef WPRFLAGvoid wWinMainCRTStartup (#else / * WPRFLAG * / void WinMainCRTStartup (#endif / * WPRFLAG * / #else / * _WINMAIN_ * / #ifdef WPRFLAGvoid wmainCRTStartup (#else / * WPRFLAG * / void mainCRTStartup (#endif / * WPRFLAG * / #endif / * _WINMAIN_ * / void) {int mainret; #ifdef _WINMAIN_ _TUCHAR * lpszCommandLine; STARTUPINFO StartupInfo; #endif / * _WINMAIN_ * / / * * Get the full Win32 version * / _SVER = getversion (); _winminor = (_SVER >> 8) & 0x00FF; _winmajor = _OSVER & 0X00FF; _WINVER = (_winmajor << 8) _winminor; _OSVER = (_OSVER >> 16) & 0x00FFFF; /// The following is independent of the discussion of this article, omitted

Get two important information:

VC does have helped us to get the system version number, and the four unsigned int types of _Winver, _winminor, _winmajor, _winver, the four unsigned int types, Windows, the secondary version number, Windows The main version number and the Windows version number (the mixture of Major Version and Minor Version don't know how to name). No need to call the GetVersion API when you use it.

Regardless of the startup function for Windows programs, the program uses these four variables to store system version information.

In addition, VCs are also initialized for us:

转载请注明原文地址:https://www.9cbs.com/read-67697.html

New Post(0)