Detect if the application is running on a laptop

Possible duplicate:
How do I know if a user is using a laptop?

I am trying to figure out if the application is working on a laptop or desktop, any ideas on how to do this?

Note: I'm only interested in the API written in Delphi and / or C ++.

EDIT: my target platform is Windows XP +, even Windows 7 is fine.

LAST EDIT : thank you all for your help, I created a unit with helper methods (in Delphi), do not hesitate to translate into C ++ or other languages ​​and / or expand (or fix) the flaws). The unit can be found here http://www.delphigeist.com/2011/02/laptop-specific-functions.html

+7
source share
6 answers

Use this structure: SYSTEM_POWER_STATUS and check the value of the ACLineStatus field.

  • ACLineStatus = 0 => The system does not use mains power> Laptop + battery
  • ACLineStatus = 1 => The system uses alternating current => Laptop + AC
  • ACLineStatus = 255 => Unknown AC power status => Desktop

Disclaimer Try experimenting with them. I do not claim that they are reliable. But they are almost correct.

-

EDIT:

Use GetSystemPowerStatus to get the value of the above structure.

By the way, you can also experiment with other fields of the structure; perhaps you can find a useful template that gives you some combination of the values ​​of different fields to help you reliably determine if the application is running on a laptop or not.

+15
source

I don’t think that there is a standard way to check if the application works on a laptop, but I think that there is also no standard justification for knowing this.

The fact is that a laptop is not so different from a desktop computer: there are laptops that never move, and I think it will be possible to create a desktop with a built-in UPS (is it considered a battery?)

I think you should find out if he has a laptop with the features needed to check on a laptop:

  • Do you want to know if this is a laptop because your application should behave differently if the computer can be moved? Then check if the battery is connected.

  • Want to find out if there is a laptop to check for hardware changes? In this case, check the model of the motherboard or ask using the dialog box.

  • You need to check this to see if it burns to death if you use it too much for too long? Just control the temperature ...

+9
source

I do not believe that there is a reliable way to detect this.

+4
source

Apparently, the hidden problem is that the laptops of the company, as a rule, do not have enough memory, but the companies work. To fix this particular problem, compare the memory used with the installed memory: EnumProcesses() and GetProcessMemoryInfo tells you the first; GetPhysicallyInstalledSystemMemory() tells you the second.

If they are too close, you can tell the user that there are 73 running processes using 2.5 GB, but only 2 GB of RAM is present. This is the real reason why your program does not start.

+3
source

MSDN discusses the API for Power and Device Aware applications here.

You can also check other things, for example:

  • Is the battery connected?
  • The track panel is connected.
  • Is a PC card inserted?
  • Has a certain type of processor (low power, Atom, etc.)
  • Unique laptop screen.
  • 3.5 "Laptop Hard Drive

If the specific number above is correct, then you can read the laptop.

You can also just ask the user during installation.

+2
source

Here are a few other answers and links that may come in handy for this question:

How to determine when the laptop is running on batteries?

How do I know if a user is using a laptop?

The latter also discusses WMI, and the answer is centered around .NET. You can use WMI from Delphi.

+1
source

All Articles