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?
Printable View
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?
Try this I nicked it from the about wizard
[email protected]
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
There is an API to get the paltform version:
------------------Code: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
[email protected]
[email protected]
ICQ#: 51055819
[This message has been edited by Serge (edited 11-18-1999).]
Thanks guys. I knew this one would be an easy one for the likes of you VBPros. Thanks again.
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.