C # How to Determine the computer type (desktop or notebook)

Source: Internet
Author: User

How to determine the computer type? A simple method is to query the win32_systemenclosure class Through WMI, and chassistypes indicates the computer type. There are 22 known types, which we usually cannot see. The most common types are desptop (3), laptop (9) (older models), and notebook (10 ).

The system. Management namespace must be referenced.

The following is the sample code:

Using system. Management;

Public Enum chassistypes
{
Other = 1,
Unknown,
Desktop,
Lowprofiledesktop,
Pizzabox,
Minitower,
Tower,
Portable,
Laptop,
Notebook,
Handheld,
Dockingstation,
Allinone,
Subnotebook,
Spacesaving,
Lunchbox,
Mainsystemchassis,
Expansionchassis,
Subchassis,
Busexpansionchassis,
Peripheralchassis,
Storagechassis,
Rackmountchassis,
Sealedcasepc
}

Public static chassistypes getcurrentchassistype ()
{
Managementclass systemenclosures = new managementclass ("win32_systemenclosure ");
Foreach (managementobject OBJ in systemenclosures. getinstances ())
{
Foreach (int I in (uint16 []) (OBJ ["chassistypes"])
{
If (I> 0 & I <25)
{
Return (chassistypes) I;
}
}
}
Return chassistypes. Unknown;
}

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/vrhero/archive/2007/11/08/1874042.aspx

Related Article

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.