简体   繁体   中英

VB6 code to find windows OS version

I am using OSVERSIONINFO to check the OS in my vb6 application. But i am not able differentiate between windows 7 and windows server 2008 R2 because they have same version number,dwMajorVersion and dwMinorVersion. So how to differentiate between these. I think it can be done in vb.net using some other method. But how it can be done in vb6?

As Xearinox noted in the above comment, OSVERSIONINFOEX returns more information.

In particular, you can examine wProductType to determine whether VER_NT_WORKSTATION (0x0000001) is set or not. If it is, the machine is running a client OS, otherwise, server.

The chart in the remarks section of the OSVERSIONINFO MSDN entry even has a column which points out detecting the various OS's using that struct item.

Right Click On Tool Bar > Components And Add > Microsoft SysControl 6.0. Double Click The SysInfo Button to Add on Form and use this code

Private Sub Form_Load()
    Dim HancyRockz as string
    HancyRockz = "OsVersion :- " & SysInfo1.OSVersion & " / Built " & SysInfo1.OSBuild
    Text1.Text=HancyRockz
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM