title: How to check the machine type? laptop or desktop?
body: <p>How to check current machine type? laptop or desktop ?</p>
  
  <p>I got this from <a href="http://blog.csdn.net/antimatterworld/archive/2007/11/11/1878710.aspx" rel="noreferrer">http://blog.csdn.net/antimatterworld/archive/2007/11/11/1878710.aspx</a> ,it works well on my home machine(Win2003 on laptop), it returns "Portable", but failed on my work machine(Vista on laptop), it returns "Other".</p>
  
  <p>here is the code:</p>
  
  <pre><code>
  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 &lt; 25)
              {
                  return (ChassisTypes)i;
              }
          }
      }
      return ChassisTypes.Unknown;
  }
  </code>
  </pre>