检查计算机是AC还是DC

def getACstatue():
    import ctypes
    from ctypes import wintypes
    class SYSTEM_POWER_STATUS(ctypes.Structure):
        _fields_ = [
            ('ACLineStatus', wintypes.BYTE),
        ]

    SYSTEM_POWER_STATUS_P = ctypes.POINTER(SYSTEM_POWER_STATUS)
    GetSystemPowerStatus = ctypes.windll.kernel32.GetSystemPowerStatus
    GetSystemPowerStatus.argtypes = [SYSTEM_POWER_STATUS_P]
    GetSystemPowerStatus.restype = wintypes.BOOL

    status = SYSTEM_POWER_STATUS()
    if not GetSystemPowerStatus(ctypes.pointer(status)):
        raise ctypes.WinError()
    print('ACLineStatus', status.ACLineStatus)
    return ('ACLineStatus', status.ACLineStatus)
getACstatue()

运行后出现下面信息,说明是AC状态

检查计算机是AC还是DC_第1张图片

 

你可能感兴趣的:(python,python)