|
-
Nov 17th, 1999, 11:03 PM
#1
Thread Starter
New Member
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?
-
Nov 17th, 1999, 11:27 PM
#2
Hyperactive Member
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
-
Nov 17th, 1999, 11:29 PM
#3
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).]
-
Nov 18th, 1999, 12:05 PM
#4
Thread Starter
New Member
Thanks guys. I knew this one would be an easy one for the likes of you VBPros. Thanks again.
-
Nov 19th, 1999, 11:13 AM
#5
Thread Starter
New Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|