How can I identify the computer as a Laptop or PC/Desktop.
Posted: Fri Jun 21, 2024 5:58 am
I am new to PB. My primary language is not US/UK. I am using Google Translate.
I tried the following code snippets, but could not get the job done.
Please help. Thanks.
I tried the following code snippets, but could not get the job done.
Please help. Thanks.
Code: Select all
; https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-system_power_status?redirectedfrom=MSDN
Define.SYSTEM_POWER_STATUS SPS
GetSystemInfo_(SPS)
Debug "SPS\ACLineStatus: " + SPS\ACLineStatus ; Với PC/Desktop, trả về 0. Với laptop, nếu trả về 0, nghĩa là laptop không cắm dây sạc
Debug "SPS\BatteryFlag: " + SPS\BatteryFlag ; Với PC/Desktop, trả về 0.
; https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getsystempowerstatus?redirectedfrom=MSDN
; Truy xuất trạng thái nguồn của hệ thống.
; Trạng thái cho biết hệ thống đang chạy bằng nguồn AC hay DC, pin hiện đang sạc hay không,
; thời lượng pin còn lại là bao nhiêu và chế độ tiết kiệm pin đang bật hay tắt.
Debug "SPS\GetSystemPowerStatus_: " + GetSystemPowerStatus_(SPS)
If GetSystemPowerStatus_(SPS) = #True
Debug "PowerStatus is available."
Else
Debug "Powerstatus cannot be detected."
EndIf