Article ID: 112393
Article Last Modified on 10/11/2006
This Statement/
Property Displays This Information
------------------------------------------------------------------
GetWinFlags The kind of CPU (80286, 80386, or 80486) and
whether a math coprocessor is present
GetWinFlags Whether Microsoft Windows is running in
enhanced mode or standard mode
GetFreeSpace The amount of free memory
and
GlobalCompact
SystemHeapInfo The percentage of free system resources
OperatingSystem The version of Windows
' Constants for GetWinFlags.
Global Const WF_CPU286 = &h2
Global Const WF_CPU386 = &h4
Global Const WF_CPU486 = &h8
Global Const WF_80x87 = &h400
Global Const WF_STANDARD = &h10
Global Const WF_ENHANCED = &h20
' Type for SystemHeapInfo.
Type SYSHEAPINFO
dwSize As Long
wUserFreePercent As Integer
wGDIFreePercent As Integer
hUserSegment As Integer
hGDISegment As Integer
End Type
Declare Function GetWinFlags Lib "KERNEL" () As Long
Declare Function GetFreeSpace Lib "KERNEL" _
(ByVal wFlags As Integer) As Long
Declare Function GlobalCompact Lib "KERNEL" _
(ByVal dwMinFree As Long) As Long
Declare Function SystemHeapInfo Lib "TOOLHELP.DLL" _
(shi As SYSHEAPINFO) As Integer
Sub GetWindowsInfo()
Dim Status As Long
Dim Memory As Long
Dim msg As String ' Status information.
Dim nl As String ' New-line.
Dim shi As SYSHEAPINFO
nl = Chr$(13) + Chr$(10) ' New-line.
Status = GetWinFlags()
' Get operating system version.
' (Uses Excel's built-in OperatingSystem function rather
' than Windows API calls.)
msg = "OS: " + Application.OperatingSystem
' Get CPU kind and operating mode.
msg = msg + nl + "CPU: "
If Status And WF_CPU286 Then msg = msg + "80286"
If Status And WF_CPU386 Then msg = msg + "80386"
If Status And WF_CPU486 Then msg = msg + "80486"
If Status And WF_80x87 Then msg = msg + " with 80x87"
msg = msg + nl
msg = msg + "Mode: "
If Status And WF_STANDARD Then msg = msg + "Standard" + nl
If Status And WF_ENHANCED Then msg = msg + "Enhanced" + nl
' Get free memory.
Memory = GetFreeSpace(0)
msg = msg + "Memory free: "
msg = msg + Format$(Memory \ 1024, "###,###,###") + "K" + nl
Memory = GlobalCompact(&hffff)
msg = msg + "Largest free block: "
msg = msg + Format$(Memory \ 1024, "###,###,###") + "K" + nl
' Get free system resources.
msg = msg + "System resources: "
shi.dwSize = Len(shi)
If SystemHeapInfo(shi) Then
If shi.wUserFreePercent < shi.wGDIFreePercent Then
msg = msg + Format$(shi.wUserFreePercent) + "%"
Else
msg = msg + Format$(shi.wGDIFreePercent) + "%"
End If
End If
MsgBox msg, vbOKOnly, "About This PC"
End Sub
Additional query words: 5.00c XL5
Keywords: kbprogramming KB112393