Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OS recognition

Status
Not open for further replies.

gransbpa

Programmer
Jun 5, 2001
98
NL
Hello there,

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?
 
these functions will tell win2k & nt or not.
You may have to experiment to see if you can get them to work for others.

'--------------------------------------------------------------
' Copyright ©1996-2002 VBnet, Randy Birch, All Rights Reserved.
' Terms of use '--------------------------------------------------------------

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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top