Finding If a Computer Is a Laptop

I’ve ran recently across this question: how to find (using C++) if a computer is a laptop? That is possible with WMI and many answers (such as this) point to the Win32_SystemEnclosure class. This class has a member called ChassisTypes, which is an array of integers indicating possible chassis types. At least one of them should indicate a laptop. However, there might be several problems with this solution. First, there are several values for “laptops”:

  • 8 – Portable
  • 9 – Laptop
  • 10 – Notebook

Different machines might return different values. And more important, this property might not be defined on all computers. A more reliable solution is explained in this TechNet article Finding Computers That Are Laptops. The solution described there suggests checking for several properties:

  • Win32_SystemEnclosure, ChassisTypes(1)=10.
  • Win32_Battery or Win32_PortableBattery.
  • Win32_PCMCIAController
  • Win32_DriverVXD.Name = “pccard”
  • Win32_ComputerSystem.Manufacturer
  • Win32_ComputerSystem.Model

The following code shows how one can query for the chassis types using C++. Run queries for the other properties to make sure you are running on a laptop.

On my laptop, the program output was:

Name: System Enclosure
Chassis: Notebook

8 Replies to “Finding If a Computer Is a Laptop”

  1. The file names in the include statements are missing, so I can’t compile this and learn from your efforts. Could you update this please?

  2. Thanks. This is a learning

    Was there a specific reason you need not make use of WMI query was of extracting the data? i have done in C# and found it shorter

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.