IT researcher
IT researcher

Reputation: 3304

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?

Upvotes: 2

Views: 6176

Answers (2)

Uɐɹıʞ ʎɔuɐɥ
Uɐɹıʞ ʎɔuɐɥ

Reputation: 31

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

Upvotes: 3

Lynn Crumbling
Lynn Crumbling

Reputation: 13357

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.

Upvotes: 6

Related Questions