home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form SysInfo
- BackColor = &H00E0E0E0&
- Caption = "System Information Viewer"
- ClientHeight = 3870
- ClientLeft = 1275
- ClientTop = 1965
- ClientWidth = 7365
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 3870
- ScaleWidth = 7365
- Begin VB.Timer Timer1
- Interval = 250
- Left = 6120
- Top = 120
- End
- Begin VB.ListBox ListColor
- Appearance = 0 'Flat
- Height = 2565
- Left = 240
- TabIndex = 2
- Top = 600
- Visible = 0 'False
- Width = 3015
- End
- Begin VB.TextBox KeyCheck
- Height = 615
- Left = 5880
- MultiLine = -1 'True
- TabIndex = 0
- Text = "SYSINFO.frx":0000
- Top = 720
- Width = 1455
- End
- Begin VB.TextBox Text1
- Height = 1095
- Left = 5880
- MultiLine = -1 'True
- TabIndex = 1
- Text = "SYSINFO.frx":0016
- Top = 1440
- Width = 1335
- End
- Begin VB.Label LabelColor
- Alignment = 2 'Center
- Appearance = 0 'Flat
- BackColor = &H00FFFFFF&
- BorderStyle = 1 'Fixed Single
- Caption = "Color"
- ForeColor = &H80000008&
- Height = 315
- Left = 240
- TabIndex = 3
- Top = 120
- Visible = 0 'False
- Width = 3015
- End
- Begin VB.Label LabelKeyState
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BorderStyle = 1 'Fixed Single
- ForeColor = &H80000008&
- Height = 255
- Left = 4800
- TabIndex = 4
- Top = 3480
- Width = 2415
- End
- Begin VB.Menu MenuGeneral
- Caption = "General"
- Begin VB.Menu MenuFreeSpace
- Caption = "Free&Space"
- End
- Begin VB.Menu MenuTimes
- Caption = "&Times"
- End
- Begin VB.Menu MenuFlags
- Caption = "&Flags"
- End
- End
- Begin VB.Menu MenuSystem
- Caption = "System"
- Begin VB.Menu MenuColors
- Caption = "&Colors"
- End
- Begin VB.Menu MenuMetrics
- Caption = "&Metrics"
- End
- Begin VB.Menu MenuParameters
- Caption = "&Parameters"
- End
- Begin VB.Menu MenuKeyboard
- Caption = "&Keyboard"
- End
- Begin VB.Menu MenuLocale
- Caption = "&Locale"
- End
- End
- Attribute VB_Name = "SysInfo"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub Form_Load()
- Dim dl&
- #If Win32 Then
- ' Preload version information
- dl& = GetVersionEx&(myVer)
- #End If
- ListColor.AddItem "COLOR_ACTIVEBORDER"
- ListColor.AddItem "COLOR_ACTIVECAPTION"
- ListColor.AddItem "COLOR_APPWORKSPACE"
- ListColor.AddItem "COLOR_BACKGROUND"
- ListColor.AddItem "COLOR_BTNFACE"
- ListColor.AddItem "COLOR_BTNHIGHLIGHT"
- ListColor.AddItem "COLOR_BTNSHADOW"
- ListColor.AddItem "COLOR_BTNTEXT"
- ListColor.AddItem "COLOR_CAPTIONTEXT"
- ListColor.AddItem "COLOR_GRAYTEXT"
- ListColor.AddItem "COLOR_HIGHLIGHT"
- ListColor.AddItem "COLOR_HIGHLIGHTTEXT"
- ListColor.AddItem "COLOR_INACTIVEBORDER"
- ListColor.AddItem "COLOR_INACTIVECAPTION"
- ListColor.AddItem "COLOR_INACTIVECAPTIONTEXT"
- ListColor.AddItem "COLOR_MENU"
- ListColor.AddItem "COLOR_MENUTEXT"
- ListColor.AddItem "COLOR_SCROLLBAR"
- ListColor.AddItem "COLOR_WINDOW"
- ListColor.AddItem "COLOR_WINDOWFRAME"
- ListColor.AddItem "COLOR_WINDOWTEXT"
- ' These are new for Windows 95. Even though they
- ' are defined for Win32, they will also work on Win16 on Win95!
- ListColor.AddItem "COLOR_3DDKSHADOW"
- ListColor.AddItem "COLOR_3DLIGHT"
- ListColor.AddItem "COLOR_INFOBK"
- ListColor.AddItem "COLOR_INFOTEXT"
- End Sub
- ' Display in the edit control the name of the key
- Private Sub KeyCheck_KeyDown(KeyCode As Integer, Shift As Integer)
- Dim dummy&
- Dim scancode&
- Dim keyname As String * 256
- ' Get the scancode
- scancode& = MapVirtualKey(KeyCode, 0)
- ' Shift the scancode to the high word and get the
- ' key name
- dummy = GetKeyNameText(scancode& * &H10000, keyname, 255)
- KeyCheck.Text = keyname
- End Sub
- Private Sub KeyCheck_KeyPress(KeyAscii As Integer)
- KeyAscii = 0 ' Ignore keys in this control
- End Sub
- Private Sub KeyCheck_LostFocus()
- KeyCheck.Text = "Press key to get info"
- End Sub
- ' Display the selected color in the label control.
- Private Sub ListColor_Click()
- Dim colindex%
- Select Case ListColor.ListIndex
- Case 0
- colindex% = COLOR_ACTIVEBORDER
- Case 1
- colindex% = COLOR_ACTIVECAPTION
- Case 2
- colindex% = COLOR_APPWORKSPACE
- Case 3
- colindex% = COLOR_BACKGROUND
- Case 4
- colindex% = COLOR_BTNFACE
- Case 5
- colindex% = COLOR_BTNHIGHLIGHT
- Case 6
- colindex% = COLOR_BTNSHADOW
- Case 7
- colindex% = COLOR_BTNTEXT
- Case 8
- colindex% = COLOR_CAPTIONTEXT
- Case 9
- colindex% = COLOR_GRAYTEXT
- Case 10
- colindex% = COLOR_HIGHLIGHT
- Case 11
- colindex% = COLOR_HIGHLIGHTTEXT
- Case 12
- colindex% = COLOR_INACTIVEBORDER
- Case 13
- colindex% = COLOR_INACTIVECAPTION
- Case 14
- colindex% = COLOR_INACTIVECAPTIONTEXT
- Case 15
- colindex% = COLOR_MENU
- Case 16
- colindex% = COLOR_MENUTEXT
- Case 17
- colindex% = COLOR_SCROLLBAR
- Case 18
- colindex% = COLOR_WINDOW
- Case 19
- colindex% = COLOR_WINDOWFRAME
- Case 20
- colindex% = COLOR_WINDOWTEXT
- Case 21
- colindex% = COLOR_3DDKSHADOW
- Case 22
- colindex% = COLOR_3DLIGHT
- Case 23
- colindex% = COLOR_INFOBK
- Case 24
- colindex% = COLOR_INFOTEXT
- End Select
- LabelColor.BackColor = GetSysColor&(colindex%) And &HFFFFFF
- End Sub
- Private Sub MenuColors_Click()
- SysInfo.Cls
- ShowColors -1
- End Sub
- Private Sub MenuFlags_Click()
- Dim flagnum&
- Dim dl&, s$
- Dim vernum&, verword%
- #If Win32 Then
- Dim mySys As SYSTEM_INFO
- #End If
- ShowColors 0
- SysInfo.Cls
- Print
- ' Get the windows flags and version numbers
- #If Win32 Then
- myVer.dwOSVersionInfoSize = 148
- dl& = GetVersionEx&(myVer)
- If myVer.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
- s$ = " Windows95 "
- ElseIf myVer.dwPlatformId = VER_PLATFORM_WIN32_NT Then
- s$ = " Windows NT "
- End If
- Print s$ & myVer.dwMajorVersion & "." & myVer.dwMinorVersion & " Build " & (myVer.dwBuildNumber And &HFFFF&)
- s$ = LPSTRToVBString(myVer.szCSDVersion)
- If Len(s$) > 0 Then Print s$
- GetSystemInfo mySys
- Print " Page size is " & mySys.dwPageSize; " bytes"
- Print " Lowest memory address: &H" & Hex$(mySys.lpMinimumApplicationAddress)
- Print " Highest memory address: &H" & Hex$(mySys.lpMaximumApplicationAddress)
- Print " Number of processors: "; mySys.dwNumberOfProcessors
- Print " Processor: ";
- Select Case mySys.dwProcessorType
- Case PROCESSOR_INTEL_386
- Print "Intel 386"
- Case PROCESSOR_INTEL_486
- Print "Intel 486"
- Case PROCESSOR_INTEL_PENTIUM
- Print "Intel Pentium"
- Case PROCESSOR_MIPS_R4000
- Print "MIPS R4000"
- Case PROCESSOR_ALPHA_21064
- Print "Alpha 21064"
- End Select
-
- #Else
- flagnum& = GetWinFlags&()
- vernum& = GetVersion&()
- verword% = CInt(vernum& / &H10000)
-
- Print " Running MS-DOS version "; verword% / 256; "."; verword% And &HFF
- verword% = CInt(vernum& And &HFFFF&)
- Print " Running Windows version "; verword% And &HFF; "."; CInt(verword% / 256)
-
- If flagnum& And WF_80x87 Then Print " 80x87 coprocessor present"
- If flagnum& And WF_CPU086 Then Print " 8086 present"
- If flagnum& And WF_CPU186 Then Print " 80186 present"
- If flagnum& And WF_CPU286 Then Print " 80286 present"
- If flagnum& And WF_CPU386 Then Print " 80386 present"
- If flagnum& And WF_CPU486 Then Print " 80486 present"
- If flagnum& And WF_ENHANCED Then Print " Windows 386-enhanced mode"
- #End If
- End Sub
- Private Sub MenuFreeSpace_Click()
- ShowColors 0
- SysInfo.Cls
- Print
- ' These functions are obsolete under Win32
- #If Win16 Then
- Print GetFreeSpace&(0); "Bytes free in Global Heap"
- Print GetFreeSystemResources%(GFSR_SYSTEMRESOURCES); "% free system resources."
- Print GetFreeSystemResources%(GFSR_GDIRESOURCES); "% free GDI resources."
- Print GetFreeSystemResources%(GFSR_USERRESOURCES); "% free USER resources."
- #Else
- Print " Refer Chapter 15 examples for information"
- Print " on retrieving memory statistics for Win32"
- #End If
- End Sub
- ' Display keyboard related iformation.
- Private Sub MenuKeyboard_Click()
- Dim cp As CPINFO
- Dim cpAnsi&, cpOEM&
- Dim dl&
- Dim layoutname As String * KL_NAMELENGTH
- Print
- SysInfo.Cls
- #If Win32 Then
- cpAnsi = GetACP()
- cpOEM = GetOEMCP()
- Print " ANSI code page: " & cpAnsi
- dl& = GetCPInfo(cpAnsi, cp)
- Print " Max byte length is " & cp.MaxCharSize
- dl& = GetCPInfo(cpOEM, cp)
- Print " OEM code page: " & cpOEM
- Print " Max byte length is " & cp.MaxCharSize
- dl& = GetKeyboardLayoutName(layoutname)
- Print " Keyboard layout: " & LPSTRToVBString(layoutname)
- dl& = GetKeyboardType(0)
- Select Case dl&
- Case 0
- Print " PC 83 key keyboard"
- Case 3
- Print " AT 84 key keyboard"
- Case 4
- Print " Enhanced 101 or 102 key keyboard"
- Case Else
- Print " Special keyboard"
- End Select
- dl& = GetKeyboardType(2)
- Print " Keyboard has " & dl & " function keys."
- #Else
- Print " Not implemented under Win16 at this time"
- #End If
- End Sub
- ' Locale specific information
- Private Sub MenuLocale_Click()
- Dim buffer As String * 100
- Dim dl&
- SysInfo.Cls
- #If Win32 Then
- dl& = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, buffer, 99)
- Print " Language: " & LPSTRToVBString(buffer)
- dl& = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SENGCOUNTRY, buffer, 99)
- Print " Country: " & LPSTRToVBString(buffer)
- dl& = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SCURRENCY, buffer, 99)
- Print " Currency Symbol: " & LPSTRToVBString(buffer)
- dl& = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, buffer, 99)
- Print " Long date format: " & LPSTRToVBString(buffer)
- dl& = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDAYNAME3, buffer, 99)
- Print " Long name for Wednesday: " & LPSTRToVBString(buffer)
- dl& = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME3, buffer, 99)
- Print " Abbreviation for Wednesday: " & LPSTRToVBString(buffer)
- #Else
- Print " Not implemented under Win16"
- #End If
- End Sub
- ' The following is a selection of the system metrics
- ' that can be determined - see the reference section
- ' under the GetSystemMetrics function for more.
- Private Sub MenuMetrics_Click()
- ShowColors 0
- SysInfo.Cls
- Print
- Print " Non sizeable border width,height = "; GetSystemMetrics(SM_CXBORDER); ","; GetSystemMetrics(SM_CYBORDER)
- Print " Caption height = "; GetSystemMetrics(SM_CYCAPTION)
- Print " Cursor width,height = "; GetSystemMetrics(SM_CXCURSOR); ","; GetSystemMetrics(SM_CYCURSOR)
- Print " Icon width,height = "; GetSystemMetrics(SM_CXICON); ","; GetSystemMetrics(SM_CYICON)
- Print " Width,Height of client area of full screen window = "; GetSystemMetrics(SM_CXFULLSCREEN); ","; GetSystemMetrics(SM_CYFULLSCREEN)
- Print " Menu bar height = "; GetSystemMetrics(SM_CYMENU)
- Print " Minimum width,height of window = "; GetSystemMetrics(SM_CXMIN); ","; GetSystemMetrics(SM_CYMIN)
- ' Here is a sample Windows 95 specific metric
- #If Win32 Then
- If myVer.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
- Print " Small Icon width,height = "; GetSystemMetrics(SM_CXSMICON); ","; GetSystemMetrics(SM_CYSMICON)
- End If
- #End If
- End Sub
- ' A few examples of the many system parameters that can
- ' be set and retreived using the SystemParametersInfo
- ' function
- Private Sub MenuParameters_Click()
- Dim dummy&
- SysInfo.Cls
- #If Win32 Then
- Dim intval&
- #Else
- Dim intval%
- #End If
- ShowColors 0
- SysInfo.Cls
- Print
- dummy = SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, intval, 0)
- Print " Keyboard Delay is "; intval
- dummy = SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, intval, 0)
- Print " Keyboard Speed is "; intval
- dummy = SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, intval, 0)
- If intval Then Print " Screen Saver is Active"
- dummy = SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, intval, 0)
- Print " Screen Save Delay is "; intval; " seconds"
- End Sub
- Private Sub MenuTimes_Click()
- Dim curtime&
- ShowColors 0
- SysInfo.Cls
- Print
- Print " Caret blinks every "; GetCaretBlinkTime(); " ms"
- #If Win16 Then
- curtime& = GetCurrentTime()
- #Else
- curtime& = GetTickCount()
- #End If
- Print " It's been "; curtime&; " ms since Windows was started"
- Print " The last Windows message was processed at "; GetMessageTime&(); " ms"
- Print " Two clicks within "; GetDoubleClickTime(); " ms of each other are a double click"
- #If Win16 Then
- Print " Timer resolution is "; GetTimerResolution&(); "microseconds per tick"
- #End If
- End Sub
- ' Use to show or hide the colors listbox and label
- Private Sub ShowColors(bflag%)
- If bflag% Then ' Show them
- ListColor.Visible = -1
- LabelColor.Visible = -1
- Else ' Hide them
- ListColor.Visible = 0
- LabelColor.Visible = 0
- End If
- End Sub
- ' This shows how a custom caret can be used in a text
- ' box. Note that an arbitrary bitmap could be used as
- ' well (refer to the function reference for the
- ' CreateCaret function - also chapter 8 for information
- ' on bitmaps).
- ' Also note that VB may change the caret back to the
- ' default without notice (like when a menu or other
- ' application is selected)
- Private Sub Text1_GotFocus()
- ' Save the original blink time - it will be used to
- ' restore the original value during the LostFocus event
- OriginalCaretBlinkTime% = GetCaretBlinkTime()
- ' Creat a different shaped caret
- CreateCaret Text1.hwnd, 0, 10, 15
- ' Creating the new caret caused the prior one (the
- ' default for the edit control) to be destroyed and
- ' thus hidden. So we must show the new caret.
- ShowCaret Text1.hwnd
- ' And change to an obnoxiously fast blink time - just
- ' to show how it's done.
- SetCaretBlinkTime 150
- End Sub
- ' Be sure to set the caret blink time back to its
- ' original value when the control loses the focus
- Private Sub Text1_LostFocus()
- SetCaretBlinkTime OriginalCaretBlinkTime%
- End Sub
- ' Update a label field to show the current state
- ' of the capslock, numlock and scroll lock keys
- Private Sub Timer1_Timer()
- Dim numlock%, scrolllock%, capslock%
- Dim keyarray(256) As Byte
- Dim dl&
- Dim res$
- capslock% = GetKeyState%(VK_CAPITAL)
- numlock% = GetKeyState%(VK_NUMLOCK)
-
- ' Here's another way to do it - take a snapshot
- ' of the entire keyboard
- dl& = GetKeyboardState(keyarray(0))
- scrolllock% = keyarray(VK_SCROLL) ' GetKeyState%(VK_SCROLL)
- ' The low bit indicates the state of the toggle
- If capslock% And 1 Then res$ = res$ + "CAPS "
- If numlock% And 1 Then res$ = res$ + "NUM "
- If scrolllock% And 1 Then res$ = res$ + "SCROLL"
- LabelKeyState.Caption = res$
- End Sub
-