Windows API one-day training (73) getversionex Function

Source: Internet
Author: User
Windows API one-day training (73) getversionex Function

Windows development is still very fast, from Win95 to Win98, to Win2000 and XP systems. Each system has different functions. to distinguish different systems in a program, you need to obtain the system version information. For example, there is a firewall in XP, but not in other previous systems. However, sometimes a server program or BT program is compiled, and a port must be set to receive external connections. Therefore, you need to set the firewall port in the XP system, in XP systems, there is no need to set ports. The getversionex function can be used to differentiate different systems.

The getversionex function declaration is as follows:

Winbaseapi
Bool
Winapi
Getversionexa (
_ Inout lposversioninfoa lpversioninformation
);
Winbaseapi
Bool
Winapi
Getversionexw (
_ Inout lposversioninfow lpversioninformation
);
# Ifdef Unicode
# Define getversionex getversionexw
# Else
# Define getversionex getversionexa
# Endif //! Unicode

Lpversioninformation is the information of the system version.

An example of calling a function is as follows:
#001 //
#002 // obtain the name of the current logon user.
#003 // Cai junsheng 2007/11/14 QQ: 9073204 Shenzhen
#004 void getwinversion (void)
#005 {
#006 //
#007 osversioninfo osvi;
#008 osvi. dwosversioninfosize = sizeof (osversioninfo );
#009
#010 // obtain the system version information.
#011: getversionex (& osvi );
#012 bool biswindowsxporlater = (osvi. dwmajorversion> 5) |
#013 (osvi. dwmajorversion = 5) & (osvi. dwminorversion> = 1 ));
#014
#015 // display the current version.
#016 if (biswindowsxporlater)
#017 {
#018 outputdebugstring (_ T ("Windows XP or an updated version! /R/N "));
#019}
#020 else
#021 {
#022 outputdebugstring (_ T ("earlier Windows XP version! /R/N "));
#023}
#024}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.