In order to determine whether my sister could run VB or VB .NET on her
recently installed system, I created a VB 6 app, and corresponding VB .NET
2002 and VB .NET 2003 versions.
The VB 6 code is given below.
Code is just simple API and WMI calls.
I do not want to convert the calls to Framework calls.
All I did was import the .vbp into both versions of VB .NET and build each
..exe.
I want to use the upgraded code without doing a full conversion to VB ..NET.
I sent her all 3 .exe files. Al three .exe files work on my system.
I have .NET 2002 and .NET 2003 installed in separate OS.
She was able to run the VB 6 version.
Note that she does not have VS .NET, but she tells me that she installed
..NET Framework 1.1 using Windows Update.
As expected, the VB .NET 2002 .exe would not work.
However, when she ran the VB .NET 2003 .exe, she got the following message:
WMIvb2003.exe - Common Language Runtime Debugging Services
Application has generated an exception that could not be handled.
Process id=0x538(1336), Thread id=0x150(336).
Is this a problem on her system, or do I need to do something more when
creating the .exe?
Option Explicit
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Type TIME_ZONE_INFORMATION
Bias As Long
StandardName As String * 64
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName As String * 64
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
Private Declare Function GetTimeZoneInformation& Lib "kernel32"
(lpTimeZoneInformation As TIME_ZONE_INFORMATION)
Private Sub Main()
WMIGetComputerSystem
End Sub
Sub WMIGetComputerSystem()
Dim Device
Dim objSystem As Object
Dim strOutput As String
Dim dblTotalMemory As Double
Dim lngReturn As Long
Dim lngTimeZoneOffsetMinutes As Long
Dim myTZ As TIME_ZONE_INFORMATION
lngReturn = GetTimeZoneInformation(myTZ)
' UTC = LocalTime + Bias
lngTimeZoneOffsetMinutes = -myTZ.Bias
For Each objSystem In
GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem")
With objSystem
strOutput = "Name: " & .Name & vbCrLf & _
"Caption: " & .Caption & vbCrLf & _
"CurrentTimeZone: " & .CurrentTimeZone & vbCrLf & _
"TimeZoneOffset: " & lngTimeZoneOffsetMinutes & vbCrLf & _
"LastBootUpTime: " & .LastBootUpTime & vbCrLf & _
"LocalDateTime: " & .LocalDateTime & vbCrLf & _
"Locale: " & .Locale & vbCrLf & _
"Manufacturer: " & .Manufacturer & vbCrLf & _
"OSType: " & .OSType & vbCrLf & _
"Version: " & .Version & vbCrLf & _
"Service Pack: " & .ServicePackMajorVersion & _
"." & .ServicePackMinorVersion & vbCrLf & _
"Windows Directory: " & .WindowsDirectory & vbCrLf & _
"Description: " & .Description & vbCrLf & _
"OS Version: " & .Caption & " (" & .Version & ")" & vbCrLf &
_
"Physical: " & .TotalVisibleMemorySize & " KB" & vbCrLf & _
"Virtual: " & .TotalVirtualMemorySize & " KB" & vbCrLf & _
"Free RAM: " & .FreePhysicalMemory & " KB" & vbCrLf & _
"Free Virtual: " & .FreeVirtualMemory & " KB"
End With
Next
strOutput = strOutput & vbCrLf
For Each objSystem In
GetObject("winmgmts:{impersonationLevel=impersonate}"). _
InstancesOf("Win32_ComputerSystem")
With objSystem
strOutput = strOutput & "Caption: " & .Caption & vbCrLf & _
"Description: " & .Description & vbCrLf & _
"Manufacturer: " & .Manufacturer & vbCrLf & _
"Model: " & .Model & vbCrLf & _
"Name: " & .Name & vbCrLf & _
"System Type: " & .SystemType & vbCrLf & _
"CurrentTimeZone: " & .CurrentTimeZone & vbCrLf & _
"Total physical memory: " & .TotalPhysicalMemory
End With
Next
dblTotalMemory = 0
For Each Device In
GetObject("winmgmts:").InstancesOf("Win32_PhysicalMemory")
dblTotalMemory = dblTotalMemory + CDbl(Device.Capacity)
Next
strOutput = strOutput & vbCrLf & "Memory capacity: " & _
Format$(dblTotalMemory / (2 ^ 20), "0 MB") & " (" & dblTotalMemory &
" bytes)"
Debug.Print strOutput
MsgBox strOutput
Set Device = Nothing
Set objSystem = Nothing
End Sub