Is there a way to detect what opperating system is running on the machine your app is installed on? I've got a small program that needs to use certain unique registry keys in WinNT or Win98/95 depending on which version of the OS is present.
~A6
Printable View
Is there a way to detect what opperating system is running on the machine your app is installed on? I've got a small program that needs to use certain unique registry keys in WinNT or Win98/95 depending on which version of the OS is present.
~A6
Paste this into a form with one command button:
Code:Private Declare Function GetVersionExA Lib "kernel32" _
(lpVersionInformation As OSVERSIONINFO) As Integer
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long '1 = Windows 95.
'2 = Windows NT
szCSDVersion As String * 128
End Type
Private Sub Command1_Click()
Dim X As Long
X = getVersion
If X = 1 Then MsgBox "WIN95"
If X = 2 Then MsgBox "WINNT"
End Sub
Public Function getVersion() As Long
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)
getVersion = osinfo.dwPlatformId
End Function