How to check the machine type in C#
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 ChassisTypes GetCurrentChassisType()
{
	try
	{
		ManagementClass mc = new ManagementClass("Win32_SystemEnclosure");
		foreach (ManagementObject mo in mc.GetInstances())
			foreach (int i in (UInt16[])(mo["ChassisTypes"]))
				if (i > 0 && i < 25)
					return (ChassisTypes)i;
		return ChassisTypes.Unknown;
	}
	catch
	{
		return ChassisTypes.Unknown;
	}
}
Categories: C# Tags: , , , , ,
%d bloggers like this: