SysInfo Control
Provides system event monitoring, including notifications for device changes, power status, display setting changes, and theme changes. Invisible at runtime.
Enumerations
SysDeviceTypeConstants
Device type constants.
| Constant | Value | Description |
|---|---|---|
| SysDeviceTypeOEM | DBT_DEVTYP_OEM | OEM device |
| SysDeviceTypeDevNode | DBT_DEVTYP_DEVNODE | Device node |
| SysDeviceTypeVolume | DBT_DEVTYP_VOLUME | Volume device |
| SysDeviceTypePort | DBT_DEVTYP_PORT | Port device |
| SysDeviceTypeDevInterface | DBT_DEVTYP_DEVICEINTERFACE | Device interface |
SysACStatusConstants
AC power status constants.
| Constant | Value | Description |
|---|---|---|
| SysACStatusOffline | 0 | Offline (on battery) |
| SysACStatusOnline | 1 | Online (on AC power) |
| SysACStatusUnknown | 255 | Unknown |
SysBatteryStatusConstants
Battery status constants.
| Constant | Value | Description |
|---|---|---|
| SysBatteryStatusHigh | 1 | Battery high |
| SysBatteryStatusLow | 2 | Battery low |
| SysBatteryStatusCritical | 4 | Battery critically low |
| SysBatteryStatusCharging | 8 | Battery charging |
| SysBatteryStatusNone | 128 | No battery |
| SysBatteryStatusUnknown | 255 | Unknown |
Properties
Name
Public Property Get Name() As StringReturns the name used to identify the object in code.
Tag
Public Property Get Tag() As String
Public Property Let Tag(ByVal Value As String)Stores extra data needed by the program.
Parent
Public Property Get Parent() As ObjectReturns the object that contains the object.
hMain
Public Property Get hMain() As LongPtrReturns the main window handle.
ACStatus
Public Property Get ACStatus() As SysACStatusConstantsReturns the AC power status.
BatteryFullTime
Public Property Get BatteryFullTime() As LongReturns the time remaining for the battery to be fully charged (seconds).
BatteryLifePercent
Public Property Get BatteryLifePercent() As IntegerReturns the remaining battery life percentage.
BatteryLifeTime
Public Property Get BatteryLifeTime() As LongReturns the remaining battery life (seconds).
BatteryStatus
Public Property Get BatteryStatus() As SysBatteryStatusConstantsReturns the battery status.
WorkAreaLeft
Public Property Get WorkAreaLeft() As SingleReturns the left margin of the work area.
WorkAreaTop
Public Property Get WorkAreaTop() As SingleReturns the top margin of the work area.
WorkAreaWidth
Public Property Get WorkAreaWidth() As SingleReturns the width of the work area.
WorkAreaHeight
Public Property Get WorkAreaHeight() As SingleReturns the height of the work area.
ScrollBarSize
Public Property Get ScrollBarSize() As SingleReturns the scrollbar size.
Events
SysColorsChanged
Public Event SysColorsChanged()Fired when system colors change.
SettingChanged
Public Event SettingChanged(ByVal Item As Long, ByVal Section As String)Fired when a system setting changes. Item is the setting item, Section is the setting section.
DevModeChanged
Public Event DevModeChanged()Fired when device mode changes.
TimeChanged
Public Event TimeChanged()Fired when the system time changes.
FontChanged
Public Event FontChanged()Fired when the system font changes.
DisplayChanged
Public Event DisplayChanged(ByVal NewColorDepth As Long, ByVal NewWidth As Single, ByVal NewHeight As Single)Fired when display settings change. NewColorDepth is the new color depth, NewWidth/NewHeight is the new resolution.
DeviceArrival
Public Event DeviceArrival(ByVal DeviceType As SysDeviceTypeConstants, ByVal DeviceID As Long, ByVal DeviceName As String, ByVal DeviceData As Long)Fired when a device is inserted.
DeviceQueryRemove
Public Event DeviceQueryRemove(ByVal DeviceType As SysDeviceTypeConstants, ByVal DeviceID As Long, ByVal DeviceName As String, ByVal DeviceData As Long, ByRef Cancel As Boolean)Fired when a device is about to be removed. Set Cancel to True to prevent removal.
DeviceQueryRemoveFailed
Public Event DeviceQueryRemoveFailed(ByVal DeviceType As SysDeviceTypeConstants, ByVal DeviceID As Long, ByVal DeviceName As String, ByVal DeviceData As Long)Fired when a device removal query fails.
DeviceRemoveComplete
Public Event DeviceRemoveComplete(ByVal DeviceType As SysDeviceTypeConstants, ByVal DeviceID As Long, ByVal DeviceName As String, ByVal DeviceData As Long)Fired when a device removal is completed.
DeviceRemovePending
Public Event DeviceRemovePending(ByVal DeviceType As SysDeviceTypeConstants, ByVal DeviceID As Long, ByVal DeviceName As String, ByVal DeviceData As Long)Fired when a device is about to be removed.
DevNodesChanged
Public Event DevNodesChanged()Fired when device nodes change.
QueryChangeConfig
Public Event QueryChangeConfig(ByRef Cancel As Boolean)Fired when the configuration is about to change. Set Cancel to True to prevent the change.
ConfigChangeCancelled
Public Event ConfigChangeCancelled()Fired when a configuration change is cancelled.
ConfigChanged
Public Event ConfigChanged()Fired when a configuration change is completed.
PowerQuerySuspend
Public Event PowerQuerySuspend(ByRef Cancel As Boolean)Fired when the system is about to suspend. Set Cancel to True to prevent suspension.
PowerQuerySuspendFailed
Public Event PowerQuerySuspendFailed()Fired when a system suspend request fails.
PowerResume
Public Event PowerResume()Fired when the system resumes from suspension.
PowerStatusChanged
Public Event PowerStatusChanged()Fired when power status changes.
PowerSuspend
Public Event PowerSuspend()Fired when the system is about to suspend.
ThemeChanged
Public Event ThemeChanged()Fired when the system theme changes.
Code Examples
Basic Usage
' Monitor power status
Private Sub SysInfo1_PowerStatusChanged()
Select Case SysInfo1.ACStatus
Case SysACStatusOnline
Debug.Print "On AC power"
Case SysACStatusOffline
Debug.Print "On battery, remaining: " & SysInfo1.BatteryLifePercent & "%"
End Select
End Sub
' Monitor device changes
Private Sub SysInfo1_DeviceArrival(ByVal DeviceType As SysDeviceTypeConstants, _
ByVal DeviceID As Long, ByVal DeviceName As String, ByVal DeviceData As Long)
Debug.Print "Device inserted: " & DeviceName
End Sub
' Monitor display setting changes
Private Sub SysInfo1_DisplayChanged(ByVal NewColorDepth As Long, _
ByVal NewWidth As Single, ByVal NewHeight As Single)
Debug.Print "Resolution: " & NewWidth & "x" & NewHeight & " Color depth: " & NewColorDepth
End Sub