{"id":824,"date":"2011-01-05T16:18:51","date_gmt":"2011-01-05T14:18:51","guid":{"rendered":"http:\/\/mariusbancila.ro\/blog\/?p=824"},"modified":"2011-05-19T15:17:16","modified_gmt":"2011-05-19T13:17:16","slug":"finding-if-a-computer-is-a-laptop","status":"publish","type":"post","link":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/","title":{"rendered":"Finding If a Computer Is a Laptop"},"content":{"rendered":"<p>I&#8217;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 <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2004\/09\/21\/how-can-i-determine-if-a-computer-is-a-laptop-or-a-desktop-machine.aspx\">this<\/a>) point to the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/Aa394474\">Win32_SystemEnclosure<\/a> 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 &#8220;laptops&#8221;:<\/p>\n<ul>\n<li>8 &#8211; Portable<\/li>\n<li>9 &#8211; Laptop<\/li>\n<li>10 &#8211; Notebook<\/li>\n<\/ul>\n<p>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 <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/cc180825.aspx\">Finding Computers That Are Laptops<\/a>. The solution described there suggests checking for several properties:<\/p>\n<ul>\n<li>Win32_SystemEnclosure, ChassisTypes(1)=10.<\/li>\n<li>Win32_Battery or Win32_PortableBattery.<\/li>\n<li>Win32_PCMCIAController<\/li>\n<li>Win32_DriverVXD.Name = &#8220;pccard&#8221;<\/li>\n<li>Win32_ComputerSystem.Manufacturer<\/li>\n<li>Win32_ComputerSystem.Model<\/li>\n<\/ul>\n<p>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.<\/p>\n<pre name=\"code\" class=\"cpp\">\r\n#define _WIN32_DCOM\r\n\r\n#include &lt;iostream&gt;\r\nusing namespace std;\r\n\r\n#include &lt;comdef.h&gt;\r\n#include &lt;Wbemidl.h&gt;\r\n\r\n#pragma comment(lib, \"wbemuuid.lib\")\r\n\r\nclass WMIQuery\r\n{\r\n   IWbemLocator* m_pLocator;\r\n   IWbemServices* m_pServices;\r\n\r\npublic:\r\n   WMIQuery():\r\n      m_pLocator(NULL),\r\n      m_pServices(NULL)\r\n   {\r\n   }\r\n\r\n   bool Initialize()\r\n   {\r\n      \/\/ Obtain the initial locator to WMI\r\n      HRESULT hr = ::CoCreateInstance(\r\n         CLSID_WbemLocator,             \r\n         0, \r\n         CLSCTX_INPROC_SERVER, \r\n         IID_IWbemLocator, (LPVOID *) &amp;m_pLocator);\r\n\r\n      if (FAILED(hr))\r\n      {\r\n         cerr &lt;&lt; \"Failed to create IWbemLocator object. Err code = 0x\" &lt;&lt; hex &lt;&lt; hr &lt;&lt; endl;\r\n         return false;\r\n      }\r\n\r\n      \/\/ Connect to WMI through the IWbemLocator::ConnectServer method\r\n      \/\/ Connect to the root\\cimv2 namespace with the current user \r\n      hr = m_pLocator->ConnectServer(\r\n         _bstr_t(L\"ROOT\\\\CIMV2\"), \/\/ Object path of WMI namespace\r\n         NULL,                    \/\/ User name. NULL = current user\r\n         NULL,                    \/\/ User password. NULL = current\r\n         0,                       \/\/ Locale. NULL indicates current\r\n         NULL,                    \/\/ Security flags.\r\n         0,                       \/\/ Authority (e.g. Kerberos)\r\n         0,                       \/\/ Context object \r\n         &amp;m_pServices             \/\/ pointer to IWbemServices proxy\r\n         );\r\n\r\n      if (FAILED(hr))\r\n      {\r\n         cerr &lt;&lt; \"Could not connect. Error code = 0x\" &lt;&lt; hex &lt;&lt; hr &lt;&lt; endl;\r\n         m_pLocator->Release();\r\n         m_pLocator = NULL;\r\n         return false;\r\n      }\r\n\r\n      \/\/ Set security levels on the proxy\r\n      hr = ::CoSetProxyBlanket(\r\n         m_pServices,                 \/\/ Indicates the proxy to set\r\n         RPC_C_AUTHN_WINNT,           \/\/ RPC_C_AUTHN_xxx\r\n         RPC_C_AUTHZ_NONE,            \/\/ RPC_C_AUTHZ_xxx\r\n         NULL,                        \/\/ Server principal name \r\n         RPC_C_AUTHN_LEVEL_CALL,      \/\/ RPC_C_AUTHN_LEVEL_xxx \r\n         RPC_C_IMP_LEVEL_IMPERSONATE, \/\/ RPC_C_IMP_LEVEL_xxx\r\n         NULL,                        \/\/ client identity\r\n         EOAC_NONE                    \/\/ proxy capabilities \r\n         );\r\n\r\n      if (FAILED(hr))\r\n      {\r\n         cerr &lt;&lt; \"Could not set proxy blanket. Error code = 0x\" &lt;&lt; hex &lt;&lt; hr &lt;&lt; endl;\r\n         m_pServices->Release();\r\n         m_pServices = NULL;\r\n         m_pLocator->Release();\r\n         m_pLocator = NULL;\r\n         return false;\r\n      }\r\n\r\n      return true;\r\n   }\r\n\r\n   IEnumWbemClassObject* Query(LPCTSTR strquery)\r\n   {\r\n      IEnumWbemClassObject* pEnumerator = NULL;\r\n      HRESULT hr = m_pServices->ExecQuery(\r\n         bstr_t(\"WQL\"), \r\n         bstr_t(strquery),\r\n         WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, \r\n         NULL,\r\n         &amp;pEnumerator);\r\n\r\n      if (FAILED(hr))\r\n      {\r\n         cerr &lt;&lt; \"Query for operating system name failed. Error code = 0x\" &lt;&lt; hex &lt;&lt; hr &lt;&lt; endl;\r\n         return NULL;\r\n      }\r\n\r\n      return pEnumerator;\r\n   }\r\n\r\n   ~WMIQuery()\r\n   {\r\n      if(m_pServices != NULL)\r\n      {\r\n         m_pServices->Release();\r\n         m_pServices = NULL;\r\n      }\r\n\r\n      if(m_pLocator != NULL)\r\n      {\r\n         m_pLocator->Release();\r\n         m_pLocator = NULL;\r\n      }\r\n   }\r\n};\r\n\r\nint _tmain(int argc, _TCHAR* argv[])\r\n{\r\n   HRESULT hres;\r\n\r\n   \/\/ Initialize COM.\r\n   hres =  ::CoInitializeEx(0, COINIT_MULTITHREADED); \r\n   if (FAILED(hres))\r\n   {\r\n      cout &lt;&lt; \"Failed to initialize COM library. Error code = 0x\" &lt;&lt; hex &lt;&lt; hres &lt;&lt; endl;\r\n      return 1;\r\n   }\r\n\r\n   \/\/ Set general COM security levels\r\n   hres =  ::CoInitializeSecurity(\r\n      NULL, \r\n      -1,                          \/\/ COM authentication\r\n      NULL,                        \/\/ Authentication services\r\n      NULL,                        \/\/ Reserved\r\n      RPC_C_AUTHN_LEVEL_DEFAULT,   \/\/ Default authentication \r\n      RPC_C_IMP_LEVEL_IMPERSONATE, \/\/ Default Impersonation  \r\n      NULL,                        \/\/ Authentication info\r\n      EOAC_NONE,                   \/\/ Additional capabilities \r\n      NULL                         \/\/ Reserved\r\n      );\r\n\r\n   if (FAILED(hres))\r\n   {\r\n      cout &lt;&lt; \"Failed to initialize security. Error code = 0x\" &lt;&lt; hex &lt;&lt; hres &lt;&lt; endl;\r\n      ::CoUninitialize();\r\n      return 1;\r\n   }\r\n   else\r\n   {\r\n      WMIQuery query;\r\n      if(query.Initialize())\r\n      {\r\n         IEnumWbemClassObject* pEnumerator = query.Query(_T(\"SELECT * FROM Win32_SystemEnclosure\"));\r\n\r\n         if(pEnumerator != NULL)\r\n         {\r\n            \/\/ Get the data from the query\r\n            IWbemClassObject *pclsObj;\r\n            ULONG uReturn = 0;\r\n\r\n            while (pEnumerator)\r\n            {\r\n               HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &amp;pclsObj, &amp;uReturn);\r\n\r\n               if(0 == uReturn)\r\n               {\r\n                  break;\r\n               }\r\n\r\n               VARIANT vtProp;\r\n\r\n               hr = pclsObj->Get(L\"Name\", 0, &amp;vtProp, 0, 0);\r\n               wcout &lt;&lt; \"Name:    \" &lt;&lt; vtProp.bstrVal &lt;&lt; endl;\r\n\r\n               hr = pclsObj->Get(L\"ChassisTypes\", 0, &amp;vtProp, 0, 0);\r\n               wcout &lt;&lt; \"Chassis: \";\r\n               SAFEARRAY* parrValues = NULL;\r\n               \r\n               if (vtProp.vt &amp; VT_ARRAY)\r\n               {\r\n                  if (VT_BYREF &amp; vtProp.vt)\r\n                     parrValues = *vtProp.pparray;\r\n                  else\r\n                     parrValues = vtProp.parray;\r\n               }\r\n\r\n               if (parrValues != NULL)\r\n               {\r\n                  SAFEARRAYBOUND arrayBounds[1];\r\n                  arrayBounds[0].lLbound = 0;\r\n                  arrayBounds[0].cElements = 0;\r\n\r\n                  SafeArrayGetLBound(parrValues, 1, &amp;arrayBounds[0].lLbound);\r\n                  SafeArrayGetUBound(parrValues, 1, (long*)&amp;arrayBounds[0].cElements);\r\n                  arrayBounds[0].cElements -= arrayBounds[0].lLbound;\r\n                  arrayBounds[0].cElements += 1;\r\n\r\n                  if (arrayBounds[0].cElements > 0)\r\n                  {\r\n                     for (ULONG i = 0; i &lt; arrayBounds[0].cElements; i++)\r\n                     {\r\n                        LONG lIndex = (LONG)i;\r\n                        INT item;\r\n\r\n                        HRESULT hr = ::SafeArrayGetElement(parrValues, &amp;lIndex, &amp;item);\r\n\r\n                        if(SUCCEEDED(hr))\r\n                        {\r\n                           LPCTSTR szType = NULL;\r\n                           switch(item)\r\n                           {\r\n                           case 1: szType = _T(\"Other\"); break;\r\n                           case 2: szType = _T(\"Unknown\"); break;\r\n                           case 3: szType = _T(\"Desktop\"); break;\r\n                           case 4: szType = _T(\"Low Profile Desktop\"); break;\r\n                           case 5: szType = _T(\"Pizza Box\"); break;\r\n                           case 6: szType = _T(\"Mini Tower\"); break;\r\n                           case 7: szType = _T(\"Tower\"); break;\r\n                           case 8: szType = _T(\"Portable\"); break;\r\n                           case 9: szType = _T(\"Laptop\"); break;\r\n                           case 10:szType = _T(\"Notebook\"); break;\r\n                           case 11:szType = _T(\"Hand Held\"); break;\r\n                           case 12:szType = _T(\"Docking Station\"); break;\r\n                           case 13:szType = _T(\"All in One\"); break;\r\n                           case 14:szType = _T(\"Sub Notebook\"); break;\r\n                           case 15:szType = _T(\"Space-Saving\"); break;\r\n                           case 16:szType = _T(\"Lunch Box\"); break;\r\n                           case 17:szType = _T(\"Main System Chassis\"); break;\r\n                           case 18:szType = _T(\"Expansion Chassis\"); break;\r\n                           case 19:szType = _T(\"SubChassis\"); break;\r\n                           case 20:szType = _T(\"Bus Expansion Chassis\"); break;\r\n                           case 21:szType = _T(\"Peripheral Chassis\"); break;\r\n                           case 22:szType = _T(\"Storage Chassis\"); break;\r\n                           case 23:szType = _T(\"Rack Mount Chassis\"); break;\r\n                           case 24:szType = _T(\"Sealed-Case PC\"); break;\r\n                           }\r\n                           wcout &lt;&lt; szType;\r\n                           if(i+1 &lt; arrayBounds[0].cElements)\r\n                              wcout &lt;&lt; \", \";\r\n                        }\r\n                     }\r\n\r\n                     wcout &lt;&lt; endl;\r\n                  }\r\n               }\r\n\r\n               VariantClear(&amp;vtProp);\r\n\r\n               pclsObj->Release();\r\n            }\r\n\r\n            pEnumerator->Release();\r\n         }\r\n      }\r\n   }\r\n\r\n   ::CoUninitialize();\r\n\r\n   return 0;\r\n}\r\n<\/pre>\n<p>On my laptop, the program output was:<\/p>\n<blockquote><p>\nName:    System Enclosure<br \/>\nChassis: Notebook\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;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 &#8230; <a title=\"Finding If a Computer Is a Laptop\" class=\"read-more\" href=\"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/\" aria-label=\"Read more about Finding If a Computer Is a Laptop\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","advgb_blocks_editor_width":"","advgb_blocks_columns_visual_guide":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[7,211],"tags":[451,461,253,252],"class_list":["post-824","post","type-post","status-publish","format-standard","hentry","category-c","category-com","tag-c","tag-com","tag-query","tag-wmi"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"Learn how to find if a computer is a laptop using C++ and WMI.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Marius Bancila\"\/>\n\t<meta name=\"keywords\" content=\"com,wmi,c++,query,laptop\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Marius Bancila&#039;s Blog | About code. Mostly on C++\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Finding If a Computer Is a Laptop\" \/>\n\t\t<meta property=\"og:description\" content=\"Learn how to find if a computer is a laptop using C++ and WMI.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2011-01-05T14:18:51+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2011-05-19T13:17:16+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Finding If a Computer Is a Laptop\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Learn how to find if a computer is a laptop using C++ and WMI.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2011\\\/01\\\/05\\\/finding-if-a-computer-is-a-laptop\\\/#article\",\"name\":\"Finding If a Computer Is a Laptop\",\"headline\":\"Finding If a Computer Is a Laptop\",\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"},\"datePublished\":\"2011-01-05T16:18:51+02:00\",\"dateModified\":\"2011-05-19T15:17:16+02:00\",\"inLanguage\":\"en-US\",\"commentCount\":8,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2011\\\/01\\\/05\\\/finding-if-a-computer-is-a-laptop\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2011\\\/01\\\/05\\\/finding-if-a-computer-is-a-laptop\\\/#webpage\"},\"articleSection\":\"C++, COM, C++, COM, query, WMI\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2011\\\/01\\\/05\\\/finding-if-a-computer-is-a-laptop\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"position\":2,\"name\":\"IT\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"position\":3,\"name\":\"Software\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"position\":4,\"name\":\"C++\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2011\\\/01\\\/05\\\/finding-if-a-computer-is-a-laptop\\\/#listItem\",\"name\":\"Finding If a Computer Is a Laptop\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2011\\\/01\\\/05\\\/finding-if-a-computer-is-a-laptop\\\/#listItem\",\"position\":5,\"name\":\"Finding If a Computer Is a Laptop\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/\",\"name\":\"Marius Bancila\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2011\\\/01\\\/05\\\/finding-if-a-computer-is-a-laptop\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Marius Bancila\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2011\\\/01\\\/05\\\/finding-if-a-computer-is-a-laptop\\\/#webpage\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2011\\\/01\\\/05\\\/finding-if-a-computer-is-a-laptop\\\/\",\"name\":\"Finding If a Computer Is a Laptop\",\"description\":\"Learn how to find if a computer is a laptop using C++ and WMI.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2011\\\/01\\\/05\\\/finding-if-a-computer-is-a-laptop\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2011-01-05T16:18:51+02:00\",\"dateModified\":\"2011-05-19T15:17:16+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Finding If a Computer Is a Laptop","description":"Learn how to find if a computer is a laptop using C++ and WMI.","canonical_url":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/","robots":"max-image-preview:large","keywords":"com,wmi,c++,query,laptop","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/#article","name":"Finding If a Computer Is a Laptop","headline":"Finding If a Computer Is a Laptop","author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"},"datePublished":"2011-01-05T16:18:51+02:00","dateModified":"2011-05-19T15:17:16+02:00","inLanguage":"en-US","commentCount":8,"mainEntityOfPage":{"@id":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/#webpage"},"isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/#webpage"},"articleSection":"C++, COM, C++, COM, query, WMI"},{"@type":"BreadcrumbList","@id":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/mariusbancila.ro\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","position":2,"name":"IT","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","position":3,"name":"Software","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","position":4,"name":"C++","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/#listItem","name":"Finding If a Computer Is a Laptop"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/#listItem","position":5,"name":"Finding If a Computer Is a Laptop","previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"}}]},{"@type":"Organization","@id":"https:\/\/mariusbancila.ro\/blog\/#organization","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","url":"https:\/\/mariusbancila.ro\/blog\/"},{"@type":"Person","@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author","url":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/","name":"Marius Bancila","image":{"@type":"ImageObject","@id":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g","width":96,"height":96,"caption":"Marius Bancila"}},{"@type":"WebPage","@id":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/#webpage","url":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/","name":"Finding If a Computer Is a Laptop","description":"Learn how to find if a computer is a laptop using C++ and WMI.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/#breadcrumblist"},"author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"creator":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"datePublished":"2011-01-05T16:18:51+02:00","dateModified":"2011-05-19T15:17:16+02:00"},{"@type":"WebSite","@id":"https:\/\/mariusbancila.ro\/blog\/#website","url":"https:\/\/mariusbancila.ro\/blog\/","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","inLanguage":"en-US","publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Marius Bancila's Blog | About code. Mostly on C++","og:type":"article","og:title":"Finding If a Computer Is a Laptop","og:description":"Learn how to find if a computer is a laptop using C++ and WMI.","og:url":"https:\/\/mariusbancila.ro\/blog\/2011\/01\/05\/finding-if-a-computer-is-a-laptop\/","article:published_time":"2011-01-05T14:18:51+00:00","article:modified_time":"2011-05-19T13:17:16+00:00","twitter:card":"summary","twitter:title":"Finding If a Computer Is a Laptop","twitter:description":"Learn how to find if a computer is a laptop using C++ and WMI."},"aioseo_meta_data":{"post_id":"824","title":"Finding If a Computer Is a Laptop","description":"Learn how to find if a computer is a laptop using C++ and WMI.","keywords":[{"label":"COM","value":"COM"},{"label":"WMI","value":"WMI"},{"label":"C++","value":"C++"},{"label":"query","value":"query"},{"label":"laptop","value":"laptop"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-03-18 21:13:46","updated":"2025-12-12 07:35:21","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"author_meta":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"featured_img":null,"jetpack_publicize_connections":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"uagb_comment_info":8,"uagb_excerpt":"I&#8217;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&hellip;","coauthors":[],"tax_additional":{"categories":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/com\/\" class=\"advgb-post-tax-term\">COM<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">COM<\/span>"]},"tags":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/com\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/com\/\" class=\"advgb-post-tax-term\">COM<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/com\/\" class=\"advgb-post-tax-term\">query<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/com\/\" class=\"advgb-post-tax-term\">WMI<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">COM<\/span>","<span class=\"advgb-post-tax-term\">query<\/span>","<span class=\"advgb-post-tax-term\">WMI<\/span>"]}},"comment_count":"8","relative_dates":{"created":"Posted 16 years ago","modified":"Updated 15 years ago"},"absolute_dates":{"created":"Posted on January 5, 2011","modified":"Updated on May 19, 2011"},"absolute_dates_time":{"created":"Posted on January 5, 2011 4:18 pm","modified":"Updated on May 19, 2011 3:17 pm"},"featured_img_caption":"","series_order":"","jetpack_shortlink":"https:\/\/wp.me\/pYNdv-di","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/comments?post=824"}],"version-history":[{"count":6,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/824\/revisions"}],"predecessor-version":[{"id":985,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/824\/revisions\/985"}],"wp:attachment":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/media?parent=824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/categories?post=824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/tags?post=824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}