-
-
Save marianz-bonfire/7feedcd0d302e613f2d4bf0b9b29661d to your computer and use it in GitHub Desktop.
C# Check if the machine is Laptop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make sure usings are included