Click to See Complete Forum and Search --> : Win95/98 or WinNT??
liveForTen
Nov 17th, 1999, 10:03 PM
I need a program to be able to tell if it is being run in Windows NT or not. Is there an API that can tell me this?
john_murphy
Nov 17th, 1999, 10:27 PM
Try this I nicked it from the about wizard
john_m_murphy@hotmail.com
rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value
If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Errors
If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then
' Win95
Else ' WinNT
endif
Serge
Nov 17th, 1999, 10:29 PM
There is an API to get the paltform version:
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Const VER_PLATFORM_WIN32s = 0
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32_NT = 2
'---------Put this on any event you want
Dim os As OSVERSIONINFO
Dim lret As Long
lret = GetVersionEx(os)
If lret <> 0 Then
Select Case os.dwPlatformId
Case VER_PLATFORM_WIN32s
MsgBox "Window3.1/3.11"
Case VER_PLATFORM_WIN32_WINDOWS
MsgBox "Window95/98"
Case VER_PLATFORM_WIN32_NT
MsgBox "WindowNT"
End Select
Else
MsgBox "Error retrieving platform version."
End If
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
[This message has been edited by Serge (edited 11-18-1999).]
liveForTen
Nov 18th, 1999, 11:05 AM
Thanks guys. I knew this one would be an easy one for the likes of you VBPros. Thanks again.
liveForTen
Nov 19th, 1999, 10:13 AM
I don't suppose any would still be interested in this topic as at this late date it is now relegated to the antiquated page 3, but here goes...
I tried solution #2 because I did not want to get in to registry keys and stuff. There was one step missing between assigning the return value of the API to a variable:
lret = GetVersionEx(os)
and:
Select case os.dwPlatformId
I found the missing step in Dan Appleman's guide to the windows API. You must first set the size of the OSVERSIONINFO Type:
os.dwOSVersionInfoSize = SIZE_OF_OSVERSIONINFO
where SIZE_OF_OSVERSIONINFO = 148.
If you don't do this, all values return as 0.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.