|
-
Sep 15th, 2000, 06:28 AM
#1
Thread Starter
Conquistador
i read in a c++ book, that to get the version of the operating system to use GetVersionEx.
i tried this
Code:
'module
Public 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
Public Declare Function GetVersion Lib "kernel32" () As Long
'form
Private Sub Command1_Click()
MsgBox GetVersion()
End Sub
what number does this give?
it's heaps of number, that mean nothing??
can any one help?
-
Sep 15th, 2000, 06:33 AM
#2
Thread Starter
Conquistador
then i tried this
Code:
Private Sub Command1_Click()
Dim INFO As OSVERSIONINFO
MsgBox GetVersionEx(INFO.dwPlatformId)
End Sub
i got a byref error
so i tried this
Code:
Private Sub Command1_Click()
Dim INFO As OSVERSIONINFO
GetVersionEx INFO
MsgBox INFO.dwPlatformId
End Sub
and it always says 0
-
Sep 15th, 2000, 06:39 AM
#3
Look at Detecting Windows Version
i posted there the correct code
-
Sep 15th, 2000, 06:44 AM
#4
Try this:
In a module:
Code:
Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Public 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
Public Const VER_PLATFORM_WIN32_NT = 2
Public Const VER_PLATFORM_WIN32_WINDOWS = 1
Public Const VER_PLATFORM_WIN32s = 0
In a form:
Code:
Private Sub Command1_Click()
Dim OS As OSVERSIONINFO
Dim sPlatform As String
Dim sOther As String
OS.dwOSVersionInfoSize = Len(OS)
GetVersionEx OS
Select Case OS.dwPlatformId
Case VER_PLATFORM_WIN32s: sPlatform = "Windows 3.X with Win32s"
Case VER_PLATFORM_WIN32_NT: sPlatform = "Windows NT"
Case VER_PLATFORM_WIN32_WINDOWS: sPlatform = "Windows 95/98/ME"
End Select
sOther = Replace(OS.szCSDVersion, Chr(0), "")
sOther = Trim(sOther)
If sOther = "" Then sOther = "None"
MsgBox "Platform: " & sPlatform & vbCrLf & _
"Version: " & OS.dwMajorVersion & "." & OS.dwMinorVersion & " Build " & OS.dwBuildNumber & vbCrLf & _
"Other Info: " & sOther, vbInformation Or vbOKOnly, "Version Info"
End Sub
[Edited by Sc0rp on 09-15-2000 at 07:47 AM]
-
Sep 15th, 2000, 03:39 PM
#5
Here is a routine I wrote awhile back, which will display OS info.
Code:
Private Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32.dll" Alias "GetDiskFreeSpaceExA" (ByVal lpDirectoryName As String, lpFreeBytesAvailableToCaller As ULARGE_INTEGER, lpTotalNumberOfBytes As ULARGE_INTEGER, lpTotalNumberOfFreeBytes As ULARGE_INTEGER) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Type ULARGE_INTEGER
LowPart As Long
HighPart As Long
End Type
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Dim OsInfo As OSVERSIONINFO
Dim tmp As String
Dim FreeUser As ULARGE_INTEGER
Dim Total As ULARGE_INTEGER
Dim FreeSys As ULARGE_INTEGER
Dim Temp As Currency
Dim fTemp As Currency
Private Sub Command1_Click()
'Get OS Info
OsInfo.dwOSVersionInfoSize = Len(OsInfo)
retval = GetVersionEx(OsInfo)
Select Case OsInfo.dwPlatformId
Case 0
tmp = "Windows 3.x"
Case 1
tmp = "Windows 95/98"
Case 2
tmp = "Windows NT"
End Select
Print "Version: " & OsInfo.dwMajorVersion & "." & OsInfo.dwMinorVersion
Print "Build: " & OsInfo.dwBuildNumber
Print "Platform: " & tmp
'Get DiskSpace
GetDiskFreeSpaceEx "C:\", FreeUser, Total, FreeSys
CopyMemory Temp, Total, 8
CopyMemory fTemp, FreeUser, 8
Print "Total Space: " & (CCur(Temp) * 10000) / 1000000000 & " GB"
Print "Free Space: " & (CCur(fTemp) * 10000) / 1000000000 & " GB"
End Sub
-
Sep 15th, 2000, 10:12 PM
#6
Thread Starter
Conquistador
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
|