{"id":467293,"date":"2025-07-17T21:00:12","date_gmt":"2025-07-17T21:00:12","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=467293"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=467293","title":{"rendered":"<span>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 CPU \u0438 RAM \u043d\u0430 \u043f\u0430\u043d\u0435\u043b\u0438 \u0437\u0430\u0434\u0430\u0447 C++<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u042f \u0441\u0442\u0443\u0434\u0435\u043d\u0442, \u0443\u0447\u0443\u0441\u044c \u043f\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e &#171;\u041f\u0440\u0438\u0431\u043e\u0440\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435&#187;, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u0412\u0441\u0435 \u0442\u0430\u043a\u0438 \u044d\u0442\u043e \u043c\u0435\u043d\u044f \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435. \u0417\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0441\u044f \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u0441\u043c\u0435\u043d\u044b \u041e\u0421 \u043d\u0430 Arch Linux, \u043d\u043e \u043f\u043e\u043a\u0430 \u043e\u0442\u043b\u043e\u0436\u0438\u043b \u044d\u0442\u0443 \u0437\u0430\u0442\u0435\u044e \u0432 \u0434\u043e\u043b\u0433\u0438\u0439 \u044f\u0449\u0438\u043a. \u0421\u043c\u043e\u0442\u0440\u0435\u043b \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0440\u043e\u043b\u0438\u043a\u0438 \u043d\u0430 YouTube \u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441\u0442\u0430\u0432\u044f\u0442 \u0441\u0435\u0431\u0435 Polybar, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u0443\u044e \u043d\u0430 \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u041f\u0430\u043d\u0435\u043b\u044c \u0437\u0430\u0434\u0430\u0447 \u0432 Windows. \u0422\u043e\u0433\u0434\u0430 \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b &#171;\u0410 \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0432 \u0432\u0438\u043d\u0434\u0435?!&#187; \u0438 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430\u0447\u0430\u043b \u0433\u0443\u0433\u043b\u0438\u0442\u044c \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443. \u041f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438, \u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0438\u043b\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 C++.<\/p>\n<p><em>\u0417\u0430\u0440\u0430\u043d\u0435\u0435 \u0445\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0434\u0438\u0442\u044c, \u044d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043a\u0440\u0438\u0442\u0438\u043a\u0438. \u041c\u043e\u0436\u0435\u0442 \u044f \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u0438\u043b\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043b, \u0436\u0434\u0443 \u0444\u0438\u0434\u0431\u0435\u043a\u0430.<\/em><\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4b4\/68d\/e64\/4b468de64cfb9cd76500d526d4a44b7d.png\" alt=\"\u0420\u0438\u0441.1 - \u0413\u043e\u043b\u0443\u0431\u0430\u044f \u0438\u043a\u043e\u043d\u043a\u0430 - RAM. \u0417\u0435\u043b\u0435\u043d\u0430\u044f - \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 CPU\" title=\"\u0420\u0438\u0441.1 - \u0413\u043e\u043b\u0443\u0431\u0430\u044f \u0438\u043a\u043e\u043d\u043a\u0430 - RAM. \u0417\u0435\u043b\u0435\u043d\u0430\u044f - \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 CPU\" width=\"507\" height=\"57\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/4b4\/68d\/e64\/4b468de64cfb9cd76500d526d4a44b7d.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4b4\/68d\/e64\/4b468de64cfb9cd76500d526d4a44b7d.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0420\u0438\u0441.1 &#8212; \u0413\u043e\u043b\u0443\u0431\u0430\u044f \u0438\u043a\u043e\u043d\u043a\u0430 &#8212; RAM. \u0417\u0435\u043b\u0435\u043d\u0430\u044f &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 CPU<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u0438 \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u041e\u0417\u0423 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 GB \u0438 %, \u0430 \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 CPU &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445. \u0426\u0432\u0435\u0442 \u0438\u043a\u043e\u043d\u043a\u0443 cpu \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438: <\/p>\n<ul>\n<li>\n<p>\u0417\u0435\u043b\u0435\u043d\u044b\u0439 &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 &lt;25%<\/p>\n<\/li>\n<li>\n<p>\u041e\u0440\u0430\u043d\u0436\u0435\u0432\u044b\u0439 &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 25-50%<\/p>\n<\/li>\n<li>\n<p>\u041a\u0440\u0430\u0441\u043d\u044b\u0439 &#8212; &gt;50%<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u043a\u043e\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 VS \u0438 \u0443\u0434\u0430\u043b\u0438\u043c \u0432\u0441\u0435 \u043b\u0438\u0448\u043d\u0435\u0435 \u043e\u0442\u0442\u0443\u0434\u0430 \u0438\u0437 .cpp \u0438 .rc \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0438\u043a\u043e\u043d\u043a\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0445 \u0432 \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. <\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/886\/ac9\/ebe\/886ac9ebe3ab7982d0a8648ca278b343.png\" alt=\"\u0440\u0438\u0441. 2\" title=\"\u0440\u0438\u0441. 2\" width=\"616\" height=\"723\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/886\/ac9\/ebe\/886ac9ebe3ab7982d0a8648ca278b343.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/886\/ac9\/ebe\/886ac9ebe3ab7982d0a8648ca278b343.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0440\u0438\u0441. 2<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fe5\/947\/f60\/fe5947f60aeccb967dc15a5f9134ba4b.png\" alt=\"\u0440\u0438\u0441. 3\" title=\"\u0440\u0438\u0441. 3\" width=\"1872\" height=\"728\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/fe5\/947\/f60\/fe5947f60aeccb967dc15a5f9134ba4b.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fe5\/947\/f60\/fe5947f60aeccb967dc15a5f9134ba4b.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0440\u0438\u0441. 3<\/figcaption><\/div>\n<\/figure>\n<p>\u042d\u0442\u0443 \u0438\u043a\u043e\u043d\u043a\u0443 \u044f \u043d\u0430\u0448\u0435\u043b \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 -&gt; <a href=\"https:\/\/www.flaticon.com\/ru\/free-icons\/prosessor\" rel=\"noopener noreferrer nofollow\">https:\/\/www.flaticon.com\/ru\/free-icons\/prosessor<\/a>. \u0422\u0430\u043c \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0438\u043a\u043e\u043d\u043a\u0443 RAM. \u041e\u043d\u0438 \u0442\u0430\u043c \u0432 \u0447\u0435\u0440\u043d\u043e\u043c \u0446\u0432\u0435\u0442\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 Paint \u0437\u0430\u043b\u0438\u0442\u044c \u0438\u0445 \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u0446\u0432\u0435\u0442, \u0430 \u0447\u0435\u0440\u0435\u0437 \u043e\u043d\u043b\u0430\u0439\u043d \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 .ico. \u0418\u043a\u043e\u043d\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0430\u043c \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f<\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 .rc (\u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432) \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0438\u043a\u043e\u043d\u043a\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0442\u044f\u043d\u0443\u0442\u044c \u0440\u044f\u0434\u043e\u043c \u0441 \u043d\u0430\u0448\u0438\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u043c exe\u0448\u043d\u0438\u043a\u043e\u043c.<\/p>\n<p><code>IDR_CPUICON1 ICON \"cpu4.ico\"<br \/> IDR_CPUICON2 ICON \"cpu6.ico\"<br \/> IDR_CPUICON3 ICON \"cpu5.ico\"<br \/> IDR_RAMICON0 ICON \"ram0.ico\"<\/code><\/p>\n<p>\u0410 \u0432 \u0444\u0430\u0439\u043b\u0435 Recource.h \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0438\u043c id\u0448\u043d\u0438\u043a\u0438<br \/><code>#define IDR_CPUICON1131<br \/> #define IDR_CPUICON2132<br \/> #define IDR_CPUICON3133<br \/> #define IDR_RAMICON0134<\/code><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c 2 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u0430\u043a\u0438 \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432 \u0442\u0430\u0441\u043a \u0431\u0430\u0440\u0435:<\/p>\n<p><code>NOTIFYICONDATA cpu_status_icon;<br \/> NOTIFYICONDATA ram_status_icon;<\/code><\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 -&gt; <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/shellapi\/ns-shellapi-notifyicondataa\" rel=\"noopener noreferrer nofollow\">https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/shellapi\/ns-shellapi-notifyicondataa<\/a><\/p>\n<p>\u0418 2 \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439:<\/p>\n<p><code>HANDLE htimer_ram = NULL;<br \/> HANDLE htimer_cpu = NULL;<\/code><\/p>\n<pre><code>void CALLBACK TimerRAM(PVOID pVoid, BOOLEAN TimerOrWaitFired) {     static wchar_t ram_info[128];     if (GlobalMemoryStatusEx(&amp;mem_info)) {         static uint16_t totalPhys = (uint16_t)ceil((float)mem_info.ullTotalPhys \/ 1024 \/ 1024 \/ 1024);         float physUsed = (float)(mem_info.ullTotalPhys - mem_info.ullAvailPhys) \/ 1024 \/ 1024 \/ 1024;         uint16_t usagePercent = mem_info.dwMemoryLoad;          swprintf(ram_info, 128, L\"%.2f\\\\%u Gb   %u%%\", physUsed, totalPhys, usagePercent);         lstrcpy(ram_status_icon.szTip, ram_info);         Shell_NotifyIcon(NIM_MODIFY, &amp;ram_status_icon);     }  }  void CALLBACK TimerCPU(PVOID pVoid, BOOLEAN TimerOrWaitFired) {     static wchar_t cpu_inf[8];     double cpu_total = GetCPULoad();     if (cpu_total &lt; 25)         cpu_status_icon.hIcon = cpu_icons[0];     else if (cpu_total &lt; 50)         cpu_status_icon.hIcon = cpu_icons[1];     else if (cpu_total &gt;= 50)         cpu_status_icon.hIcon = cpu_icons[2];     swprintf(cpu_inf, 8, L\"%.2f %%\", cpu_total);     lstrcpy(cpu_status_icon.szTip, cpu_inf);     Shell_NotifyIcon(NIM_MODIFY, &amp;cpu_status_icon); }<\/code><\/pre>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u041e\u0417\u0423 \u0431\u0443\u0434\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u0432 \u0442\u0430\u0439\u043c\u0435\u0440\u0435. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u0440\u043e\u0446\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>float GetCPULoad() {     static FILETIME idleTimePrev = {}, kernelTimePrev = {}, userTimePrev = {};      FILETIME idleTime, kernelTime, userTime;     if (!GetSystemTimes(&amp;idleTime, &amp;kernelTime, &amp;userTime)) return 0.0;      auto toUInt64 = [](FILETIME ft) {         return ((uint64_t)ft.dwHighDateTime &lt;&lt; 32) | ft.dwLowDateTime;         };      uint64_t idleDiff = toUInt64(idleTime) - toUInt64(idleTimePrev);     uint64_t kernelDiff = toUInt64(kernelTime) - toUInt64(kernelTimePrev);     uint64_t userDiff = toUInt64(userTime) - toUInt64(userTimePrev);      idleTimePrev = idleTime;     kernelTimePrev = kernelTime;     userTimePrev = userTime;      uint64_t total = kernelDiff + userDiff;     return total ? (1.0 - (float)idleDiff \/ total) * 100.0 : 0.0; }<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0442\u0430\u0439\u043c\u0435\u0440\u044b \u0438 \u0442.\u043f.:<\/p>\n<pre><code>BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) {    hInst = hInstance; \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043c\u0430\u0440\u043a\u0435\u0440 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439     HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);     if (!hWnd)    {       return FALSE;    }    cpu_icons[0] = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDR_CPUICON1), IMAGE_ICON, 64, 64, 0);    cpu_icons[1] = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDR_CPUICON2), IMAGE_ICON, 64, 64, 0);    cpu_icons[2] = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDR_CPUICON3), IMAGE_ICON, 64, 64, 0);    cpu_status_icon.cbSize = sizeof(NOTIFYICONDATA);    cpu_status_icon.hWnd = hWnd;    cpu_status_icon.uID = 1;    cpu_status_icon.hIcon = cpu_icons[0];    lstrcpy(cpu_status_icon.szTip, L\"%\");    cpu_status_icon.uFlags = NIF_ICON | NIF_TIP;    Shell_NotifyIcon(NIM_ADD, &amp;cpu_status_icon);     mem_info.dwLength = sizeof(mem_info);     ram_status_icon.cbSize = sizeof(NOTIFYICONDATA);    ram_status_icon.hWnd = hWnd;    ram_status_icon.uID = 2;    ram_status_icon.hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDR_RAMICON0), IMAGE_ICON, 64, 64, 0);;    lstrcpy(ram_status_icon.szTip, L\"%\");    ram_status_icon.uFlags = NIF_ICON | NIF_TIP;    Shell_NotifyIcon(NIM_ADD, &amp;ram_status_icon);      if (!CreateTimerQueueTimer(&amp;htimer_cpu, NULL, TimerCPU, NULL, 1000, 1500, WT_EXECUTEDEFAULT))    {        std::cerr &lt;&lt; \"Error cpu timer\\n\";        return -1;    }     if (!CreateTimerQueueTimer(&amp;htimer_ram, NULL, TimerRAM, NULL, 1000, 1500, WT_EXECUTEDEFAULT))    {        std::cerr &lt;&lt; \"Error ram timer\\n\";        return -2;    }    return TRUE; }<\/code><\/pre>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440\u044b \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<pre><code>LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {     switch (message)     {     case WM_DESTROY:         DeleteTimerQueueTimer(NULL, htimer_cpu, NULL);         DeleteTimerQueueTimer(NULL, htimer_ram, NULL);         PostQuitMessage(0);         break;     default:         return DefWindowProc(hWnd, message, wParam, lParam);     }     return 0; }<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/PenguinPelmen\/CPU_icon_monitoring.git\" rel=\"noopener noreferrer nofollow\">\u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 \u043c\u043e\u0435\u043c \u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/928602\/\"> https:\/\/habr.com\/ru\/articles\/928602\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u042f \u0441\u0442\u0443\u0434\u0435\u043d\u0442, \u0443\u0447\u0443\u0441\u044c \u043f\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e &#171;\u041f\u0440\u0438\u0431\u043e\u0440\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435&#187;, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u0412\u0441\u0435 \u0442\u0430\u043a\u0438 \u044d\u0442\u043e \u043c\u0435\u043d\u044f \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435. \u0417\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0441\u044f \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u0441\u043c\u0435\u043d\u044b \u041e\u0421 \u043d\u0430 Arch Linux, \u043d\u043e \u043f\u043e\u043a\u0430 \u043e\u0442\u043b\u043e\u0436\u0438\u043b \u044d\u0442\u0443 \u0437\u0430\u0442\u0435\u044e \u0432 \u0434\u043e\u043b\u0433\u0438\u0439 \u044f\u0449\u0438\u043a. \u0421\u043c\u043e\u0442\u0440\u0435\u043b \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0440\u043e\u043b\u0438\u043a\u0438 \u043d\u0430 YouTube \u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441\u0442\u0430\u0432\u044f\u0442 \u0441\u0435\u0431\u0435 Polybar, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u0443\u044e \u043d\u0430 \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u041f\u0430\u043d\u0435\u043b\u044c \u0437\u0430\u0434\u0430\u0447 \u0432 Windows. \u0422\u043e\u0433\u0434\u0430 \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b &#171;\u0410 \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0432 \u0432\u0438\u043d\u0434\u0435?!&#187; \u0438 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430\u0447\u0430\u043b \u0433\u0443\u0433\u043b\u0438\u0442\u044c \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443. \u041f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438, \u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0438\u043b\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 C++.<\/p>\n<p><em>\u0417\u0430\u0440\u0430\u043d\u0435\u0435 \u0445\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0434\u0438\u0442\u044c, \u044d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043a\u0440\u0438\u0442\u0438\u043a\u0438. \u041c\u043e\u0436\u0435\u0442 \u044f \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u0438\u043b\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043b, \u0436\u0434\u0443 \u0444\u0438\u0434\u0431\u0435\u043a\u0430.<\/em><\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<figure class=\"\">\n<div><figcaption>\u0420\u0438\u0441.1 &#8212; \u0413\u043e\u043b\u0443\u0431\u0430\u044f \u0438\u043a\u043e\u043d\u043a\u0430 &#8212; RAM. \u0417\u0435\u043b\u0435\u043d\u0430\u044f &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 CPU<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u0438 \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u041e\u0417\u0423 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 GB \u0438 %, \u0430 \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 CPU &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445. \u0426\u0432\u0435\u0442 \u0438\u043a\u043e\u043d\u043a\u0443 cpu \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438: <\/p>\n<ul>\n<li>\n<p>\u0417\u0435\u043b\u0435\u043d\u044b\u0439 &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 &lt;25%<\/p>\n<\/li>\n<li>\n<p>\u041e\u0440\u0430\u043d\u0436\u0435\u0432\u044b\u0439 &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 25-50%<\/p>\n<\/li>\n<li>\n<p>\u041a\u0440\u0430\u0441\u043d\u044b\u0439 &#8212; &gt;50%<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u043a\u043e\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 VS \u0438 \u0443\u0434\u0430\u043b\u0438\u043c \u0432\u0441\u0435 \u043b\u0438\u0448\u043d\u0435\u0435 \u043e\u0442\u0442\u0443\u0434\u0430 \u0438\u0437 .cpp \u0438 .rc \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0438\u043a\u043e\u043d\u043a\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0445 \u0432 \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0440\u0438\u0441. 2<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>\u0440\u0438\u0441. 3<\/figcaption><\/div>\n<\/figure>\n<p>\u042d\u0442\u0443 \u0438\u043a\u043e\u043d\u043a\u0443 \u044f \u043d\u0430\u0448\u0435\u043b \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 -&gt; <a href=\"https:\/\/www.flaticon.com\/ru\/free-icons\/prosessor\" rel=\"noopener noreferrer nofollow\">https:\/\/www.flaticon.com\/ru\/free-icons\/prosessor<\/a>. \u0422\u0430\u043c \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0438\u043a\u043e\u043d\u043a\u0443 RAM. \u041e\u043d\u0438 \u0442\u0430\u043c \u0432 \u0447\u0435\u0440\u043d\u043e\u043c \u0446\u0432\u0435\u0442\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 Paint \u0437\u0430\u043b\u0438\u0442\u044c \u0438\u0445 \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u0446\u0432\u0435\u0442, \u0430 \u0447\u0435\u0440\u0435\u0437 \u043e\u043d\u043b\u0430\u0439\u043d \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 .ico. \u0418\u043a\u043e\u043d\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0430\u043c \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f<\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 .rc (\u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432) \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0438\u043a\u043e\u043d\u043a\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0442\u044f\u043d\u0443\u0442\u044c \u0440\u044f\u0434\u043e\u043c \u0441 \u043d\u0430\u0448\u0438\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u043c exe\u0448\u043d\u0438\u043a\u043e\u043c.<\/p>\n<p><code>IDR_CPUICON1 ICON \"cpu4.ico\"<br \/> IDR_CPUICON2 ICON \"cpu6.ico\"<br \/> IDR_CPUICON3 ICON \"cpu5.ico\"<br \/> IDR_RAMICON0 ICON \"ram0.ico\"<\/code><\/p>\n<p>\u0410 \u0432 \u0444\u0430\u0439\u043b\u0435 Recource.h \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0438\u043c id\u0448\u043d\u0438\u043a\u0438<br \/><code>#define IDR_CPUICON1131<br \/> #define IDR_CPUICON2132<br \/> #define IDR_CPUICON3133<br \/> #define IDR_RAMICON0134<\/code><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c 2 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u0430\u043a\u0438 \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432 \u0442\u0430\u0441\u043a \u0431\u0430\u0440\u0435:<\/p>\n<p><code>NOTIFYICONDATA cpu_status_icon;<br \/> NOTIFYICONDATA ram_status_icon;<\/code><\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 -&gt; <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/shellapi\/ns-shellapi-notifyicondataa\" rel=\"noopener noreferrer nofollow\">https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/shellapi\/ns-shellapi-notifyicondataa<\/a><\/p>\n<p>\u0418 2 \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439:<\/p>\n<p><code>HANDLE htimer_ram = NULL;<br \/> HANDLE htimer_cpu = NULL;<\/code><\/p>\n<pre><code>void CALLBACK TimerRAM(PVOID pVoid, BOOLEAN TimerOrWaitFired) {     static wchar_t ram_info[128];     if (GlobalMemoryStatusEx(&amp;mem_info)) {         static uint16_t totalPhys = (uint16_t)ceil((float)mem_info.ullTotalPhys \/ 1024 \/ 1024 \/ 1024);         float physUsed = (float)(mem_info.ullTotalPhys - mem_info.ullAvailPhys) \/ 1024 \/ 1024 \/ 1024;         uint16_t usagePercent = mem_info.dwMemoryLoad;          swprintf(ram_info, 128, L\"%.2f\\\\%u Gb   %u%%\", physUsed, totalPhys, usagePercent);         lstrcpy(ram_status_icon.szTip, ram_info);         Shell_NotifyIcon(NIM_MODIFY, &amp;ram_status_icon);     }  }  void CALLBACK TimerCPU(PVOID pVoid, BOOLEAN TimerOrWaitFired) {     static wchar_t cpu_inf[8];     double cpu_total = GetCPULoad();     if (cpu_total &lt; 25)         cpu_status_icon.hIcon = cpu_icons[0];     else if (cpu_total &lt; 50)         cpu_status_icon.hIcon = cpu_icons[1];     else if (cpu_total &gt;= 50)         cpu_status_icon.hIcon = cpu_icons[2];     swprintf(cpu_inf, 8, L\"%.2f %%\", cpu_total);     lstrcpy(cpu_status_icon.szTip, cpu_inf);     Shell_NotifyIcon(NIM_MODIFY, &amp;cpu_status_icon); }<\/code><\/pre>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u041e\u0417\u0423 \u0431\u0443\u0434\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u0432 \u0442\u0430\u0439\u043c\u0435\u0440\u0435. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u0440\u043e\u0446\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>float GetCPULoad() {     static FILETIME idleTimePrev = {}, kernelTimePrev = {}, userTimePrev = {};      FILETIME idleTime, kernelTime, userTime;     if (!GetSystemTimes(&amp;idleTime, &amp;kernelTime, &amp;userTime)) return 0.0;      auto toUInt64 = [](FILETIME ft) {         return ((uint64_t)ft.dwHighDateTime &lt;&lt; 32) | ft.dwLowDateTime;         };      uint64_t idleDiff = toUInt64(idleTime) - toUInt64(idleTimePrev);     uint64_t kernelDiff = toUInt64(kernelTime) - toUInt64(kernelTimePrev);     uint64_t userDiff = toUInt64(userTime) - toUInt64(userTimePrev);      idleTimePrev = idleTime;     kernelTimePrev = kernelTime;     userTimePrev = userTime;      uint64_t total = kernelDiff + userDiff;     return total ? (1.0 - (float)idleDiff \/ total) * 100.0 : 0.0; }<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0442\u0430\u0439\u043c\u0435\u0440\u044b \u0438 \u0442.\u043f.:<\/p>\n<pre><code>BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) {    hInst = hInstance; \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043c\u0430\u0440\u043a\u0435\u0440 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439     HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);     if (!hWnd)    {       return FALSE;    }    cpu_icons[0] = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDR_CPUICON1), IMAGE_ICON, 64, 64, 0);    cpu_icons[1] = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDR_CPUICON2), IMAGE_ICON, 64, 64, 0);    cpu_icons[2] = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDR_CPUICON3), IMAGE_ICON, 64, 64, 0);    cpu_status_icon.cbSize = sizeof(NOTIFYICONDATA);    cpu_status_icon.hWnd = hWnd;    cpu_status_icon.uID = 1;    cpu_status_icon.hIcon = cpu_icons[0];    lstrcpy(cpu_status_icon.szTip, L\"%\");    cpu_status_icon.uFlags = NIF_ICON | NIF_TIP;    Shell_NotifyIcon(NIM_ADD, &amp;cpu_status_icon);     mem_info.dwLength = sizeof(mem_info);     ram_status_icon.cbSize = sizeof(NOTIFYICONDATA);    ram_status_icon.hWnd = hWnd;    ram_status_icon.uID = 2;    ram_status_icon.hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDR_RAMICON0), IMAGE_ICON, 64, 64, 0);;    lstrcpy(ram_status_icon.szTip, L\"%\");    ram_status_icon.uFlags = NIF_ICON | NIF_TIP;    Shell_NotifyIcon(NIM_ADD, &amp;ram_status_icon);      if (!CreateTimerQueueTimer(&amp;htimer_cpu, NULL, TimerCPU, NULL, 1000, 1500, WT_EXECUTEDEFAULT))    {        std::cerr &lt;&lt; \"Error cpu timer\\n\";        return -1;    }     if (!CreateTimerQueueTimer(&amp;htimer_ram, NULL, TimerRAM, NULL, 1000, 1500, WT_EXECUTEDEFAULT))    {        std::cerr &lt;&lt; \"Error ram timer\\n\";        return -2;    }    return TRUE; }<\/code><\/pre>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440\u044b \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<pre><code>LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {     switch (message)     {     case WM_DESTROY:         DeleteTimerQueueTimer(NULL, htimer_cpu, NULL);         DeleteTimerQueueTimer(NULL, htimer_ram, NULL);         PostQuitMessage(0);         break;     default:         return DefWindowProc(hWnd, message, wParam, lParam);     }     return 0; }<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/PenguinPelmen\/CPU_icon_monitoring.git\" rel=\"noopener noreferrer nofollow\">\u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 \u043c\u043e\u0435\u043c \u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/928602\/\"> https:\/\/habr.com\/ru\/articles\/928602\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-467293","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/467293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=467293"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/467293\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=467293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=467293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=467293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}