PDA

Click to See Complete Forum and Search --> : Use Api to find OS used on a PC?


alex_read
Jan 17th, 2001, 03:27 AM
Which function can I look up which can tell me what operating system the user is running on their PC.


Thank you in advance!

crispin
Jan 17th, 2001, 03:40 AM
'paste into a form with 1 command button
Private Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type

Public Function getVersion() As Long
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)
getVersion = osinfo.dwPlatformId
End Function

Private Sub Command1_Click()
Dim lVersion&
lVersion = getVersion()
Select Case lVersion
Case 1
MsgBox "WIN9X"
Case 2
MsgBox "WINNT"
End Select
End Sub

alex_read
Jan 17th, 2001, 04:09 AM
Cheers Crispin! :D

What would happen if the user has windows 200, will this show up as NT? If so is there any way to tell the difference please?

Thanks again!

crispin
Jan 17th, 2001, 04:34 AM
Yeah I just tested it on W2000Pro, it shows up as WINNT - dunno if thats much use or not really, there might be some more info in that OSVERSION struct that could tell you if its NT or W2000...

hope this helps

alex_read
Jan 17th, 2001, 04:39 AM
No, that's excellent, at least I know cheers.

I am writing a setup program & will just use the fso.folderexists() to see if the start menu is under the Win2000\documents and settings\, or under NT\winnt\.

Thanks for your help!