I have to make a decision in a program depending upon the operating system used (the program is called from within several operating systems). Could anyone tell me if this is possible and if yes how?
Public Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long
Public Const VER_PLATFORM_WIN32s = 0
Public Const VER_PLATFORM_WIN32_WINDOWS = 1
Public Const VER_PLATFORM_WIN32_NT = 2
'windows-defined type OSVERSIONINFO
Public Type OSVERSIONINFO
OSVSize As Long
dwVerMajor As Long
dwVerMinor As Long
dwBuildNumber As Long
PlatformID As Long
szCSDVersion As String * 128
End Type
Public Function IsWin2000()
#If Win32 Then
Dim OSV As OSVERSIONINFO
OSV.OSVSize = Len(OSV)
If GetVersionEx(OSV) = 1 Then
'PlatformId contains a value representing
'the OS, so if its VER_PLATFORM_WIN32_NT,
'abd the dwVerMajosr is 5, return true
IsWin2000 = (OSV.PlatformID = VER_PLATFORM_WIN32_NT) And _
(OSV.dwVerMajor = 5)
End If
#End If
End Function
Public Function IsWinNT()
#If Win32 Then
Dim OSV As OSVERSIONINFO
OSV.OSVSize = Len(OSV)
If GetVersionEx(OSV) = 1 Then
'PlatformId contains a value representing
'the OS, so if its VER_PLATFORM_WIN32_NT,
'return true
IsWinNT = (OSV.PlatformID = VER_PLATFORM_WIN32_NT)
End If
#End If
End Function
HTH
Ben ----------------------------------------
Ben O'Hara
Home: bpo@SickOfSpam.RobotParade.co.uk
Work: bo104@SickOfSpam.westyorkshire.pnn.police.uk
(in case you've not worked it out get rid of Sick Of Spam to mail me!)
Web:
Thanks for the info Ben! Now, I'm not a very experienced programmer, and don't actually know how to use such functions. Can you just call them and put the result in a textfield or a variable? And how do I have to declare them?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.