2010-11-08 用VB判斷電腦是NB還是PC(VB) (VB) 36745 0 VB 用VB判斷電腦是NB還是PC(VB) (VB) 用VB判斷是筆電(筆記型電腦 NOTEBOOK)還是桌機(桌上型電腦 PC)我的想法是 NB需要電池,PC不用,所以 就由判斷電池剩於容量來區分是NB還是PCPrivate Declare Function GetSystemPowerStatus Lib "kernel32" (lpSystemPowerStatus As SYSTEM_POWER_STATUS) As Long ' 自訂型態 Private Type SYSTEM_POWER_STATUS ACLineStatus As Byte BatteryFlag As Byte BatteryLifePercent As Byte Reserved1 As Byte BatteryLifeTime As Long BatteryFullLifeTime As Long End Type Private Sub cmdBatteryLife_Click() Dim SysPower As SYSTEM_POWER_STATUS Dim strLifeTime As String, strLifePercent As String GetSystemPowerStatus SysPower ' Call API 取得系統電池計量 If SysPower.BatteryLifePercent = 255 Then '桌電一定是255 Debug.Print "PC" Else '如果 是筆電一定小於101 Debug.Print "NB" End If End Sub 如有錯誤 歡迎指正 回首頁