C + + to determine whether a laptop computer

Source: Internet
Author: User
First we know that the difference between a desktop and a laptop is whether it has a power supply

If the API that reads the power information provides a return value, is it possible to conclude that it is a laptop or a desktop computer?


Let's look at an API


GetSystemPowerStatus function

We can generally know

This is a function of retrieving the power state of the system, which indicates whether the system is DC or AC, and the current load of the battery is emptied and so on.


Let me take a look at the parameters:

System_power_status

We can see batterflag this member, he loaded the battery status and included the logo

When the value is 128 and 255, the reaction is no voltage or read voltage,

So you can hit the following code:

#include <Windows.h>  #include <stdio.h>    int main ()  {      system_power_status A;      GetSystemPowerStatus (&a);        if (A.batteryflag = = && A.batteryflag = = 255)      {          printf ("desktop computer \ n");      }      else      {          printf ("Portable computer \ n");      }        return 0;  }

Operation Result:


The above is the C/s + + judgment is the content of notebook computer, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!


  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.