How to obtain a version of the Windows operating system

Source: Internet
Author: User
A lot of times we need to know the version of the Windows operating system, and we can do that with the following API function.
Option Explicit
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (Lpversioninformation as osVersionInfo) as Long
Private Type osVersionInfo
dwOSVersionInfoSize as Long
dwMajorVersion as Long
dwMinorVersion as Long
dwBuildNumber as Long
dwPlatformId as Long
szCSDVersion As String * 128 ' maintenance string for PSS usage
Osname as String ' I add it myself, the name of the operating system
End Type
' Get the version of the Windows operating system
' Osname in the OSVERSIONINFO structure returns the name of the operating system
Private Function getwindowsversion () as osVersionInfo
Dim ver as osVersionInfo
Ver.dwosversioninfosize = 148
GetVersionEx ver
With Ver
Select case. dwPlatformId
Case 1
Select case. dwMinorVersion
Case 0
. Osname = "Windows 95"
Case 10
. Osname = "Windows 98"
Case 90
. Osname = "Windows mellinnium"
End Select
Case 2
Select case. dwMajorVersion
Case 3
. Osname = "Windows NT 3.51"
Case 4
. Osname = "Windows NT 4.0"
Case 5
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.