AccessTr.neT
laptop batery - Baskı Önizleme

+- AccessTr.neT (https://accesstr.net)
+-- Forum: Microsoft Access (https://accesstr.net/forum-microsoft-access.html)
+--- Forum: Access Örnekleri ve Uygulamaları (https://accesstr.net/forum-access-ornekleri-ve-uygulamalari.html)
+--- Konu Başlığı: laptop batery (/konu-laptop-batery.html)



laptop batery - accessman - 04/05/2012

Kod:
Public Function getBatteryStatus() As Integer
  Dim obj As Object, obj2 As Object, stat As Integer
'  Get Battery Status
'  Return Value Meaning
'0 No battery
'1 The battery is discharging.
'2 The system has access to AC so no battery is being discharged. However, the battery is not necessarily charging.
'3 Fully Charged
'4 Low
'5 Critical
'6 Charging
'7 Charging and High
'8 Charging and Low
'9 Charging and Critical
'10 Undefined
'11 Partially Charged
  stat = 0
  Set obj = GetObject("winmgmts:").InstancesOf("Win32_Battery")
  For Each obj2 In obj 'loop in objects
    stat = obj2.BatteryStatus
  Next
  getBatteryStatus = stat
End Function

Kod:
Private Sub Form_Load()
    MsgBox "Battery status: " & getBatteryStatus(), vbInformation + vbOKOnly, "Battery Status"
    End
End Sub