{"id":838,"date":"2020-10-19T13:53:31","date_gmt":"2020-10-19T03:53:31","guid":{"rendered":"http:\/\/www.nickdu.com\/?p=838"},"modified":"2020-10-19T13:53:31","modified_gmt":"2020-10-19T03:53:31","slug":"get-processor-id-cpu-in-c","status":"publish","type":"post","link":"https:\/\/nickdu.com\/?p=838","title":{"rendered":"Get Processor Id (CPU) in C++"},"content":{"rendered":"\n<p>This piece of C++ code helps to get CPU (Processor) Id<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;array>\n#include &lt;iomanip>\n#include &lt;iostream>\n#include &lt;sstream>\n#include &lt;string>\n#include&lt;conio.h>\nstd::string GetProcessorId() {\n\tstd::array&lt;int, 4> cpuInfo;\n\t__cpuid(cpuInfo.data(), 1);\n\tstd::ostringstream buffer;\n\tbuffer\n\t\t&lt;&lt; std::uppercase &lt;&lt; std::hex &lt;&lt; std::setfill('0')\n\t\t&lt;&lt; std::setw(8) &lt;&lt; cpuInfo.at(3)\n\t\t&lt;&lt; std::setw(8) &lt;&lt; cpuInfo.at(0);\n\treturn buffer.str();\n}\n\nint main(void) {\n\tstd::cout &lt;&lt; \"Processor Serial number is:  \";\n\t\tstd::cout&lt;&lt;GetProcessorId() &lt;&lt; std::endl;\n\t_getch();\n\treturn 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This piece of C++ code helps to get CPU (Processor) Id<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,2],"tags":[],"class_list":["post-838","post","type-post","status-publish","format-standard","hentry","category-cc","category-it"],"_links":{"self":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=838"}],"version-history":[{"count":0,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/838\/revisions"}],"wp:attachment":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}