N
Norman Chong
Hi group,
I want to get some information about the Windows version and
ServicePack. I used the WinAPI but got the following problem:
When I try to pass my OSVERSIONINFOEX structure ByRef to the
getVersionEx API-function, the structure remains empty. Shouldn't this
contain the values after the call?? Does anybody know what's wrong in
my code (Or maybe in my way of thinking)??
Private Structure OSVERSIONINFOEX
Dim dwOSVersionInfoSize As Integer
Dim dwMajorVersion As Integer
Dim dwMinorVersion As Integer
Dim dwBuildNumber As Integer
Dim dwPlatformId As Integer
<Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.ByValTStr,
SizeConst:=128)> _
Dim szCSDVersion As String
Dim wServicePackMajor As Short
Dim wServicePackMinor As Short
Dim wSuiteMask As Short
Dim wProductType As Byte
Dim wReserved As Byte
End Structure
Private Declare Function GetVersionEx Lib "kernel32" Alias
"GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFOEX) As Long
Private Sub LoadVersionStructure()
Dim test As New OSVERSIONINFOEX
Dim lngResult As Long
test.dwOSVersionInfoSize = Len(test)
lngResult = GetVersionEx(test)
If lngResult = 0 Then
MessageBox.Show("Failed to load version structure.")
End If
End Sub
I don't get an error and getVersionEx doesn't return 0, but like I
wrote, no data in OSVersionEx...
Unfortunately I can't use Environment.OSVersion to get what I need,
because I also need additional information (e.g. Whether it's Home
Edition or not, etc)
Thanx...
I want to get some information about the Windows version and
ServicePack. I used the WinAPI but got the following problem:
When I try to pass my OSVERSIONINFOEX structure ByRef to the
getVersionEx API-function, the structure remains empty. Shouldn't this
contain the values after the call?? Does anybody know what's wrong in
my code (Or maybe in my way of thinking)??
Private Structure OSVERSIONINFOEX
Dim dwOSVersionInfoSize As Integer
Dim dwMajorVersion As Integer
Dim dwMinorVersion As Integer
Dim dwBuildNumber As Integer
Dim dwPlatformId As Integer
<Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.ByValTStr,
SizeConst:=128)> _
Dim szCSDVersion As String
Dim wServicePackMajor As Short
Dim wServicePackMinor As Short
Dim wSuiteMask As Short
Dim wProductType As Byte
Dim wReserved As Byte
End Structure
Private Declare Function GetVersionEx Lib "kernel32" Alias
"GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFOEX) As Long
Private Sub LoadVersionStructure()
Dim test As New OSVERSIONINFOEX
Dim lngResult As Long
test.dwOSVersionInfoSize = Len(test)
lngResult = GetVersionEx(test)
If lngResult = 0 Then
MessageBox.Show("Failed to load version structure.")
End If
End Sub
I don't get an error and getVersionEx doesn't return 0, but like I
wrote, no data in OSVersionEx...
Unfortunately I can't use Environment.OSVersion to get what I need,
because I also need additional information (e.g. Whether it's Home
Edition or not, etc)
Thanx...