From 53ba07e7192f8ef06b8ade92b554532da20343cd Mon Sep 17 00:00:00 2001 From: CherryPill Date: Sat, 23 May 2020 13:21:25 +0300 Subject: [PATCH 01/10] Add CPU usage monitoring --- .../Icons/utilization/utilization_0.ico | Bin 0 -> 4682 bytes .../Icons/utilization/utilization_1.ico | Bin 0 -> 4682 bytes .../Icons/utilization/utilization_2.ico | Bin 0 -> 4682 bytes .../Icons/utilization/utilization_3.ico | Bin 0 -> 4682 bytes .../Icons/utilization/utilization_4.ico | Bin 0 -> 4682 bytes .../Icons/utilization/utilization_5.ico | Bin 0 -> 4682 bytes SystemInfo/SystemInfo.aps | Bin 2068880 -> 2102256 bytes SystemInfo/SystemInfo.rc | Bin 12640 -> 13732 bytes SystemInfo/SystemInfo.vcxproj | 14 + SystemInfo/SystemInfo.vcxproj.filters | 42 +++ SystemInfo/WMIWBEMINFO.cpp | 29 ++ SystemInfo/WMIWBEMINFO.h | 115 +++++++ SystemInfo/const/appconst.h | 4 +- SystemInfo/const/itemIDs.h | 6 +- SystemInfo/core/WMIWBEMINFO.cpp | 14 + SystemInfo/core/WMIWBEMINFO.h | 116 +++++++ SystemInfo/core/sysinfo.cpp | 303 ++++-------------- SystemInfo/core/sysinfo.h | 9 + SystemInfo/glb/globalVars.cpp | 8 +- SystemInfo/glb/globalVars.h | 17 +- SystemInfo/mainWindowProcedure.cpp | 107 ++++++- SystemInfo/mainWindowProcedure.h | 2 + SystemInfo/resource.h | Bin 5504 -> 7124 bytes 23 files changed, 528 insertions(+), 258 deletions(-) create mode 100644 SystemInfo/Icons/utilization/utilization_0.ico create mode 100644 SystemInfo/Icons/utilization/utilization_1.ico create mode 100644 SystemInfo/Icons/utilization/utilization_2.ico create mode 100644 SystemInfo/Icons/utilization/utilization_3.ico create mode 100644 SystemInfo/Icons/utilization/utilization_4.ico create mode 100644 SystemInfo/Icons/utilization/utilization_5.ico create mode 100644 SystemInfo/WMIWBEMINFO.cpp create mode 100644 SystemInfo/WMIWBEMINFO.h create mode 100644 SystemInfo/core/WMIWBEMINFO.cpp create mode 100644 SystemInfo/core/WMIWBEMINFO.h diff --git a/SystemInfo/Icons/utilization/utilization_0.ico b/SystemInfo/Icons/utilization/utilization_0.ico new file mode 100644 index 0000000000000000000000000000000000000000..f0fb10567556583dca57f7f40f8f7df0fd791e92 GIT binary patch literal 4682 zcmd6rO>9(E7=~|kMRcPJB*s7^7}2#c#$QZGqpbxDrJ-pA5`%!9I6xP+lo@BF&h$qr zE!;XCE7o+-v_M?4bivlmYz#}1?wy47%pBimI7iP6_vWq~Z1eQqdC&LV_xyb4T!tX% z(QohWKtH{~YtIJ3cHQl5eF}m;UDc|;LGZNNe&4^XMN811TrRhjN~LNW8ykNaV`|N2 zvsSOyyTz9L&B@eBb7$j@?Df+W_5U7?(SZCPOr|Ey!p1`Lwz+L?HE)@ljhpS%J3iAM zrFG`H&mFP%>-SBg-oXC>{^hZ<>EG-(L6?448Y`_icK*v_%VubEs7vmFS#PYj`G;en zIkI`AYyOo+rQQFu{D14Bzv=LQ+~dEZ@gLXtcd7#6l-Lw=Vvj)EFV-x5R@<%XtRVJ` z)jIQEvO4*z;_JZN`11z4{Ga*{SLNR)|3K~VmMDvq{fxFv%v+xF^v`uq>^q+3^2a=l z{DSyY{(p4%GyW6u-=%gqCcYO_g8rlJ6APC2t;XCCL+lBw`S};6`T6w!to*AT{@KtB zPY*YP%W8*dkr8?Etw5U*Sqt}Qv=KurIZ65SCmrE`QT{XXUr{@-rWXXyE(x?nK|Wj& zXtWVSEPYDKXRf0B=jDH9*aUB?9jHJ27}vW3?PEbb!eN2Nn$sU*slTNBqGF=vzpV8i z@apeF#r+~C1+@n|1nUgX3#WgndtwJXEiV76V$Ma(|FZlKd;W}dOlCZvS)s&8q&&dIro2<~}bt)6f7_p6|`sd3mY@PQq|>72jB_Ip}fKIgB_ zu1EZrHvdAQV8+MC&B(~eL(c0uC$eJHYM<#^u$;0QZNv~eZZ)0}lYjKmQ8RdU z(A=%w_5DpIlQG3&(S%|6kfN@t$uKXjT5UnsjODV`uIWk)vE(G=FHJ3(d^&ILRqyfj j!+rnf{~&7JAe+tB(&==qTCKMJuSMU#x3p&eo1eb{g&M>F literal 0 HcmV?d00001 diff --git a/SystemInfo/Icons/utilization/utilization_1.ico b/SystemInfo/Icons/utilization/utilization_1.ico new file mode 100644 index 0000000000000000000000000000000000000000..c37aac2fd153e91feba8f96d923398594996c703 GIT binary patch literal 4682 zcmeI0L2MLN7{_1nMB)VxNQ}`&OazaF7!M|TAOu&c4c`*>Gi3L>c5ZXXhHcOk0eIy^!4fbO?%VcsNb-qT4^oS zrensVwB|T}+~j>&eQ0ad8u=fSe{OKjc9puUY12=kR%ooT&p$gjYkNz*ZOU%!Vr_9v z{$Mb$2TBLpmVc?X^gO@rF<<}Z>;FIRzb`cZTW!4mY}5UBO8Li>|7$$~;flB~R>ZJC zJ0tEo&N}TIZT}E>7oFA|KjL)aZ;RiJEj}tX-ZTI7|Ge_=P=2Fv*e1@2&)qRvhsZcy z2SzL`)I$4QvxqBt>RhFsQiBZM>P(dFDIBAb3!{V#vSaVF@^^( zF|Fd`<{wr6D>@(7+aZj2OZfV4bs9SL$J<jMw7g@kQl7ulgTS{a@2Kd?E^hdu_8oW3A6Qs0rE|0uSCpA}an(rxVZh zMXf*m*A?o&UGiNM;r`pGWAeZzLGStg!`l_o;^OH)J-eQ%|BUhvDE|hHL%;Y*Ft?Wl z+B<@}!@B~FYoexj2Lu{~bM z;+pq=p-`~<_U?O{t4F>i5zgPKW8Qnfedn)>{CHUluf@e*kVp9!$_s1q=W;naG&E%U z`}?18Qrk(976VTEQrn#4h|?IugLlYjoFgXw;OT?5=Xj63Q@#__rT&(3?E_xYaZocDdtnNx^8 zc-PblylTX$Dj}-TI$78gq7Ga1;!}uy=zDi@Z-Ihg_~w95J7yKyQN;mG??Id1I!&{yAA!dzf7p;MT`f|a zML)R>#(*E32h^^EA%#0GU8vE#>mo?OgT|IqXi~Ioc2awPCAp?Nd&SRSz&pn`E+tlfymo=tlS5Kc+{ut)J z9rJ$#{p1FSfj+=>M~!1`u0PHRwPS!DdfS0j{c)wUp66#Z{&D0xwDorhzSp1^2t_rv z%pr%A#=ZxDUWcaH)la~K^}1vJqsVVV{(kfm7vMd`YdZ+2od%qDat2W2IdM+uZ3EPZ zUe9x-#(J**yB7ID%zqH`&$%Q)4O7!~D~&a#ZdV_G$7=rjkUxa{m*^+F&p7rx-Yj?p zCV{#BIgZrW_ZZO2n%(N{*8d>#y}1AR+#+`X$I1^H0kxapnSyOW7yQUK53Qp-Su)cy{hL+zuzw-k%%-5V~Ys3Sd&HwOek#>TfbsNX_MH} zLoaJ~sgL$WWyl+nYw0z9{h7c2`9FwEIS2#-8L!uyNvG3=|Fz)v*9PY7zj^%zt>15G literal 0 HcmV?d00001 diff --git a/SystemInfo/Icons/utilization/utilization_3.ico b/SystemInfo/Icons/utilization/utilization_3.ico new file mode 100644 index 0000000000000000000000000000000000000000..62f31f933772204697c3f2e70fda5e0c08c38992 GIT binary patch literal 4682 zcmeI0yKmD_6vi(S5<+5up)ep(!NMPacnrW&F%;5vXro4z*!mESa3M=WNtA#{AfiD{ z>nIe8sy>iHS_T+8GIV6}R+469I)P8` z6@{f&T|1{#57w?Wx0Jev7EydFbq28?eW#l=1$<>PnS*#dUawZGzeS|(I8NQR?Vvb- zzl_JnWv99Wdn^vH|35fJA@Dy;#*#(L(qHQr70{>Bs5JZ7^)FACWw^FZ6q-N^~QSWk2&U! zf7t)w`4`T=@cI+f{U^NshW8&n;~ks(&m&y_zXmw}9pCs*!T(!;{^Ik03;!wj-^3Mw z%!2Qr4DJAGF;LZvY3(*z6EOFg*8KH%wa)s_;GL4qUz-k}^Z$C$P@kTOO@b{R`wgg#S6 zR}d!!kObV{NAL+Of#;e#eTcize3JTo8y0P%J2Z*e|Vme`(Oj`xLoZb)_I&zYSXr1ay$iet; zSQ{N21FwHCwmH|xW#IlU`ZJe(;cA`g7mx%0Rcp1yKbOl%B9V|- zEOx|Gv;~j`V_KU)o6}5cjWOmhH=#A|qeK1Z%TbBUL}b_6_4-RHm6CiuFQ#c8kw=Sj z(#(QItrgLxH1k?pLdzWHvZhOYX|5z$BP)B>9;ZL&Ki~iPA4EL}(&=>FFpRooS)l literal 0 HcmV?d00001 diff --git a/SystemInfo/Icons/utilization/utilization_4.ico b/SystemInfo/Icons/utilization/utilization_4.ico new file mode 100644 index 0000000000000000000000000000000000000000..91dfab4c359ced5593ed28eda6c625856a0dfefe GIT binary patch literal 4682 zcmeI0v1=1i9LJxN6r3DfExPm%5b+O?4u#MTDKxlAt3wW=W{^-55(+sGjM#eNC=MlU zhIs9$1s8?tQYdn`bnB3xM6!N_9Q$(6h`8I zF8-UvP0V?7P#NuRm!w7>XzdZprslEMq)%cbwyZTd$As}qYfH#I z$>G31Nc*E&t-`i#IF2*GX1PilWJ7B$mb^|9UTN(uONo(K8S{tn>#OT%lo~kpk7fF0 h{^k8&zCi?8P^;B~QmGX9zMp(+p?`n)9p-;1e*(%-8WsQm literal 0 HcmV?d00001 diff --git a/SystemInfo/Icons/utilization/utilization_5.ico b/SystemInfo/Icons/utilization/utilization_5.ico new file mode 100644 index 0000000000000000000000000000000000000000..7f8b6069a4a512f74a1121290d3dda313e87acc0 GIT binary patch literal 4682 zcmeHLF>As=7`={#P8~W6UHSw16G{;mK_mSIf{=hX3KD_{ZgvnQ2rh9-V}?$S#kHHG zlN9$JIN#mtcWE;uboJWd?s#{(yM&kA<-T{{$Jhns$}OW*VfWXJ-O$xt)?)0DY8s`I zu`3#Td$`Pybx;um!O`?(~0IrncLI_hh5;R(-|J)Y zGEpf~tkoKcOo|YtwjTejul!uzF5P<&2S_0`|4H*N+y!b$4a`suWth!z&OdkOa1zH5 zJ3}O+0{_gNp_R0Z@vr2{^3xv6*Wb>+{r~L#v-Zc7{#g5K^+%uatp0qT|E&I6{k8i0 zxBBa>4f;Q-=>LSB5cSu(G5=?YWx@X$_s8fx_s~q6XGJ4vpc+-N{n#q)=l|G$3`PU! xchGk5oS1f|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Xm1VB=MXwp3`Z%?oIy)P#4 z&&gyrn|Jy9s+>)Br}B3IJvk}hLap1v)0@h*r$juTb31u@GTpFMlgAWi#F*t(R{tSK$@j$*a1B7KVc|WJUqbEZ$Lq0 + @@ -191,6 +192,7 @@ + @@ -210,6 +212,18 @@ + + + + + + + + + + + + diff --git a/SystemInfo/SystemInfo.vcxproj.filters b/SystemInfo/SystemInfo.vcxproj.filters index 4273be3..46d2d98 100644 --- a/SystemInfo/SystemInfo.vcxproj.filters +++ b/SystemInfo/SystemInfo.vcxproj.filters @@ -99,6 +99,9 @@ dialog + + core + @@ -161,6 +164,9 @@ dialog + + core + @@ -210,6 +216,42 @@ Resource Files + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + diff --git a/SystemInfo/WMIWBEMINFO.cpp b/SystemInfo/WMIWBEMINFO.cpp new file mode 100644 index 0000000..4de5d02 --- /dev/null +++ b/SystemInfo/WMIWBEMINFO.cpp @@ -0,0 +1,29 @@ +#include "WMIWBEMINFO.h" + + +WMIWBEMINFO* WMIWBEMINFO::currentInstance; + +WMIWBEMINFO* WMIWBEMINFO::getWMIWBEMINFOInstance() { + if (currentInstance == nullptr) { + currentInstance = new WMIWBEMINFO(); + } + return currentInstance; +} + +IWbemLocator* WMIWBEMINFO::getWbemLocator() { + return this->pLoc; +} + +IWbemServices* WMIWBEMINFO::getWbemServices() { + return this->pSvc; +} + +HRESULT WMIWBEMINFO::getHres() { + return this->hres; +} + +WMIWBEMINFO::~WMIWBEMINFO() { + this->pSvc->Release(); + this->pLoc->Release(); + CoUninitialize(); +} diff --git a/SystemInfo/WMIWBEMINFO.h b/SystemInfo/WMIWBEMINFO.h new file mode 100644 index 0000000..c8af3a0 --- /dev/null +++ b/SystemInfo/WMIWBEMINFO.h @@ -0,0 +1,115 @@ +#pragma once + +#include +#include +#include +#include +class WMIWBEMINFO +{ +private: + static WMIWBEMINFO* currentInstance; + HRESULT hres; + IWbemServices* pSvc; + IWbemLocator* pLoc; + WMIWBEMINFO() { + + // Step 1: -------------------------------------------------- + // Initialize COM. ------------------------------------------ + + hres = CoInitializeEx(0, COINIT_MULTITHREADED); + if (FAILED(hres)) { + throw std::exception("Failed to initialize COM library"); + } + + // Step 2: -------------------------------------------------- + // Set general COM security levels -------------------------- + + hres = CoInitializeSecurity( + NULL, + -1, // COM authentication + NULL, // Authentication services + NULL, // Reserved + RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication + RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation + NULL, // Authentication info + EOAC_NONE, // Additional capabilities + NULL // Reserved + ); + + + if (FAILED(hres)) { + CoUninitialize(); + throw std::exception("Failed to initialize COM security levels"); + } + + //obtain the initial locator to WMI + + this->pLoc = NULL; + + hres = CoCreateInstance( + CLSID_WbemLocator, + 0, + CLSCTX_INPROC_SERVER, + IID_IWbemLocator, (LPVOID*)& pLoc); + + if (FAILED(hres)) { + CoUninitialize(); + throw std::exception("Failed to create IWbemLocator object"); + } + + // Step 4: ----------------------------------------------------- + // Connect to WMI through the IWbemLocator::ConnectServer method + + this->pSvc = NULL; + + // Connect to the root\cimv2 namespace with + // the current user and obtain pointer pSvc + // to make IWbemServices calls. + hres = pLoc->ConnectServer( + _bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace + NULL, // User name. NULL = current user + NULL, // User password. NULL = current + 0, // Locale. NULL indicates current + NULL, // Security flags. + 0, // Authority (for example, Kerberos) + 0, // Context object + &pSvc // pointer to IWbemServices proxy + ); + + if (FAILED(hres)) { + pLoc->Release(); + CoUninitialize(); + throw std::exception("Could not connect to root/cimv2 namespace"); + } + + + // Step 5: -------------------------------------------------- + // Set security levels on the proxy ------------------------- + + hres = CoSetProxyBlanket( + pSvc, // Indicates the proxy to set + RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx + RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx + NULL, // Server principal name + RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx + RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx + NULL, // client identity + EOAC_NONE // proxy capabilities + ); + + if (FAILED(hres)) { + pSvc->Release(); + pLoc->Release(); + CoUninitialize(); + throw std::exception("Could not set proxy blanket"); + } + } + +public: + static WMIWBEMINFO* getWMIWBEMINFOInstance(); + IWbemLocator *getWbemLocator(); + IWbemServices* getWbemServices(); + HRESULT getHres(); + ~WMIWBEMINFO(); +}; + diff --git a/SystemInfo/const/appconst.h b/SystemInfo/const/appconst.h index e2cf014..7d47ac3 100644 --- a/SystemInfo/const/appconst.h +++ b/SystemInfo/const/appconst.h @@ -7,5 +7,7 @@ #define ITEM_INFO_HEIGHT 60 #define ITEM_INFO_INITIAL_HEIGTH 15 #define ITEM_ICON_SIZE 16 - #define MOUSE_WHEEL_SCROLL 120 + #define ITEM_UTIL_ICON_RENDER_SIZE_WIDTH 12 + #define ITEM_UTIL_ICON_RENDER_SIZE_HEIGHT 14 + #define MOUSE_WHEEL_SCROLL 120 #endif \ No newline at end of file diff --git a/SystemInfo/const/itemIDs.h b/SystemInfo/const/itemIDs.h index fdaa2da..224c3a5 100644 --- a/SystemInfo/const/itemIDs.h +++ b/SystemInfo/const/itemIDs.h @@ -10,8 +10,8 @@ #define MONITOR_LABEL 6 #define STORAGE_LABEL 7 #define OPTICAL_LABEL 8 - #define AUDIO_LABEL 9 - #define NETWORK_LABEL 10 + #define NETWORK_LABEL 9 + #define AUDIO_LABEL 10 #define UPTIME_LABEL 11 #define BIOS_INFO 12 #define OS_INFO 13 @@ -28,6 +28,8 @@ #define END_INFO 24 #define AUX_IP_TOGGLE 720 + #define AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE 820 + #define AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING 920 #define INFO_ID_OFFSET 12 #define ICON_ID_OFFSET 60 diff --git a/SystemInfo/core/WMIWBEMINFO.cpp b/SystemInfo/core/WMIWBEMINFO.cpp new file mode 100644 index 0000000..0852a22 --- /dev/null +++ b/SystemInfo/core/WMIWBEMINFO.cpp @@ -0,0 +1,14 @@ +#include "WMIWBEMINFO.h" + + + +WMIWBEMINFO* WMIWBEMINFO::getWMIWBEMInfoInstance() { + if (!currentInstance) { + currentInstance = new WMIWBEMINFO(); + } + return currentInstance; +} + +WMIWBEMINFO::~WMIWBEMINFO() +{ +} diff --git a/SystemInfo/core/WMIWBEMINFO.h b/SystemInfo/core/WMIWBEMINFO.h new file mode 100644 index 0000000..d243c79 --- /dev/null +++ b/SystemInfo/core/WMIWBEMINFO.h @@ -0,0 +1,116 @@ +#pragma once + +#include +#include +#include +#include +class WMIWBEMINFO +{ +private: + static WMIWBEMINFO* currentInstance; + HRESULT hres; + IWbemServices* pSvc; + IWbemLocator* pLoc; + WMIWBEMINFO() { + HRESULT hres; + + // Step 1: -------------------------------------------------- + // Initialize COM. ------------------------------------------ + + this->hres = CoInitializeEx(0, COINIT_MULTITHREADED); + if (FAILED(hres)) { + throw std::exception("Failed to initialize COM library"); + } + + // Step 2: -------------------------------------------------- + // Set general COM security levels -------------------------- + + hres = CoInitializeSecurity( + NULL, + -1, // COM authentication + NULL, // Authentication services + NULL, // Reserved + RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication + RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation + NULL, // Authentication info + EOAC_NONE, // Additional capabilities + NULL // Reserved + ); + + + if (FAILED(hres)) { + CoUninitialize(); + throw std::exception("Failed to initialize COM security levels"); + } + + //obtain the initial locator to WMI + + this->pLoc = NULL; + + hres = CoCreateInstance( + CLSID_WbemLocator, + 0, + CLSCTX_INPROC_SERVER, + IID_IWbemLocator, (LPVOID*)& pLoc); + + if (FAILED(hres)) { + CoUninitialize(); + throw std::exception("Failed to create IWbemLocator object"); + } + + // Step 4: ----------------------------------------------------- + // Connect to WMI through the IWbemLocator::ConnectServer method + + this->pSvc = NULL; + + // Connect to the root\cimv2 namespace with + // the current user and obtain pointer pSvc + // to make IWbemServices calls. + hres = pLoc->ConnectServer( + _bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace + NULL, // User name. NULL = current user + NULL, // User password. NULL = current + 0, // Locale. NULL indicates current + NULL, // Security flags. + 0, // Authority (for example, Kerberos) + 0, // Context object + &pSvc // pointer to IWbemServices proxy + ); + + if (FAILED(hres)) { + pLoc->Release(); + CoUninitialize(); + throw std::exception("Could not connect to root/cimv2 namespace"); + } + + + // Step 5: -------------------------------------------------- + // Set security levels on the proxy ------------------------- + + hres = CoSetProxyBlanket( + pSvc, // Indicates the proxy to set + RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx + RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx + NULL, // Server principal name + RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx + RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx + NULL, // client identity + EOAC_NONE // proxy capabilities + ); + + if (FAILED(hres)) { + pSvc->Release(); + pLoc->Release(); + CoUninitialize(); + throw std::exception("Could not set proxy blanket"); + } + } + +public: + static WMIWBEMINFO* getWMIWBEMINFOInstance(); + IWbemLocator* getWbemLocator(); + IWbemServices* getWbemServices(); + HRESULT getHres(); + ~WMIWBEMINFO(); +}; + diff --git a/SystemInfo/core/sysinfo.cpp b/SystemInfo/core/sysinfo.cpp index e29ed32..b4737c7 100644 --- a/SystemInfo/core/sysinfo.cpp +++ b/SystemInfo/core/sysinfo.cpp @@ -13,6 +13,7 @@ #include "../util/utility.h" #include "../SMBIOS.h" #include "../mainWindowProcedure.h" +#include "../core/WMIWBEMINFO.h" //TODO: Conflate fillMB and fillCPU into one procedure since MB uses socket info available on Win32_Processor @@ -21,124 +22,18 @@ void(*fillInfoFuncs[])(SystemInfo*, HRESULT, IWbemServices*, IWbemLocator*) = fillStorage, fillCDROM, fillAudio }; - +WMIWBEMINFO* wmiWbemInfo = wmiWbemInfo->getWMIWBEMINFOInstance(); //the actual function that does all the heavy work int fillSystemInformation(SystemInfo* localMachine) { - HRESULT hres; - - // Step 1: -------------------------------------------------- - // Initialize COM. ------------------------------------------ - - hres = CoInitializeEx(0, COINIT_MULTITHREADED); - if (FAILED(hres)) { - MessageBox(NULL, _T("Failed to initialize COM library"), _T("Fatal Error"), MB_OK); - return 1; - } - - // Step 2: -------------------------------------------------- - // Set general COM security levels -------------------------- - - hres = CoInitializeSecurity( - NULL, - -1, // COM authentication - NULL, // Authentication services - NULL, // Reserved - RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication - RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation - NULL, // Authentication info - EOAC_NONE, // Additional capabilities - NULL // Reserved - ); - - - if (FAILED(hres)) { - MessageBox(NULL, _T("Failed to initialize security"), _T("Fatal Error"), MB_OK); - CoUninitialize(); - return 1; - } - - //obtain the initial locator to WMI - - IWbemLocator* pLoc = NULL; - - hres = CoCreateInstance( - CLSID_WbemLocator, - 0, - CLSCTX_INPROC_SERVER, - IID_IWbemLocator, (LPVOID*)& pLoc); - - if (FAILED(hres)) { - MessageBox(NULL, _T("Failed to create IWbemLocator object"), _T("Fatal Error"), MB_OK); - CoUninitialize(); - return 1; // Program has failed. - } - - // Step 4: ----------------------------------------------------- - // Connect to WMI through the IWbemLocator::ConnectServer method - - IWbemServices* pSvc = NULL; - - // Connect to the root\cimv2 namespace with - // the current user and obtain pointer pSvc - // to make IWbemServices calls. - hres = pLoc->ConnectServer( - _bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace - NULL, // User name. NULL = current user - NULL, // User password. NULL = current - 0, // Locale. NULL indicates current - NULL, // Security flags. - 0, // Authority (for example, Kerberos) - 0, // Context object - &pSvc // pointer to IWbemServices proxy - ); - - if (FAILED(hres)) { - MessageBox(NULL, _T("Could not connect"), _T("Fatal Error"), MB_OK); - pLoc->Release(); - CoUninitialize(); - return 1; - } - - - // Step 5: -------------------------------------------------- - // Set security levels on the proxy ------------------------- - - hres = CoSetProxyBlanket( - pSvc, // Indicates the proxy to set - RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx - RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx - NULL, // Server principal name - RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx - RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx - NULL, // client identity - EOAC_NONE // proxy capabilities - ); - - if (FAILED(hres)) { - MessageBox(NULL, _T("Could not set proxy blanket"), _T("Fatal Error"), MB_OK); - pSvc->Release(); - pLoc->Release(); - CoUninitialize(); - return 1; - } - - //use the IWbemServices pointer to make requests of WMI - - //temp - //fillCPUTemp(localMachine, hres, pSvc, pLoc); - //hardware fillBIOS(localMachine); for (int x = 0; x < sizeof(fillInfoFuncs) / sizeof(fillInfoFuncs[0]); x++) { - (*fillInfoFuncs[x])(localMachine, hres, pSvc, pLoc); + (*fillInfoFuncs[x])(localMachine, wmiWbemInfo->getHres(), + wmiWbemInfo->getWbemServices(), wmiWbemInfo->getWbemLocator()); } fillNetworkAdapters(localMachine); fillUptime(localMachine); - pSvc->Release(); - pLoc->Release(); - CoUninitialize(); - return 0; } @@ -680,143 +575,8 @@ IEnumWbemClassObject* executeWQLQuery(HRESULT hres, IWbemLocator * pLoc, } } -int test() { - - HRESULT hres; - - // Step 1: -------------------------------------------------- - // Initialize COM. ------------------------------------------ - - hres = CoInitializeEx(0, COINIT_MULTITHREADED); - if (FAILED(hres)) { - MessageBox(NULL, _T("Failed to initialize COM library"), _T("Fatal Error"), MB_OK); - return 1; // Program has failed. - } - - // Step 2: -------------------------------------------------- - // Set general COM security levels -------------------------- - - hres = CoInitializeSecurity( - NULL, - -1, // COM authentication - NULL, // Authentication services - NULL, // Reserved - RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication - RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation - NULL, // Authentication info - EOAC_NONE, // Additional capabilities - NULL // Reserved - ); - - - if (FAILED(hres)) { - MessageBox(NULL, _T("Failed to initialize security"), _T("Fatal Error"), MB_OK); - CoUninitialize(); - return 1; // Program has failed. - } - - // Step 3: --------------------------------------------------- - // Obtain the initial locator to WMI ------------------------- - - IWbemLocator* pLoc = NULL; - - hres = CoCreateInstance( - CLSID_WbemLocator, - 0, - CLSCTX_INPROC_SERVER, - IID_IWbemLocator, (LPVOID*)& pLoc); - - if (FAILED(hres)) { - MessageBox(NULL, _T("Failed to create IWbemLocator object"), _T("Fatal Error"), MB_OK); - CoUninitialize(); - return 1; // Program has failed. - } - - // Step 4: ----------------------------------------------------- - // Connect to WMI through the IWbemLocator::ConnectServer method - - IWbemServices* pSvc = NULL; - - // Connect to the root\cimv2 namespace with - // the current user and obtain pointer pSvc - // to make IWbemServices calls. - hres = pLoc->ConnectServer( - _bstr_t(L"ROOT\\WMI"), // Object path of WMI namespace - NULL, // User name. NULL = current user - NULL, // User password. NULL = current - 0, // Locale. NULL indicates current - NULL, // Security flags. - 0, // Authority (for example, Kerberos) - 0, // Context object - &pSvc // pointer to IWbemServices proxy - ); - - if (FAILED(hres)) { - MessageBox(NULL, _T("Could not connect"), _T("Fatal Error"), MB_OK); - pLoc->Release(); - CoUninitialize(); - return 1; // Program has failed. - } - - // Step 5: -------------------------------------------------- - // Set security levels on the proxy ------------------------- - - hres = CoSetProxyBlanket( - pSvc, // Indicates the proxy to set - RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx - RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx - NULL, // Server principal name - RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx - RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx - NULL, // client identity - EOAC_NONE // proxy capabilities - ); - - if (FAILED(hres)) { - MessageBox(NULL, _T("Could not set proxy blanket"), _T("Fatal Error"), MB_OK); - pSvc->Release(); - pLoc->Release(); - CoUninitialize(); - return 1; // Program has failed. - } - - // Step 6: -------------------------------------------------- - // Use the IWbemServices pointer to make requests of WMI ---- - - - IEnumWbemClassObject* pEnumerator = NULL; - pEnumerator = executeWQLQuery(hres, pLoc, pSvc, - bstr_t("SELECT * FROM MSAcpi_ThermalZoneTemperature")); - - IWbemClassObject* pclsObj = NULL; - ULONG uReturn = 0; - - while (pEnumerator) { - HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, - &pclsObj, &uReturn); - - if (0 == uReturn) { - break; - } - - VARIANT vtProp; - VariantInit(&vtProp); - hr = pclsObj->Get(L"CurrentTemperature", 0, &vtProp, 0, 0); - wstring socket = vtProp.bstrVal; - displayMessageGeneric(UI_MESS_RES::SUCCESS, socket.c_str()); - VariantClear(&vtProp); - pclsObj->Release(); - } - pEnumerator->Release(); - - pSvc->Release(); - pLoc->Release(); - CoUninitialize(); - - return 0; -} - bstr_t buildQueryString(const wchar_t* wmiClass, vector attrs) { + WCHAR queryString[256] = { 0 }; wcscpy(queryString, L"SELECT "); auto it = attrs.begin(); @@ -828,10 +588,21 @@ bstr_t buildQueryString(const wchar_t* wmiClass, vector attrs) { } wcscat(queryString, L" FROM "); wcscat(queryString, wmiClass); - int x = 0; return bstr_t(queryString); } +bstr_t buildQueryString(const wchar_t* wmiClass, + vector attrs, + const wchar_t* whereClause) { + bstr_t mainQuery = buildQueryString(wmiClass, attrs); + bstr_t mainQueryWithWhereClause = mainQuery; + if (whereClause != NULL) { + mainQueryWithWhereClause += SysAllocString(L" WHERE "); + mainQueryWithWhereClause += SysAllocString(whereClause); + } + return mainQueryWithWhereClause; +} + wstring getComputerType() { SYSTEM_POWER_CAPABILITIES systemPowerCapabilities; ZeroMemory(&systemPowerCapabilities, sizeof(systemPowerCapabilities)); @@ -883,3 +654,43 @@ wstring getRamBySlot(HRESULT hres, return wstring(capacityStrBuff); } +int getCpuUsagePercentage() { + vector queryAttrs = wmiClassStringsMap.at(L"Win32_PerfFormattedData_PerfOS_Processor"); + IEnumWbemClassObject* pEnumerator = executeWQLQuery + (wmiWbemInfo->getHres(), + wmiWbemInfo->getWbemLocator(), + wmiWbemInfo->getWbemServices(), + buildQueryString(L"Win32_PerfFormattedData_PerfOS_Processor", queryAttrs, L"Name='_Total'")); + + IWbemClassObject* pclsObj = NULL; + ULONG uReturn = 0; + + int cpuUsage = 0; + while (pEnumerator) { + HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, + &pclsObj, &uReturn); + + if (0 == uReturn){ + break; + } + + VARIANT vtProp; + + hr = pclsObj->Get(queryAttrs.at((int)WMI_CPU_PERF::PROC_TIME_PERCENTAGE), 0, &vtProp, 0, 0); + + if (WBEM_S_NO_ERROR != hr) { + if (pclsObj) { + VariantClear(&vtProp); + pclsObj->Release(); pclsObj = NULL; + } + break; + } + cpuUsage = std::stoi(vtProp.bstrVal); + + VariantClear(&vtProp); + + pclsObj->Release(); pclsObj = NULL; + } + return cpuUsage; +} + diff --git a/SystemInfo/core/sysinfo.h b/SystemInfo/core/sysinfo.h index 65db8ac..eb1ad63 100644 --- a/SystemInfo/core/sysinfo.h +++ b/SystemInfo/core/sysinfo.h @@ -49,6 +49,10 @@ enum class WMI_SOUND { CAPTION }; + + enum class WMI_CPU_PERF { + PROC_TIME_PERCENTAGE + }; static unordered_map > wmiClassStringsMap = { { L"Win32_OperatingSystem", {L"Name", L"OSArchitecture"}}, { L"Win32_Processor", { L"Name", L"MaxClockSpeed", L"SocketDesignation"} }, @@ -60,6 +64,8 @@ { L"Win32_DiskDrive", { L"Caption", L"Size" } }, { L"Win32_CDROMDrive", { L"Caption" } }, { L"Win32_SoundDevice", { L"Caption"} }, + { L"Win32_PerfFormattedData_PerfOS_Processor", { L"PercentProcessorTime"} } + }; int fillSystemInformation(SystemInfo *localMachine); int test(); @@ -80,7 +86,10 @@ void fillUptime(SystemInfo *localMachine); void fillDimensionsAndFrequency(HRESULT, IWbemServices*, IWbemLocator*, UINT*); wstring getSocket(HRESULT, IWbemServices*, IWbemLocator*); + int getCpuUsagePercentage(void); IEnumWbemClassObject* executeWQLQuery(HRESULT hres, IWbemLocator *pLoc, IWbemServices *pSvc, BSTR stringQuery); bstr_t buildQueryString(const wchar_t *wmiClass, vector attrs); + bstr_t buildQueryString(const wchar_t* wmiClass, vector attrs, const wchar_t *whereClause); + wstring getRamBySlot(HRESULT hres, IWbemServices*, IWbemLocator*, const vector&); #endif \ No newline at end of file diff --git a/SystemInfo/glb/globalVars.cpp b/SystemInfo/glb/globalVars.cpp index 0b44c77..3374021 100644 --- a/SystemInfo/glb/globalVars.cpp +++ b/SystemInfo/glb/globalVars.cpp @@ -47,4 +47,10 @@ TCHAR *timeVerboseDaysOfWeek[] = { _T("Saturday") }; -TCHAR sysInfoConfigDirectoryPath[256] = {}; \ No newline at end of file +TCHAR sysInfoConfigDirectoryPath[256] = {}; + +int currentCpuUsageGlobal = 0; + + +int cpuInfoHolderXoffset = 0; +int cpuInfoHolderYoffset = 0; \ No newline at end of file diff --git a/SystemInfo/glb/globalVars.h b/SystemInfo/glb/globalVars.h index b22efef..d323e95 100644 --- a/SystemInfo/glb/globalVars.h +++ b/SystemInfo/glb/globalVars.h @@ -21,7 +21,8 @@ extern int scrollFullPageHeight; extern HBRUSH grayBrush; extern HFONT appNameFontLarge; static vector iconArr; - +static vector iconArrCpuUtilizationIcons; +const static int iconArrCpuUtilizationIconsSize = 6; const static int totalItemsCount = 13; static WORD ICON_IDS[totalItemsCount]{ @@ -39,6 +40,15 @@ static WORD ICON_IDS[totalItemsCount]{ UPTIME_ICON }; +static WORD UTIL_iCON_IDS[iconArrCpuUtilizationIconsSize]{ + UTILIZATION_ICON_0, + UTILIZATION_ICON_1, + UTILIZATION_ICON_2, + UTILIZATION_ICON_3, + UTILIZATION_ICON_4, + UTILIZATION_ICON_5 +}; + static wstring UI_messagesTxt[] = { L"Successfully written to ", L"Error writing to ", @@ -164,4 +174,9 @@ enum class ACTION { extern WNDPROC lpfnScrEditProc; extern TCHAR sysInfoConfigDirectoryPath[256]; +extern int currentCpuUsageGlobal; + +extern int cpuInfoHolderXoffset; +extern int cpuInfoHolderYoffset; + #endif \ No newline at end of file diff --git a/SystemInfo/mainWindowProcedure.cpp b/SystemInfo/mainWindowProcedure.cpp index 0be74f4..bd15ad9 100644 --- a/SystemInfo/mainWindowProcedure.cpp +++ b/SystemInfo/mainWindowProcedure.cpp @@ -19,6 +19,8 @@ #include "dialog/aboutDialog.h" #include "dialog/scrUploadDialog.h" #include "import/binImport.h" +#include "core/WMIWBEMINFO.h" +#include "core/sysinfo.h" int g_scrollY = 0; LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -108,10 +110,21 @@ LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } else { SetTextColor(hdcStatic, RGB(125, 207, 246)); } - } else { + } + else if (GetDlgCtrlID((HWND)lParam) == AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING) { + if (currentCpuUsageGlobal <= 33) { + SetTextColor(hdcStatic, RGB(0, 255, 0)); + } + else if (currentCpuUsageGlobal > 33 && currentCpuUsageGlobal <= 66) { + SetTextColor(hdcStatic, RGB(255, 255, 0)); + } + else { + SetTextColor(hdcStatic, RGB(255, 0, 0)); + } + } + else { if (GetDlgCtrlID((HWND)lParam) == AUX_IP_TOGGLE) { SetTextColor(hdcStatic, RGB(255, 0, 0)); - } SetTextColor(hdcStatic, RGB(255, 255, 255)); } @@ -258,6 +271,16 @@ void loadImages(void) { NULL); iconArr.push_back(newIcon); } + for (int x = 0; x < iconArrCpuUtilizationIconsSize; x++) { + HICON newIcon = (HICON)LoadImage(ghInstance, + MAKEINTRESOURCE(UTIL_iCON_IDS[x]), + IMAGE_ICON, + ITEM_UTIL_ICON_RENDER_SIZE_WIDTH, + ITEM_UTIL_ICON_RENDER_SIZE_HEIGHT, + NULL); + iconArrCpuUtilizationIcons.push_back(newIcon); + } + int s = 0; } void createHardwareInfoHolders(HWND parent, SystemInfo *info, int offsetIndex) { @@ -328,7 +351,7 @@ void createHardwareInfoHolders(HWND parent, SystemInfo *info, int offsetIndex) { NULL, NULL ); - if (x == 9) { + if (x == NETWORK_LABEL) { createIPToggleControl(parent, xStartOffSetLabel + 140, yStartOffSet); } //info @@ -346,6 +369,10 @@ void createHardwareInfoHolders(HWND parent, SystemInfo *info, int offsetIndex) { NULL, NULL ); + if (y == CPU_INFO) { + cpuInfoHolderXoffset = xStartOffSetInformation; + cpuInfoHolderYoffset = yStartOffSet + 16; + } if (y >= GPU_INFO && y < AUDIO_INFO) { UINT32 listSize = getInfoBoxItemCount(y, info); //return rec structure @@ -354,6 +381,7 @@ void createHardwareInfoHolders(HWND parent, SystemInfo *info, int offsetIndex) { continue; } } + yStartOffSet += (ITEM_HEIGHT + 2); } scrollFullPageHeight = yStartOffSet; @@ -370,6 +398,11 @@ void populateInfoHolders(SystemInfo *currentMachineInfo, HWND mainWindowHwnd) { currentMachineInfo->getOS().c_str()); SetWindowText(GetDlgItem(mainWindowHwnd, CPU_INFO), currentMachineInfo->getCPU().c_str()); + + HWND cpuInfoHolderHandle = GetDlgItem(mainWindowHwnd, CPU_INFO); + int charLen = GetWindowTextLength(cpuInfoHolderHandle); + createCpuUtiliazationInfoHolder(mainWindowHwnd, cpuInfoHolderXoffset + charLen * 6, cpuInfoHolderYoffset); + SetWindowText(GetDlgItem(mainWindowHwnd, MB_INFO), currentMachineInfo->getMB().c_str()); SetWindowText(GetDlgItem(mainWindowHwnd, RAM_INFO), @@ -395,14 +428,12 @@ void populateInfoHolders(SystemInfo *currentMachineInfo, HWND mainWindowHwnd) { formListString(currentMachineInfo, OS_INFO_TYPES::HARDWARE_NETWORK, WRITE_OUT_TYPE::APP_WINDOW).c_str()); - if (currentMachineInfo->getNetworkAdaptersText().back().find(L"Unable") == string::npos) { - //createIPToggleControl(GetDlgItem(mainWindowHwnd, NETWORK_INFO)); - } SetWindowText(GetDlgItem(mainWindowHwnd, AUDIO_INFO), currentMachineInfo->getAudio().c_str()); if (!PROGRAM_INSTANCE) { - DWORD uptimeThreadId; HANDLE threadHandle = (HANDLE)_beginthreadex(0, 0, updateUptime, 0, 0, 0); + HANDLE cpuUtilThreadHandle = (HANDLE)_beginthreadex(0, 0, + updateCpuUtilizationPercentage, 0, 0, 0); } else { SetWindowText(GetDlgItem(mainWindowHwnd, UPTIME_INFO), currentMachineInfo->getUptime().c_str()); @@ -420,6 +451,30 @@ unsigned int __stdcall updateUptime(void *t) { _endthreadex(0); } +unsigned int __stdcall updateCpuUtilizationPercentage(void *t) { + + while (true) { + int cpuPercentage = getCpuUsagePercentage(); + currentCpuUsageGlobal = cpuPercentage; + if (cpuPercentage == 0) { + SetWindowText(GetDlgItem(mainWindowHwnd, + AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING), L"IDLE"); + } + else { + SetWindowText(GetDlgItem(mainWindowHwnd, + AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING), + std::to_wstring(cpuPercentage).append(L"%").c_str()); + } + SendDlgItemMessage(mainWindowHwnd, + AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE, + STM_SETICON, + (WPARAM)iconArrCpuUtilizationIcons.at((int)(cpuPercentage / 20)), + NULL); + Sleep(1000); + } + _endthreadex(0); +} + void createIPToggleControl(HWND parent, int xOff, int yOff) { CreateWindowEx( 0, @@ -437,6 +492,44 @@ void createIPToggleControl(HWND parent, int xOff, int yOff) { ); } +void createCpuUtiliazationInfoHolder(HWND parent, int xOff, int yOff) { + CreateWindowEx( + 0, + L"Static", + L"", + WS_VISIBLE | WS_CHILD | SS_LEFT | DS_SETFONT, + xOff, + yOff, + 80, + 15, + parent, + (HMENU)AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING, + NULL, + NULL + ); + CreateWindowEx( + 0, + L"Static", + NULL, + WS_VISIBLE | + WS_CHILD | + SS_ICON | SS_CENTER, + xOff + 28, + yOff, + ITEM_UTIL_ICON_RENDER_SIZE_WIDTH, + ITEM_UTIL_ICON_RENDER_SIZE_HEIGHT, + parent, + (HMENU)AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE, + NULL, + NULL + ); + SendDlgItemMessage(parent, + AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE, + STM_SETICON, + (WPARAM)iconArrCpuUtilizationIcons.at(0), + NULL); +} + void toggleIpAddress(HWND mainWindow, SystemInfo *info) { static bool showStatus = 0; static wstring savedIP; diff --git a/SystemInfo/mainWindowProcedure.h b/SystemInfo/mainWindowProcedure.h index db9ff74..ae7b67f 100644 --- a/SystemInfo/mainWindowProcedure.h +++ b/SystemInfo/mainWindowProcedure.h @@ -7,10 +7,12 @@ void createHardwareInfoHolders(HWND, SystemInfo*, int); void populateInfoHolders(SystemInfo *machine, HWND); void createIPToggleControl(HWND, int, int); + void createCpuUtiliazationInfoHolder(HWND, int, int); void loadImages(void); void toggleIpAddress(HWND, SystemInfo*); void updateNetworkAdaptersView(SystemInfo*); unsigned int __stdcall updateUptime(void*); + unsigned int __stdcall updateCpuUtilizationPercentage(void*); void scrollClientWindow(HWND hwnd, int bar, int pos); void fillGUI(HWND hwnd, SystemInfo *localMachine, int); #endif \ No newline at end of file diff --git a/SystemInfo/resource.h b/SystemInfo/resource.h index 12260f64d2da710d481dbeb6e7110d6588ea15c9..ddd50700d1888bba6bc33d4fc259e501d02461fc 100644 GIT binary patch delta 558 zcmZqBzGA+ii%~h0A%ww`!3T(=7#zWDe+EB>cp%@I0m3qw_)&Ip6O-8F4;(C$71($- z&thD}#_a@D6981{&R{s1k=dBp7)U3wNg|0Gfy5b&Co2j_BZ(TrL^+T}O`xKItjMCK zP|-#vaggOmrkH_bfOeVz?Nntno&1o^kkMqaB8NB;{xO(r$SMz3Ee-MxqZw3pAS*Gt z4WYV$E(Pm0hw28pkqEnupt_+x0-Im~GJ)9y>K98W&wTPkW>F$cGzOUn)NKw531&kE wgUNwR`ar$~k@`)cE{bQ9o*cj_vN?cb9~Yy-W^Q3iMqn5*a*J<{5m8|T00?Sqxc~qF delta 37 tcmca&-k`mqi*fS<#!YOK7x0U0Uck4HYjcvM86%_7WJWge%^Rdt7y%Y845$DA From c70c14cdac15f27ffe63a6f49cb5d10f8d3de4a0 Mon Sep 17 00:00:00 2001 From: CherryPill Date: Mon, 1 Jun 2020 00:39:18 +0300 Subject: [PATCH 02/10] Refactoring --- SystemInfo/Icons/icon2.ico | Bin 45451 -> 0 bytes SystemInfo/SystemInfo.aps | Bin 2102256 -> 2053372 bytes SystemInfo/SystemInfo.rc | Bin 13732 -> 13606 bytes SystemInfo/SystemInfo.vcxproj | 7 ----- SystemInfo/SystemInfo.vcxproj.filters | 25 ++------------- SystemInfo/core/sysinfo.cpp | 9 +++--- SystemInfo/core/sysinfo.h | 2 +- SystemInfo/dialog/aboutDialog.cpp | 2 +- SystemInfo/main.cpp | 4 +-- SystemInfo/mainWindowProcedure.cpp | 43 ++++++++++++-------------- SystemInfo/meta/SoftwareInfo.cpp | 2 +- SystemInfo/resource.h | Bin 7124 -> 5782 bytes 12 files changed, 32 insertions(+), 62 deletions(-) delete mode 100644 SystemInfo/Icons/icon2.ico diff --git a/SystemInfo/Icons/icon2.ico b/SystemInfo/Icons/icon2.ico deleted file mode 100644 index 5d06b9f2857b39f0b5d3395e3e7999ba6bcc3a38..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 45451 zcmeHQ2V4`$_n!>`f|LYoh=qWPSiy=FB49<4^YlDC1oTw&lwubJvRJ^5oLDFdo((IW z*bpR96!ApE*^r{)4iE(uM5G8w{xgB)x2_3AY2KgtFnKfc-n{pHZ`JR%LyWA^>Ijs5h#!!DKZ6<{ARP;Z)WQ z%>g()gwV$Z;XMI(w3^Td>rl`75JDdtETRL@{VV`mZLBA#x6x?>)v8aLXgM8elUh`Q z#BO=`LR4EZeS$eS_n^ybSfM+OojMkPKmAlI=0Z$B#ciVP3IH_XP{!`KhR+9}P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0 zjIgYpFpeU!ABZW}(_*?Vj4BvefCLA-F0gy?9VAphIVi^N*(FNUC`0NAI%^O z{9J|~)gV9OIKz)_kY8BD@Vn{op+Ru$v#EJzKf-1xzU=dWk&V%jg{}*fYHz$+;fVs; z4-Plh5;zR<5&bx7{^#}h(}9xxEsr`K$Ft`5gUs%+e5zQ+x8^%SMm~p6ZS4gan&WOv z6;~UnGKF1*RF%2VIvk6wNW!xa29OLnZ2-8-3Cc{>{FHipTsMm$Tk>!L(=n3QfP9H4AS delta 131 zcmZ3MwIq837w2R*A*IQ3!czo28C)1V8RCK1nZcjIkHK)VBX|7fD$WV47*a+cDfUc; zWQKf(yvc?_qMNz+MOZdp5f+nXHDJ(VFqmwpr#o3jf6ZhgJ)Ox+2H)VK;*%q!geJ>L L3vISAe8&s`8@3 - @@ -213,17 +212,11 @@ - - - - - - diff --git a/SystemInfo/SystemInfo.vcxproj.filters b/SystemInfo/SystemInfo.vcxproj.filters index 46d2d98..33b69ee 100644 --- a/SystemInfo/SystemInfo.vcxproj.filters +++ b/SystemInfo/SystemInfo.vcxproj.filters @@ -207,33 +207,12 @@ Resource Files - - Resource Files - Resource Files Resource Files - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - Resource Files @@ -246,10 +225,10 @@ Resource Files - + Resource Files - + Resource Files diff --git a/SystemInfo/core/sysinfo.cpp b/SystemInfo/core/sysinfo.cpp index b4737c7..85377d8 100644 --- a/SystemInfo/core/sysinfo.cpp +++ b/SystemInfo/core/sysinfo.cpp @@ -654,7 +654,7 @@ wstring getRamBySlot(HRESULT hres, return wstring(capacityStrBuff); } -int getCpuUsagePercentage() { +unsigned int getCpuUsagePercentage() { vector queryAttrs = wmiClassStringsMap.at(L"Win32_PerfFormattedData_PerfOS_Processor"); IEnumWbemClassObject* pEnumerator = executeWQLQuery (wmiWbemInfo->getHres(), @@ -664,13 +664,13 @@ int getCpuUsagePercentage() { IWbemClassObject* pclsObj = NULL; ULONG uReturn = 0; - - int cpuUsage = 0; + //if -1, then WMI for some reason didn't get the data from the tables + int cpuUsage = -1; while (pEnumerator) { HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn); - if (0 == uReturn){ + if (0 == uReturn) { break; } @@ -683,6 +683,7 @@ int getCpuUsagePercentage() { VariantClear(&vtProp); pclsObj->Release(); pclsObj = NULL; } + throw std::exception("Failed to get info from perf table"); break; } cpuUsage = std::stoi(vtProp.bstrVal); diff --git a/SystemInfo/core/sysinfo.h b/SystemInfo/core/sysinfo.h index eb1ad63..684c65b 100644 --- a/SystemInfo/core/sysinfo.h +++ b/SystemInfo/core/sysinfo.h @@ -86,7 +86,7 @@ void fillUptime(SystemInfo *localMachine); void fillDimensionsAndFrequency(HRESULT, IWbemServices*, IWbemLocator*, UINT*); wstring getSocket(HRESULT, IWbemServices*, IWbemLocator*); - int getCpuUsagePercentage(void); + unsigned int getCpuUsagePercentage(void); IEnumWbemClassObject* executeWQLQuery(HRESULT hres, IWbemLocator *pLoc, IWbemServices *pSvc, BSTR stringQuery); bstr_t buildQueryString(const wchar_t *wmiClass, vector attrs); bstr_t buildQueryString(const wchar_t* wmiClass, vector attrs, const wchar_t *whereClause); diff --git a/SystemInfo/dialog/aboutDialog.cpp b/SystemInfo/dialog/aboutDialog.cpp index 7f1bcf1..2b31c78 100644 --- a/SystemInfo/dialog/aboutDialog.cpp +++ b/SystemInfo/dialog/aboutDialog.cpp @@ -18,7 +18,7 @@ BOOL CALLBACK aboutDlgProc(HWND dlgHandle, UINT message, WPARAM wParam, LPARAM l break; } case WM_INITDIALOG: { - SendDlgItemMessage(dlgHandle, IDC_STATIC_ICON, STM_SETICON, (WPARAM)(HICON)LoadImage(ghInstance, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 64, 64, NULL), NULL); + SendDlgItemMessage(dlgHandle, IDC_STATIC_ICON, STM_SETICON, (WPARAM)(HICON)LoadImage(ghInstance, MAKEINTRESOURCE(MAIN_APP_ICON), IMAGE_ICON, 64, 64, NULL), NULL); DWORD buffSize = 256; TCHAR inputBuff[256]; ZeroMemory(inputBuff, sizeof(inputBuff)); diff --git a/SystemInfo/main.cpp b/SystemInfo/main.cpp index 92de213..b70984d 100644 --- a/SystemInfo/main.cpp +++ b/SystemInfo/main.cpp @@ -36,8 +36,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); wc.lpfnWndProc = mainWindowProc; wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 0, 0, NULL); - wc.hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 32, 32, NULL); + wc.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(MAIN_APP_ICON), IMAGE_ICON, 0, 0, NULL); + wc.hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(MAIN_APP_ICON), IMAGE_ICON, 32, 32, NULL); if (!RegisterClassEx(&wc)) { MessageBox(NULL, L"Window class registration failed", L"Error", MB_ICONERROR); return FALSE; diff --git a/SystemInfo/mainWindowProcedure.cpp b/SystemInfo/mainWindowProcedure.cpp index bd15ad9..455f5d4 100644 --- a/SystemInfo/mainWindowProcedure.cpp +++ b/SystemInfo/mainWindowProcedure.cpp @@ -452,24 +452,26 @@ unsigned int __stdcall updateUptime(void *t) { } unsigned int __stdcall updateCpuUtilizationPercentage(void *t) { - while (true) { int cpuPercentage = getCpuUsagePercentage(); - currentCpuUsageGlobal = cpuPercentage; - if (cpuPercentage == 0) { - SetWindowText(GetDlgItem(mainWindowHwnd, - AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING), L"IDLE"); - } - else { - SetWindowText(GetDlgItem(mainWindowHwnd, - AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING), - std::to_wstring(cpuPercentage).append(L"%").c_str()); - } - SendDlgItemMessage(mainWindowHwnd, - AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE, - STM_SETICON, - (WPARAM)iconArrCpuUtilizationIcons.at((int)(cpuPercentage / 20)), - NULL); + if (cpuPercentage != -1) { + currentCpuUsageGlobal = cpuPercentage; + if (cpuPercentage == 0) { + SetWindowText(GetDlgItem(mainWindowHwnd, + AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING), L"IDLE"); + } + else { + SetWindowText(GetDlgItem(mainWindowHwnd, + AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING), + std::to_wstring(cpuPercentage).append(L"%").c_str()); + } + SendDlgItemMessage(mainWindowHwnd, + AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE, + STM_SETICON, + (WPARAM)iconArrCpuUtilizationIcons.at((int)(cpuPercentage / 20)), + NULL); + } + Sleep(1000); } _endthreadex(0); @@ -497,10 +499,10 @@ void createCpuUtiliazationInfoHolder(HWND parent, int xOff, int yOff) { 0, L"Static", L"", - WS_VISIBLE | WS_CHILD | SS_LEFT | DS_SETFONT, + WS_VISIBLE | WS_CHILD | SS_RIGHT | DS_SETFONT, xOff, yOff, - 80, + 26, 15, parent, (HMENU)AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING, @@ -523,11 +525,6 @@ void createCpuUtiliazationInfoHolder(HWND parent, int xOff, int yOff) { NULL, NULL ); - SendDlgItemMessage(parent, - AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE, - STM_SETICON, - (WPARAM)iconArrCpuUtilizationIcons.at(0), - NULL); } void toggleIpAddress(HWND mainWindow, SystemInfo *info) { diff --git a/SystemInfo/meta/SoftwareInfo.cpp b/SystemInfo/meta/SoftwareInfo.cpp index 94718c5..03bc6db 100644 --- a/SystemInfo/meta/SoftwareInfo.cpp +++ b/SystemInfo/meta/SoftwareInfo.cpp @@ -5,7 +5,7 @@ SoftwareInfo::SoftwareInfo() { this->setSoftwareName(_T("SystemInfo")); this->setSoftwareDesc(_T("Hardware information tool for Windows")); this->setSoftwareRepo(_T("https://github.com/CherryPill/system_info")); - this->setSoftwareVer(_T("1.4.2 [32-bit]")); + this->setSoftwareVer(_T("1.4.3 [32-bit]")); } SoftwareInfo::~SoftwareInfo() {} diff --git a/SystemInfo/resource.h b/SystemInfo/resource.h index ddd50700d1888bba6bc33d4fc259e501d02461fc..44ebc7623e174020e0225e73632ab641f12ebc6d 100644 GIT binary patch delta 172 zcmca&K23MRJ$_#XM+Q#@KZbZ99l#JU`6H9zUZ9h&o0#>B$TDMK&+s`@s!1)=^4x^ARZlMgR2xe=`AUCYB9GPkQ9Y%HPra*36s{JCLq T$^IM>@7w6YTc=mtcINRvFIs&r From 532f4dbfa1519b4fabb8072c56eacfcda85db47e Mon Sep 17 00:00:00 2001 From: CherryPill Date: Wed, 10 Jun 2020 18:50:37 +0300 Subject: [PATCH 03/10] Add control manager, simple logger, cpu usage refactoring --- SystemInfo.sln | 2 + SystemInfo/SystemInfo.vcxproj | 4 ++ SystemInfo/SystemInfo.vcxproj.filters | 15 +++++ SystemInfo/const/appconst.h | 2 +- SystemInfo/const/itemIDs.h | 3 +- SystemInfo/controlManager.cpp | 49 ++++++++++++++++ SystemInfo/controlManager.h | 23 ++++++++ SystemInfo/glb/globalVars.cpp | 7 ++- SystemInfo/glb/globalVars.h | 13 ++++- SystemInfo/logger/logger.cpp | 21 +++++++ SystemInfo/logger/logger.h | 21 +++++++ SystemInfo/mainWindowProcedure.cpp | 80 +++++++++++++++++++-------- SystemInfo/mainWindowProcedure.h | 1 + 13 files changed, 211 insertions(+), 30 deletions(-) create mode 100644 SystemInfo/controlManager.cpp create mode 100644 SystemInfo/controlManager.h create mode 100644 SystemInfo/logger/logger.cpp create mode 100644 SystemInfo/logger/logger.h diff --git a/SystemInfo.sln b/SystemInfo.sln index 158bd64..2da3242 100644 --- a/SystemInfo.sln +++ b/SystemInfo.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.28729.10 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SystemInfo", "SystemInfo\SystemInfo.vcxproj", "{48DC8C62-89CF-4F86-BFE0-42AA4080A9B8}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{00560159-1600-41C9-BB56-BE1CE22C58BD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 diff --git a/SystemInfo/SystemInfo.vcxproj b/SystemInfo/SystemInfo.vcxproj index c4d8f75..68a5aaf 100644 --- a/SystemInfo/SystemInfo.vcxproj +++ b/SystemInfo/SystemInfo.vcxproj @@ -161,6 +161,7 @@ + @@ -169,6 +170,7 @@ + @@ -183,6 +185,7 @@ + @@ -192,6 +195,7 @@ + diff --git a/SystemInfo/SystemInfo.vcxproj.filters b/SystemInfo/SystemInfo.vcxproj.filters index 33b69ee..4e84983 100644 --- a/SystemInfo/SystemInfo.vcxproj.filters +++ b/SystemInfo/SystemInfo.vcxproj.filters @@ -49,6 +49,9 @@ {6978f6a2-6a74-4303-8e45-40d49674e069} + + {d1cbdcf0-8a30-40f3-8555-149fa60d0ab0} + @@ -102,6 +105,12 @@ core + + logger + + + util + @@ -167,6 +176,12 @@ core + + logger + + + util + diff --git a/SystemInfo/const/appconst.h b/SystemInfo/const/appconst.h index 7d47ac3..c271fe6 100644 --- a/SystemInfo/const/appconst.h +++ b/SystemInfo/const/appconst.h @@ -9,5 +9,5 @@ #define ITEM_ICON_SIZE 16 #define ITEM_UTIL_ICON_RENDER_SIZE_WIDTH 12 #define ITEM_UTIL_ICON_RENDER_SIZE_HEIGHT 14 - #define MOUSE_WHEEL_SCROLL 120 + #define MOUSE_WHEEL_SCROLL 120 #endif \ No newline at end of file diff --git a/SystemInfo/const/itemIDs.h b/SystemInfo/const/itemIDs.h index 224c3a5..7d9fbb6 100644 --- a/SystemInfo/const/itemIDs.h +++ b/SystemInfo/const/itemIDs.h @@ -28,9 +28,10 @@ #define END_INFO 24 #define AUX_IP_TOGGLE 720 - #define AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE 820 + #define AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_ICON 820 #define AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING 920 + #define INFO_ID_OFFSET 12 #define ICON_ID_OFFSET 60 #endif \ No newline at end of file diff --git a/SystemInfo/controlManager.cpp b/SystemInfo/controlManager.cpp new file mode 100644 index 0000000..5f7e654 --- /dev/null +++ b/SystemInfo/controlManager.cpp @@ -0,0 +1,49 @@ +#include "controlManager.h" +HWND ControlManager::appCreateControl( + TCHAR *className, + int xOffset, + int yOffSet, + int width, + int height, + std::bitset<32> windowStyles, + HWND parent, + int controlMenuID, + TCHAR* windowName, + DWORD exStyle, + HINSTANCE hInstance, + LPVOID lParam + ) { + HWND createdWindow = CreateWindowEx( + 0, + className, + windowName, + windowStyles.to_ulong(), + xOffset, + yOffSet, + width, + height, + parent, + (HMENU)controlMenuID, + hInstance, + lParam + ); + if (!createdWindow) { + DWORD errCode = GetLastError(); + + //to do: implement this https://docs.microsoft.com/en-us/windows/win32/debug/retrieving-the-last-error-code + + int s = 11; + } + return createdWindow; +} + +bool ControlManager::searchAndDestroy( + HWND parentWindowHandle, + TCHAR *className, + TCHAR *windowName) { + HWND foundWindowHandle = NULL; + if ((foundWindowHandle = FindWindowEx(NULL, NULL, className, windowName)) != NULL) { + return DestroyWindow(foundWindowHandle); + } + return false; +} \ No newline at end of file diff --git a/SystemInfo/controlManager.h b/SystemInfo/controlManager.h new file mode 100644 index 0000000..ab113c0 --- /dev/null +++ b/SystemInfo/controlManager.h @@ -0,0 +1,23 @@ +#pragma once +#include +#include +class ControlManager { +public: + static HWND appCreateControl( + TCHAR* className, + int xOffset, + int yOffSet, + int width, + int height, + std::bitset<32> windowStyles, + HWND parent, + int controlMenuID, + TCHAR* windowName = NULL, + DWORD exStyle = 0, + HINSTANCE hInstance = NULL, + LPVOID lParam = NULL); + static bool searchAndDestroy( + HWND parentWindowHandle, + TCHAR *className, + TCHAR *windowName); +}; \ No newline at end of file diff --git a/SystemInfo/glb/globalVars.cpp b/SystemInfo/glb/globalVars.cpp index 3374021..4510249 100644 --- a/SystemInfo/glb/globalVars.cpp +++ b/SystemInfo/glb/globalVars.cpp @@ -49,8 +49,9 @@ TCHAR *timeVerboseDaysOfWeek[] = { TCHAR sysInfoConfigDirectoryPath[256] = {}; -int currentCpuUsageGlobal = 0; +int currentCpuUsageGlobal = -1; -int cpuInfoHolderXoffset = 0; -int cpuInfoHolderYoffset = 0; \ No newline at end of file +int glbCpuInfoHolderXoffset = 0; +int glbCpuInfoHolderYoffset = 0; + diff --git a/SystemInfo/glb/globalVars.h b/SystemInfo/glb/globalVars.h index d323e95..828e34d 100644 --- a/SystemInfo/glb/globalVars.h +++ b/SystemInfo/glb/globalVars.h @@ -25,6 +25,15 @@ static vector iconArrCpuUtilizationIcons; const static int iconArrCpuUtilizationIconsSize = 6; const static int totalItemsCount = 13; + +static int glbCpuProgressStringXOffset; +static int glbCpuProgressStringYOffset; +const static int cpuProgressStringWindowWidthSmall = 26; + +const static int cpuProgressStringWindowHeightSmall = 15; +const static int cpuProgressStringWindowWidthLarge = 40; +const static int cpuProgressStringWindowHeightLarge = 15; + static WORD ICON_IDS[totalItemsCount]{ BIOS_ICON, OS_ICON, @@ -176,7 +185,7 @@ extern WNDPROC lpfnScrEditProc; extern TCHAR sysInfoConfigDirectoryPath[256]; extern int currentCpuUsageGlobal; -extern int cpuInfoHolderXoffset; -extern int cpuInfoHolderYoffset; +extern int glbCpuInfoHolderXoffset; +extern int glbCpuInfoHolderYoffset; #endif \ No newline at end of file diff --git a/SystemInfo/logger/logger.cpp b/SystemInfo/logger/logger.cpp new file mode 100644 index 0000000..ac63fcb --- /dev/null +++ b/SystemInfo/logger/logger.cpp @@ -0,0 +1,21 @@ +#include "logger.h" + +SimpleLogger* SimpleLogger::loggerInstance; +SimpleLogger* SimpleLogger::getLoggerInstance() { + if (loggerInstance == nullptr) { + loggerInstance = new SimpleLogger(); + } + return loggerInstance; +} + +void SimpleLogger::info() { + +} + +void SimpleLogger::error() { + +} + +void SimpleLogger::debug() { + +} \ No newline at end of file diff --git a/SystemInfo/logger/logger.h b/SystemInfo/logger/logger.h new file mode 100644 index 0000000..8e41153 --- /dev/null +++ b/SystemInfo/logger/logger.h @@ -0,0 +1,21 @@ +#pragma once +#include +#include +#include +class SimpleLogger { +private: + static SimpleLogger*loggerInstance; + std::wofstream outLoggerStream; + TCHAR *hardCodedLoggerOutFilePath = L""; + SimpleLogger() { + std::locale loc(std::locale::classic(), new std::codecvt_utf8); + outLoggerStream.open(hardCodedLoggerOutFilePath, std::wofstream::out); + outLoggerStream.imbue(loc); //todo create configAppData directory on application startup + } +public: + static SimpleLogger *getLoggerInstance(); + static void info(); + static void error(); + static void debug(); + +}; \ No newline at end of file diff --git a/SystemInfo/mainWindowProcedure.cpp b/SystemInfo/mainWindowProcedure.cpp index 455f5d4..23ff8cf 100644 --- a/SystemInfo/mainWindowProcedure.cpp +++ b/SystemInfo/mainWindowProcedure.cpp @@ -21,6 +21,7 @@ #include "import/binImport.h" #include "core/WMIWBEMINFO.h" #include "core/sysinfo.h" +#include "controlManager.h" int g_scrollY = 0; LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -112,14 +113,19 @@ LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } } else if (GetDlgCtrlID((HWND)lParam) == AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING) { - if (currentCpuUsageGlobal <= 33) { - SetTextColor(hdcStatic, RGB(0, 255, 0)); - } - else if (currentCpuUsageGlobal > 33 && currentCpuUsageGlobal <= 66) { - SetTextColor(hdcStatic, RGB(255, 255, 0)); + if (currentCpuUsageGlobal >= 0) { + if (currentCpuUsageGlobal <= 33) { + SetTextColor(hdcStatic, RGB(0, 255, 0)); + } + else if (currentCpuUsageGlobal > 33 && currentCpuUsageGlobal <= 66) { + SetTextColor(hdcStatic, RGB(255, 255, 0)); + } + else { + SetTextColor(hdcStatic, RGB(255, 0, 0)); + } } else { - SetTextColor(hdcStatic, RGB(255, 0, 0)); + SetTextColor(hdcStatic, RGB(255, 255, 255)); } } else { @@ -370,8 +376,8 @@ void createHardwareInfoHolders(HWND parent, SystemInfo *info, int offsetIndex) { NULL ); if (y == CPU_INFO) { - cpuInfoHolderXoffset = xStartOffSetInformation; - cpuInfoHolderYoffset = yStartOffSet + 16; + glbCpuInfoHolderXoffset = xStartOffSetInformation; + glbCpuInfoHolderYoffset = yStartOffSet + 16; } if (y >= GPU_INFO && y < AUDIO_INFO) { UINT32 listSize = getInfoBoxItemCount(y, info); @@ -401,7 +407,11 @@ void populateInfoHolders(SystemInfo *currentMachineInfo, HWND mainWindowHwnd) { HWND cpuInfoHolderHandle = GetDlgItem(mainWindowHwnd, CPU_INFO); int charLen = GetWindowTextLength(cpuInfoHolderHandle); - createCpuUtiliazationInfoHolder(mainWindowHwnd, cpuInfoHolderXoffset + charLen * 6, cpuInfoHolderYoffset); + if (!PROGRAM_INSTANCE) { + glbCpuInfoHolderXoffset = glbCpuInfoHolderXoffset + charLen * 6; + createCpuUtiliazationInfoHolder(mainWindowHwnd, glbCpuInfoHolderXoffset, glbCpuInfoHolderYoffset); + + } SetWindowText(GetDlgItem(mainWindowHwnd, MB_INFO), currentMachineInfo->getMB().c_str()); @@ -452,6 +462,7 @@ unsigned int __stdcall updateUptime(void *t) { } unsigned int __stdcall updateCpuUtilizationPercentage(void *t) { + while (true) { int cpuPercentage = getCpuUsagePercentage(); if (cpuPercentage != -1) { @@ -466,17 +477,33 @@ unsigned int __stdcall updateCpuUtilizationPercentage(void *t) { std::to_wstring(cpuPercentage).append(L"%").c_str()); } SendDlgItemMessage(mainWindowHwnd, - AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE, + AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_ICON, STM_SETICON, (WPARAM)iconArrCpuUtilizationIcons.at((int)(cpuPercentage / 20)), NULL); - } + } Sleep(1000); } _endthreadex(0); } +unsigned int __stdcall playLoadTextAnimation(void *t) { + std::wstring animationCharArr[4] = {L"--", L"\\", L"|", L"/"}; + while (currentCpuUsageGlobal < 0) { + for (const auto &ch : animationCharArr) { + if (currentCpuUsageGlobal < 0) { + return 0; + } + SetWindowText(GetDlgItem(mainWindowHwnd, + AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING), + ch.c_str()); + Sleep(1000); + } + } + return 0; +} + void createIPToggleControl(HWND parent, int xOff, int yOff) { CreateWindowEx( 0, @@ -495,36 +522,43 @@ void createIPToggleControl(HWND parent, int xOff, int yOff) { } void createCpuUtiliazationInfoHolder(HWND parent, int xOff, int yOff) { - CreateWindowEx( - 0, + + ControlManager::appCreateControl( L"Static", - L"", - WS_VISIBLE | WS_CHILD | SS_RIGHT | DS_SETFONT, xOff, yOff, - 26, - 15, + cpuProgressStringWindowWidthLarge, + cpuProgressStringWindowHeightLarge, + WS_VISIBLE | WS_CHILD | SS_RIGHT | DS_SETFONT, parent, - (HMENU)AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING, - NULL, - NULL + AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING, + L"--" ); + HANDLE cpuLoadTextAnimation = (HANDLE)_beginthreadex(0, 0, + playLoadTextAnimation, 0, 0, 0); CreateWindowEx( 0, L"Static", NULL, WS_VISIBLE | WS_CHILD | - SS_ICON | SS_CENTER, - xOff + 28, + SS_ICON | + SS_CENTER, + xOff + cpuProgressStringWindowWidthLarge + 5, yOff, ITEM_UTIL_ICON_RENDER_SIZE_WIDTH, ITEM_UTIL_ICON_RENDER_SIZE_HEIGHT, parent, - (HMENU)AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE, + (HMENU)AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_ICON, NULL, NULL ); + SendDlgItemMessage(parent, + AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_ICON, + STM_SETICON, + (WPARAM)iconArrCpuUtilizationIcons.at(0), + NULL); + } void toggleIpAddress(HWND mainWindow, SystemInfo *info) { diff --git a/SystemInfo/mainWindowProcedure.h b/SystemInfo/mainWindowProcedure.h index ae7b67f..42b4a20 100644 --- a/SystemInfo/mainWindowProcedure.h +++ b/SystemInfo/mainWindowProcedure.h @@ -13,6 +13,7 @@ void updateNetworkAdaptersView(SystemInfo*); unsigned int __stdcall updateUptime(void*); unsigned int __stdcall updateCpuUtilizationPercentage(void*); + unsigned int __stdcall playLoadTextAnimation(void*); void scrollClientWindow(HWND hwnd, int bar, int pos); void fillGUI(HWND hwnd, SystemInfo *localMachine, int); #endif \ No newline at end of file From a9d9da6282fc0c3fff6d79ac6f88c714d65bf11a Mon Sep 17 00:00:00 2001 From: CherryPill Date: Wed, 10 Jun 2020 21:55:19 +0300 Subject: [PATCH 04/10] fix typo, misc logic fixes --- SystemInfo/mainWindowProcedure.cpp | 22 ++++++++-------------- SystemInfo/mainWindowProcedure.h | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/SystemInfo/mainWindowProcedure.cpp b/SystemInfo/mainWindowProcedure.cpp index 23ff8cf..c896f65 100644 --- a/SystemInfo/mainWindowProcedure.cpp +++ b/SystemInfo/mainWindowProcedure.cpp @@ -409,7 +409,7 @@ void populateInfoHolders(SystemInfo *currentMachineInfo, HWND mainWindowHwnd) { int charLen = GetWindowTextLength(cpuInfoHolderHandle); if (!PROGRAM_INSTANCE) { glbCpuInfoHolderXoffset = glbCpuInfoHolderXoffset + charLen * 6; - createCpuUtiliazationInfoHolder(mainWindowHwnd, glbCpuInfoHolderXoffset, glbCpuInfoHolderYoffset); + createCpuUtilizationInfoHolder(mainWindowHwnd, glbCpuInfoHolderXoffset, glbCpuInfoHolderYoffset); } @@ -492,13 +492,13 @@ unsigned int __stdcall playLoadTextAnimation(void *t) { std::wstring animationCharArr[4] = {L"--", L"\\", L"|", L"/"}; while (currentCpuUsageGlobal < 0) { for (const auto &ch : animationCharArr) { - if (currentCpuUsageGlobal < 0) { + if (currentCpuUsageGlobal >= 0) { return 0; } SetWindowText(GetDlgItem(mainWindowHwnd, AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING), ch.c_str()); - Sleep(1000); + Sleep(500); } } return 0; @@ -521,7 +521,7 @@ void createIPToggleControl(HWND parent, int xOff, int yOff) { ); } -void createCpuUtiliazationInfoHolder(HWND parent, int xOff, int yOff) { +void createCpuUtilizationInfoHolder(HWND parent, int xOff, int yOff) { ControlManager::appCreateControl( L"Static", @@ -536,23 +536,17 @@ void createCpuUtiliazationInfoHolder(HWND parent, int xOff, int yOff) { ); HANDLE cpuLoadTextAnimation = (HANDLE)_beginthreadex(0, 0, playLoadTextAnimation, 0, 0, 0); - CreateWindowEx( - 0, + ControlManager::appCreateControl( L"Static", - NULL, - WS_VISIBLE | - WS_CHILD | - SS_ICON | - SS_CENTER, xOff + cpuProgressStringWindowWidthLarge + 5, yOff, ITEM_UTIL_ICON_RENDER_SIZE_WIDTH, ITEM_UTIL_ICON_RENDER_SIZE_HEIGHT, + WS_VISIBLE | WS_CHILD | SS_ICON | SS_CENTER, parent, - (HMENU)AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_ICON, - NULL, - NULL + AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_ICON ); + SendDlgItemMessage(parent, AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_ICON, STM_SETICON, diff --git a/SystemInfo/mainWindowProcedure.h b/SystemInfo/mainWindowProcedure.h index 42b4a20..f2f6a9e 100644 --- a/SystemInfo/mainWindowProcedure.h +++ b/SystemInfo/mainWindowProcedure.h @@ -7,7 +7,7 @@ void createHardwareInfoHolders(HWND, SystemInfo*, int); void populateInfoHolders(SystemInfo *machine, HWND); void createIPToggleControl(HWND, int, int); - void createCpuUtiliazationInfoHolder(HWND, int, int); + void createCpuUtilizationInfoHolder(HWND, int, int); void loadImages(void); void toggleIpAddress(HWND, SystemInfo*); void updateNetworkAdaptersView(SystemInfo*); From f15520917bec60e86161079582cf0c0660508b66 Mon Sep 17 00:00:00 2001 From: CherryPill Date: Fri, 12 Jun 2020 14:07:48 +0300 Subject: [PATCH 05/10] Refactor message display logic, multiple fixes --- SystemInfo/SystemInfo.vcxproj | 4 +- SystemInfo/SystemInfo.vcxproj.filters | 4 +- SystemInfo/controlManager.cpp | 49 --------------- SystemInfo/controlManager.h | 23 ------- SystemInfo/core/sysinfo.cpp | 8 ++- SystemInfo/dialog/scrUploadDialog.cpp | 5 +- SystemInfo/glb/globalVars.h | 14 ++--- SystemInfo/import/binImport.cpp | 6 +- SystemInfo/mainWindowProcedure.cpp | 27 ++++++-- SystemInfo/util/controlManager.cpp | 80 ++++++++++++++++++++++++ SystemInfo/util/controlManager.h | 90 +++++++++++++++++++++++++++ SystemInfo/util/utility.cpp | 70 +++++++-------------- SystemInfo/util/utility.h | 18 ++---- 13 files changed, 241 insertions(+), 157 deletions(-) delete mode 100644 SystemInfo/controlManager.cpp delete mode 100644 SystemInfo/controlManager.h create mode 100644 SystemInfo/util/controlManager.cpp create mode 100644 SystemInfo/util/controlManager.h diff --git a/SystemInfo/SystemInfo.vcxproj b/SystemInfo/SystemInfo.vcxproj index 68a5aaf..4bf1586 100644 --- a/SystemInfo/SystemInfo.vcxproj +++ b/SystemInfo/SystemInfo.vcxproj @@ -169,8 +169,8 @@ + - @@ -194,8 +194,8 @@ + - diff --git a/SystemInfo/SystemInfo.vcxproj.filters b/SystemInfo/SystemInfo.vcxproj.filters index 4e84983..a269e7f 100644 --- a/SystemInfo/SystemInfo.vcxproj.filters +++ b/SystemInfo/SystemInfo.vcxproj.filters @@ -108,7 +108,7 @@ logger - + util @@ -179,7 +179,7 @@ logger - + util diff --git a/SystemInfo/controlManager.cpp b/SystemInfo/controlManager.cpp deleted file mode 100644 index 5f7e654..0000000 --- a/SystemInfo/controlManager.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "controlManager.h" -HWND ControlManager::appCreateControl( - TCHAR *className, - int xOffset, - int yOffSet, - int width, - int height, - std::bitset<32> windowStyles, - HWND parent, - int controlMenuID, - TCHAR* windowName, - DWORD exStyle, - HINSTANCE hInstance, - LPVOID lParam - ) { - HWND createdWindow = CreateWindowEx( - 0, - className, - windowName, - windowStyles.to_ulong(), - xOffset, - yOffSet, - width, - height, - parent, - (HMENU)controlMenuID, - hInstance, - lParam - ); - if (!createdWindow) { - DWORD errCode = GetLastError(); - - //to do: implement this https://docs.microsoft.com/en-us/windows/win32/debug/retrieving-the-last-error-code - - int s = 11; - } - return createdWindow; -} - -bool ControlManager::searchAndDestroy( - HWND parentWindowHandle, - TCHAR *className, - TCHAR *windowName) { - HWND foundWindowHandle = NULL; - if ((foundWindowHandle = FindWindowEx(NULL, NULL, className, windowName)) != NULL) { - return DestroyWindow(foundWindowHandle); - } - return false; -} \ No newline at end of file diff --git a/SystemInfo/controlManager.h b/SystemInfo/controlManager.h deleted file mode 100644 index ab113c0..0000000 --- a/SystemInfo/controlManager.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include -#include -class ControlManager { -public: - static HWND appCreateControl( - TCHAR* className, - int xOffset, - int yOffSet, - int width, - int height, - std::bitset<32> windowStyles, - HWND parent, - int controlMenuID, - TCHAR* windowName = NULL, - DWORD exStyle = 0, - HINSTANCE hInstance = NULL, - LPVOID lParam = NULL); - static bool searchAndDestroy( - HWND parentWindowHandle, - TCHAR *className, - TCHAR *windowName); -}; \ No newline at end of file diff --git a/SystemInfo/core/sysinfo.cpp b/SystemInfo/core/sysinfo.cpp index 85377d8..a7b33ea 100644 --- a/SystemInfo/core/sysinfo.cpp +++ b/SystemInfo/core/sysinfo.cpp @@ -14,6 +14,7 @@ #include "../SMBIOS.h" #include "../mainWindowProcedure.h" #include "../core/WMIWBEMINFO.h" +#include "../util/controlManager.h" //TODO: Conflate fillMB and fillCPU into one procedure since MB uses socket info available on Win32_Processor @@ -564,8 +565,11 @@ IEnumWbemClassObject* executeWQLQuery(HRESULT hres, IWbemLocator * pLoc, &pEnumerator); //test this behavior if (FAILED(hres)) { - displayMessageGeneric(UI_MESS_RES::FAILURE, - L"Fatal error: Query to operating system failed"); + GenericMessageOK() + .withMessage(L"Fatal error: Query to operating system failed") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); + pSvc->Release(); pLoc->Release(); CoUninitialize(); diff --git a/SystemInfo/dialog/scrUploadDialog.cpp b/SystemInfo/dialog/scrUploadDialog.cpp index 03d585a..68bbc59 100644 --- a/SystemInfo/dialog/scrUploadDialog.cpp +++ b/SystemInfo/dialog/scrUploadDialog.cpp @@ -1,6 +1,7 @@ #include "scrUploadDialog.h" #include "../util/utility.h" #include "../glb/globalVars.h" +#include "../util/controlManager.h" UPLOAD_SRC_LINK_DATA uploadSrcLinkData = {}; BOOL CALLBACK scrDlgProc(HWND dlgHandle, UINT message, WPARAM wParam, LPARAM lParam) { @@ -35,8 +36,8 @@ LRESULT CALLBACK editCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_LBUTTONDOWN: { SetWindowText(GetDlgItem(GetParent(hwnd), IDC_STATIC_SCRCOPYDONE), copyLinkToClipboard() ? - UI_messagesTxt[2].c_str() : - UI_messagesTxt[3].c_str()); + ControlManager::UI_messagesTxt[2].c_str() : + ControlManager::UI_messagesTxt[3].c_str()); break; } } diff --git a/SystemInfo/glb/globalVars.h b/SystemInfo/glb/globalVars.h index 828e34d..5f56b1c 100644 --- a/SystemInfo/glb/globalVars.h +++ b/SystemInfo/glb/globalVars.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "../meta/SoftwareInfo.h" #include "../resource.h" @@ -58,12 +59,7 @@ static WORD UTIL_iCON_IDS[iconArrCpuUtilizationIconsSize]{ UTILIZATION_ICON_5 }; -static wstring UI_messagesTxt[] = { - L"Successfully written to ", - L"Error writing to ", - L"Link successfully copied to clipboard", - L"There's been a problem copying link to clipboard" -}; + static wstring UI_messagesCapt[] = { L"Success", @@ -85,15 +81,15 @@ static wstring itemStrings[totalItemsCount] = { L"Uptime", L"Snapshot" }; - -static TCHAR *savefileExtensions[5] = { +//DO NOT change, a map depends on it +static TCHAR* savefileExtensions[] = { _T(".txt"), _T(".xml"), _T(".html"), _T(".png") }; -static TCHAR *savefileExtensionsLong[5] = { +static TCHAR *savefileExtensionsLong[] = { _T(".txt files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"), _T(".xml files (*.xml)\0*.xml\0All Files (*.*)\0*.*\0"), _T(".html files (*.html)\0*.html\0All Files (*.*)\0*.*\0"), diff --git a/SystemInfo/import/binImport.cpp b/SystemInfo/import/binImport.cpp index eef1579..ff63fd5 100644 --- a/SystemInfo/import/binImport.cpp +++ b/SystemInfo/import/binImport.cpp @@ -1,5 +1,6 @@ #include "../util/utility.h" #include "../import/binImport.h" +#include "../util/controlManager.h" void importData(SystemInfo* snapshotInstance) { pugi::xml_document doc; pugi::xml_parse_result res = doc.load_file(PROGRAM_DATA_IMPORT_LOCATION); @@ -49,6 +50,9 @@ void importData(SystemInfo* snapshotInstance) { } } } else { - displayMessageGeneric(UI_MESS_RES::FAILURE, _T("Unable to parse XML file")); + GenericMessageOK() + .withMessage(L"Unable to parse XML file") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); } } diff --git a/SystemInfo/mainWindowProcedure.cpp b/SystemInfo/mainWindowProcedure.cpp index c896f65..1def32b 100644 --- a/SystemInfo/mainWindowProcedure.cpp +++ b/SystemInfo/mainWindowProcedure.cpp @@ -21,7 +21,7 @@ #include "import/binImport.h" #include "core/WMIWBEMINFO.h" #include "core/sysinfo.h" -#include "controlManager.h" +#include "util/controlManager.h" int g_scrollY = 0; LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -68,16 +68,33 @@ LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara saveSpecs::save(receivedCommand, &resStruct, hwnd, localMachine->getCurrentInstance()); if (resStruct.result == ACTION::ACCEPTED) { - displayExportMessage(UI_MESS_RES::SUCCESS, getUIMessByCommand(receivedCommand)); - if (displayPromptForAction(actionPromptText[0]) == IDYES) { + GenericMessageOK() + .withMessage( + formMessageForUIExportByExportAction + (ControlManager::UI_MESS_RES_ICON::QUESTION, + receivedCommand) + ) + ->withIcon(ControlManager::UI_MESS_RES_ICON::SUCCESS) + ->display(); + + if (PromptMessageYesNo() + .withMessage(actionPromptText[0]) + ->withIcon(ControlManager::UI_MESS_RES_ICON::QUESTION) + ->display() == IDYES) { if (openDefAppForExpData(receivedCommand, &resStruct) != TRUE) { - displayMessageGeneric(UI_MESS_RES::FAILURE, L"Unable to open exported data"); + GenericMessageOK() + .withMessage(L"Unable to open exported data") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); } } break; } else if(resStruct.result == ACTION::__ERROR) { - displayMessageGeneric(UI_MESS_RES::FAILURE, L"Error while writing to file"); + GenericMessageOK() + .withMessage(L"Error while writing to file") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); } else { //user canceled the save window out diff --git a/SystemInfo/util/controlManager.cpp b/SystemInfo/util/controlManager.cpp new file mode 100644 index 0000000..ba13661 --- /dev/null +++ b/SystemInfo/util/controlManager.cpp @@ -0,0 +1,80 @@ +#include "controlManager.h" +#include "utility.h" + +const wstring ControlManager::UI_messagesTxt[] = { + L"Successfully written to ", + L"Error writing to ", + L"Link successfully copied to clipboard", + L"There's been a problem copying link to clipboard" +}; + +const unordered_map ControlManager::messageCodeCaptionsMap = +{ + {ControlManager::UI_MESS_RES_ICON::SUCCESS, L"Success"}, + {ControlManager::UI_MESS_RES_ICON::QUESTION, L"User action required"}, + {ControlManager::UI_MESS_RES_ICON::WARN, L"Warning"}, + {ControlManager::UI_MESS_RES_ICON::FAILURE, L"Error" } +}; + +const unordered_map > ControlManager::UIMessageExportFileExtByUserExportModeCommandMap = +{ + {ControlManager::UI_MESS_EXPORT_ACTION::WRITE_OUT_HTML, + {L".html", L".html files (*.html)\0*.html\0"}}, + {ControlManager::UI_MESS_EXPORT_ACTION::WRITE_OUT_IMG, + {L".png", L".png images (*.png)\0*.png\0"}}, + {ControlManager::UI_MESS_EXPORT_ACTION::WRITE_OUT_TXT, + {L".txt", L".txt files (*.txt)\0*.txt\0"}}, + {ControlManager::UI_MESS_EXPORT_ACTION::WRITE_OUT_XML, + {L".xml", L".xml files (*.xml)\0*.xml\0"}} +}; + +HWND ControlManager::appCreateControl( + TCHAR *className, + int xOffset, + int yOffSet, + int width, + int height, + std::bitset<32> windowStyles, + HWND parent, + int controlMenuID, + TCHAR* windowName, + DWORD exStyle, + HINSTANCE hInstance, + LPVOID lParam + ) { + HWND createdWindow = CreateWindowEx( + 0, + className, + windowName, + windowStyles.to_ulong(), + xOffset, + yOffSet, + width, + height, + parent, + (HMENU)controlMenuID, + hInstance, + lParam + ); + if (!createdWindow) { + DWORD errCode = GetLastError(); + GenericMessageOK() + .withMessage(getSystemErrorCodeMessageForErrorCode(errCode)) + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); + //to do: implement this https://docs.microsoft.com/en-us/windows/win32/debug/retrieving-the-last-error-code + + } + return createdWindow; +} + +bool ControlManager::searchAndDestroy( + HWND parentWindowHandle, + TCHAR *className, + TCHAR *windowName) { + HWND foundWindowHandle = NULL; + if ((foundWindowHandle = FindWindowEx(NULL, NULL, className, windowName)) != NULL) { + return DestroyWindow(foundWindowHandle); + } + return false; +} \ No newline at end of file diff --git a/SystemInfo/util/controlManager.h b/SystemInfo/util/controlManager.h new file mode 100644 index 0000000..85ec719 --- /dev/null +++ b/SystemInfo/util/controlManager.h @@ -0,0 +1,90 @@ +#pragma once +#include +#include +#include +#include "../glb/globalVars.h" +class ControlManager { + public: + + const static wstring UI_messagesTxt[]; + + enum class UI_MESS_RES_ICON { + SUCCESS = MB_ICONINFORMATION, //info + FAILURE = MB_ICONERROR, //error + WARN = MB_ICONWARNING, + QUESTION = MB_ICONQUESTION + }; + + enum class UI_MESS_EXPORT_ACTION { + WRITE_OUT_TXT = ID_EXPORT_TXT, + WRITE_OUT_XML = ID_EXPORT_XML, + WRITE_OUT_HTML = ID_EXPORT_HTML, + WRITE_OUT_IMG = ID_FILE_TAKESCREENSHOT_SAVE_LOCALLY + }; + + enum class UI_MESS_TYPE { + GENERIC, + EXPORT + }; + + const static unordered_map messageCodeCaptionsMap; + + const static unordered_map > UIMessageExportFileExtByUserExportModeCommandMap; + + static HWND appCreateControl( + TCHAR* className, + int xOffset, + int yOffSet, + int width, + int height, + std::bitset<32> windowStyles, + HWND parent, + int controlMenuID, + TCHAR* windowName = NULL, + DWORD exStyle = 0, + HINSTANCE hInstance = NULL, + LPVOID lParam = NULL); + + static bool searchAndDestroy( + HWND parentWindowHandle, + TCHAR *className, + TCHAR *windowName); +}; + +class AbstractMessage { + protected: + wstring message; + ControlManager::UI_MESS_RES_ICON icon; + public: + virtual UINT display() = 0; + AbstractMessage *withMessage(const wstring message) { + this->message.assign(message); + return this; + } + AbstractMessage* withIcon(ControlManager::UI_MESS_RES_ICON icon) { + this->icon = icon; + return this; + } +}; + +class GenericMessageOK : public AbstractMessage { + public: + UINT display() { + return MessageBox( + mainWindowHwnd, + this->message.c_str(), + ControlManager::messageCodeCaptionsMap.at(this->icon).c_str(), + MB_OK | static_cast(this->icon)); + } +}; + +class PromptMessageYesNo : public AbstractMessage { + public: + UINT display() { + return MessageBox( + NULL, + this->message.c_str(), + ControlManager::messageCodeCaptionsMap.at(this->icon).c_str(), + MB_YESNO | static_cast(this->icon)); + } +}; \ No newline at end of file diff --git a/SystemInfo/util/utility.cpp b/SystemInfo/util/utility.cpp index d8e1536..8dfd6e1 100644 --- a/SystemInfo/util/utility.cpp +++ b/SystemInfo/util/utility.cpp @@ -7,6 +7,7 @@ #include "../util/utility.h" #include "../const/itemIDs.h" #include "../core/SystemInfo.h" +#include "../util/controlManager.h" void positionWindow(POINT *upperLeftCorner) { @@ -465,54 +466,6 @@ void calculateTimeAndFormat(TCHAR *formattedTimeString) { } } -void displayExportMessage(UI_MESS_RES res, UI_MESS_ACTION act) { - MessageBox(NULL, (UI_messagesTxt[static_cast(res)] + - savefileExtensions[static_cast(act)] + L" file").c_str(), - UI_messagesCapt[static_cast(res)].c_str(), - MB_OK - | - !static_cast(res) - ? - MB_ICONINFORMATION - : - MB_ICONERROR); - -} - -void displayMessageGeneric(UI_MESS_RES res, const TCHAR *message) { - MessageBox(NULL, message, - UI_messagesCapt[static_cast(res)].c_str(), - MB_OK - | - !static_cast(res) - ? - MB_ICONINFORMATION - : - MB_ICONERROR); -} - -//gets the appropriate format message -UI_MESS_ACTION getUIMessByCommand(WORD command) { - switch (command) { - case (ID_EXPORT_XML): { - return UI_MESS_ACTION::WRITE_OUT_XML; - break; - } - case (ID_EXPORT_TXT): { - return UI_MESS_ACTION::WRITE_OUT_TXT; - break; - } - case (ID_EXPORT_HTML): { - return UI_MESS_ACTION::WRITE_OUT_HTML; - break; - } - case(ID_FILE_TAKESCREENSHOT_SAVE_LOCALLY): { - return UI_MESS_ACTION::WRITE_OUT_IMG; - break; - } - } -} - int displayPromptForAction(std::wstring promptMessage) { return MessageBox(NULL, promptMessage.c_str(), L"Notification", MB_YESNO); @@ -578,4 +531,25 @@ void condenseSpaces(std::wstring &str) { std::wstring::iterator new_end = std::unique(str.begin(), str.end(), wcharEqualsPredicate); str.erase(new_end, str.end()); +} + +std::wstring getSystemErrorCodeMessageForErrorCode(DWORD errorCode) { + TCHAR *errorCodeString = new TCHAR[256]; + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + errorCode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)& errorCode, + 0, NULL); + return std::wstring(errorCodeString); +} + +std::wstring formMessageForUIExportByExportAction(ControlManager::UI_MESS_RES_ICON res, DWORD act) { + return (ControlManager::UI_messagesTxt[0] + + ControlManager::UIMessageExportFileExtByUserExportModeCommandMap + .at((ControlManager::UI_MESS_EXPORT_ACTION)static_cast(act)) + [0] + L" file"); } \ No newline at end of file diff --git a/SystemInfo/util/utility.h b/SystemInfo/util/utility.h index d6820b3..0f96293 100644 --- a/SystemInfo/util/utility.h +++ b/SystemInfo/util/utility.h @@ -5,17 +5,7 @@ #include #include "../core/SystemInfo.h" #include "../glb/globalVars.h" -enum class UI_MESS_RES { - SUCCESS, - FAILURE -}; - -enum class UI_MESS_ACTION { - WRITE_OUT_TXT, - WRITE_OUT_XML, - WRITE_OUT_HTML, - WRITE_OUT_IMG -}; +#include "../util/controlManager.h" enum class FILE_IO_OPERATION { SAVE_AS, @@ -119,9 +109,6 @@ std::wstring netAdapterStringWrapper(NetAdapter); void getFileNameFromPath(TCHAR *fullPath, TCHAR *fileName); ACTION fileIOCheck(wofstream&); void calculateTimeAndFormat(TCHAR*); -void displayExportMessage(enum class UI_MESS_RES, enum class UI_MESS_ACTION); -void displayMessageGeneric(enum class UI_MESS_RES, const TCHAR*); -UI_MESS_ACTION getUIMessByCommand(WORD); int displayPromptForAction(std::wstring); BOOL openDefAppForExpData(WORD command, RESULT_STRUCT *res); void configAppData(); @@ -129,4 +116,7 @@ bool dirExists(LPCTSTR); std::wstring convertWmiCapacityToGB(std::wstring); void removeTabulation(std::wstring&); void condenseSpaces(std::wstring&); +std::wstring getSystemErrorCodeMessageForErrorCode(DWORD); +std::wstring formMessageForUIExportByExportAction(ControlManager::UI_MESS_RES_ICON res, DWORD act); + #endif \ No newline at end of file From eddb98906e8551c118a6303b5be5e94e937a2244 Mon Sep 17 00:00:00 2001 From: CherryPill Date: Mon, 15 Jun 2020 17:42:28 +0300 Subject: [PATCH 06/10] Add full-size screenshots --- SystemInfo/export/screenCapture.cpp | 132 ++++++++++++++++++++++++---- SystemInfo/export/screenCapture.h | 9 ++ SystemInfo/mainWindowProcedure.cpp | 16 +++- SystemInfo/util/controlManager.cpp | 2 - 4 files changed, 137 insertions(+), 22 deletions(-) diff --git a/SystemInfo/export/screenCapture.cpp b/SystemInfo/export/screenCapture.cpp index 52d4e69..9fa6b8d 100644 --- a/SystemInfo/export/screenCapture.cpp +++ b/SystemInfo/export/screenCapture.cpp @@ -7,21 +7,54 @@ #include "../dialog/scrUploadDialog.h" #include "../network/rest/rest.h" +#pragma comment (lib,"Gdiplus.lib") + + ACTION takeScreenshot(HWND hwnd, SCR_SAVETYPE scrSaveType, RESULT_STRUCT *res) { - RECT winSize; - GetClientRect(hwnd, &winSize); - INT32 areaWidth = winSize.right - winSize.left; - INT32 areaHeight = winSize.bottom - winSize.top; - HDC mainWindowDC = GetDC(hwnd); - HDC screenCapture = CreateCompatibleDC(mainWindowDC); - HBITMAP hCaptureBitmap = CreateCompatibleBitmap(mainWindowDC, - areaWidth, areaHeight); - SelectObject(screenCapture, hCaptureBitmap); - BitBlt(screenCapture, 0, 0, areaWidth, areaHeight, - mainWindowDC, 0, 0, SRCCOPY | CAPTUREBLT); - CImage screen; - screen.Attach(hCaptureBitmap); + //init GDI+ + ULONG_PTR gdiPlusToken; + Gdiplus::GdiplusStartupInput input; + Gdiplus::GdiplusStartup(&gdiPlusToken, &input, nullptr); + CLSID pngEncoderCLSID = { 0x557cf406, 0x1a04, 0x11d3,{ 0x9a,0x73,0x00,0x00,0xf8,0x1e,0xf3,0x2e } }; + + std::vector bitmapList; + + INT32 pixelsToOffset = 10; + VisibleAreaCoordsStruct initialDims = getVisibleClientArea(hwnd); + + INT32 currentVisibleYOffset = initialDims.visibleAreaHeight; + INT32 initialVisibleYOffset = currentVisibleYOffset; + //scroll a few pixels up and get hbitmap, + //put into vector + //merge by calling mergeBitmaps + //scroll back + if (scrollFullPageHeight > currentVisibleYOffset) { + while (scrollFullPageHeight > currentVisibleYOffset) { + ScrollWindow(hwnd, 0, -pixelsToOffset, NULL, NULL); + UpdateWindow(hwnd); + VisibleAreaCoordsStruct a = getVisibleClientArea(hwnd); + Gdiplus::Bitmap* currBitmap = getBitmapFromAreaCoords(hwnd, a); + bitmapList.push_back(currBitmap); + currentVisibleYOffset += pixelsToOffset; + Sleep(200); + } + ScrollWindow(hwnd, 0, currentVisibleYOffset - initialVisibleYOffset, NULL, NULL); + UpdateWindow(hwnd); + } + else { + VisibleAreaCoordsStruct a = getVisibleClientArea(hwnd); + Gdiplus::Bitmap* currBitmap = getBitmapFromAreaCoords(hwnd, a); + bitmapList.push_back(currBitmap); + } + //currentVisibleYOffset = adjusted image size; + Gdiplus::Bitmap* gdiPlusMainImgBitmap = NULL; + if (bitmapList.size() > 1) { + gdiPlusMainImgBitmap = mergeBitmaps(bitmapList, currentVisibleYOffset); + } + else { + gdiPlusMainImgBitmap = bitmapList.at(0); + } TCHAR fullSavePath[256]; @@ -36,13 +69,12 @@ ACTION takeScreenshot(HWND hwnd, SCR_SAVETYPE scrSaveType, RESULT_STRUCT *res) { return ACTION::CANCELED_OUT; } } - - if (!SUCCEEDED(screen.Save(fullSavePath))) { + if (!gdiPlusMainImgBitmap->Save(fullSavePath, &pngEncoderCLSID, NULL) == Gdiplus::Status::Ok) { return ACTION::__ERROR; } - DeleteObject(hCaptureBitmap); - ReleaseDC(hwnd, mainWindowDC); - DeleteDC(screenCapture); + + //shutdown GDI+ + Gdiplus::GdiplusShutdown(gdiPlusToken); if (scrSaveType == SCR_SAVETYPE::LOCAL) { res->src.assign(fullSavePath); } @@ -58,4 +90,66 @@ ACTION takeScreenshot(HWND hwnd, SCR_SAVETYPE scrSaveType, RESULT_STRUCT *res) { DeleteFile(fullSavePath); } return ACTION::ACCEPTED; -} \ No newline at end of file +} + +VisibleAreaCoordsStruct getVisibleClientArea(HWND hwnd) { + RECT winSize; + GetClientRect(hwnd, &winSize); + + //visible client area + INT32 areaWidth = winSize.right - winSize.left; + INT32 areaHeight = winSize.bottom - winSize.top; + return { areaWidth, areaHeight }; +} + +Gdiplus::Bitmap* getBitmapFromAreaCoords(HWND hwnd, VisibleAreaCoordsStruct &coords) { + HDC mainWindowDC = GetDC(hwnd); + HDC screenCapture = CreateCompatibleDC(mainWindowDC); + HBITMAP hCaptureBitmap = CreateCompatibleBitmap(mainWindowDC, + coords.visibleAreaWidth, coords.visibleAreaHeight); + SelectObject(screenCapture, hCaptureBitmap); + BitBlt(screenCapture, + 0, + 0, + coords.visibleAreaWidth, + coords.visibleAreaHeight, + mainWindowDC, + 0, + 0, + SRCCOPY | CAPTUREBLT); + + Gdiplus::Bitmap *gdiPlusMainImgBitmap = Gdiplus::Bitmap::FromHBITMAP(hCaptureBitmap, NULL); + DeleteObject(hCaptureBitmap); + ReleaseDC(hwnd, mainWindowDC); + DeleteDC(screenCapture); + return gdiPlusMainImgBitmap; +} + +Gdiplus::Bitmap *mergeBitmaps( + std::vector bitmapsToMerge, + INT32 adjustedImageSizeByYOffset) { + + bitmapsToMerge.at(0)->GetWidth(); + Gdiplus::Bitmap *completeBitmap = + new Gdiplus::Bitmap( + bitmapsToMerge.at(0)->GetWidth(), + adjustedImageSizeByYOffset); + Gdiplus::Graphics *g = Gdiplus::Graphics::FromImage(completeBitmap); + //iterate over the vector and draw images one by one + INT32 offsetForLength = 10; + for (auto bitmapIterator = bitmapsToMerge.begin(); + bitmapIterator != bitmapsToMerge.end(); + bitmapIterator++) { + if (bitmapIterator == bitmapsToMerge.begin()) { + g->DrawImage((*bitmapIterator), 0, 0); + } + else { + g->DrawImage((*bitmapIterator), 0, offsetForLength); + offsetForLength += 10; + } + } + return completeBitmap; +} + + + diff --git a/SystemInfo/export/screenCapture.h b/SystemInfo/export/screenCapture.h index 25dce51..c145865 100644 --- a/SystemInfo/export/screenCapture.h +++ b/SystemInfo/export/screenCapture.h @@ -1,6 +1,15 @@ #ifndef SCREENCAPTURE_H #define SCREENCAPTURE_H #include +#include #include "../util/utility.h" +typedef struct VisibleAreaCoordsStruct { + INT32 visibleAreaWidth; + INT32 visibleAreaHeight; +}; ACTION takeScreenshot(HWND, SCR_SAVETYPE, RESULT_STRUCT*); +Gdiplus::Bitmap* getBitmapFromAreaCoords(HWND hwnd, VisibleAreaCoordsStruct&); +VisibleAreaCoordsStruct getVisibleClientArea(HWND hwnd); +Gdiplus::Bitmap* mergeBitmaps( std::vector, INT32); + #endif // !SCREENCAPTURE_H diff --git a/SystemInfo/mainWindowProcedure.cpp b/SystemInfo/mainWindowProcedure.cpp index 1def32b..4b10c2b 100644 --- a/SystemInfo/mainWindowProcedure.cpp +++ b/SystemInfo/mainWindowProcedure.cpp @@ -41,6 +41,7 @@ LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } fillGUI(hwnd, localMachine, 0); toggleIpAddress(hwnd, NULL); + return 0; } @@ -110,7 +111,20 @@ LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break; } case ID_FILE_EXIT: { - PostQuitMessage(WM_QUIT); + for (int x = 0; x < 10; x++) { + if (scrollFullPageHeight) { + } + ScrollWindow(hwnd, 0, -10, NULL, NULL); + UpdateWindow(hwnd); + Sleep(1000); + } + for (int x = 0; x < 10; x++) { + ScrollWindow(hwnd, 0, 10, NULL, NULL); + UpdateWindow(hwnd); + Sleep(1000); + } + + //PostQuitMessage(WM_QUIT); break; } case AUX_IP_TOGGLE: { diff --git a/SystemInfo/util/controlManager.cpp b/SystemInfo/util/controlManager.cpp index ba13661..317e5ea 100644 --- a/SystemInfo/util/controlManager.cpp +++ b/SystemInfo/util/controlManager.cpp @@ -62,8 +62,6 @@ HWND ControlManager::appCreateControl( .withMessage(getSystemErrorCodeMessageForErrorCode(errCode)) ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) ->display(); - //to do: implement this https://docs.microsoft.com/en-us/windows/win32/debug/retrieving-the-last-error-code - } return createdWindow; } From d31010dfff184ecfcb21ac49369eec16939b1749 Mon Sep 17 00:00:00 2001 From: CherryPill Date: Tue, 16 Jun 2020 17:09:45 +0300 Subject: [PATCH 07/10] Fix month string not being prepended with 0 Add getting CLSID from the system, fall back for hardcoded value if not available Refactor messagebox usage throughout the project --- SystemInfo/core/SystemInfo.cpp | 1 + SystemInfo/core/SystemInfo.h | 1 + SystemInfo/core/sysinfo.cpp | 10 ++++-- SystemInfo/export/saveSpecs.cpp | 5 ++- SystemInfo/export/screenCapture.cpp | 17 +++++++--- SystemInfo/glb/globalVars.cpp | 1 + SystemInfo/glb/globalVars.h | 7 ++++ SystemInfo/main.cpp | 5 ++- SystemInfo/mainWindowProcedure.cpp | 15 +-------- SystemInfo/network/rest/rest.cpp | 37 ++++++++++++++------- SystemInfo/util/utility.cpp | 50 ++++++++++++++++++++++------- SystemInfo/util/utility.h | 33 +++++++++++++++++-- 12 files changed, 134 insertions(+), 48 deletions(-) diff --git a/SystemInfo/core/SystemInfo.cpp b/SystemInfo/core/SystemInfo.cpp index 8ee353a..ade549a 100644 --- a/SystemInfo/core/SystemInfo.cpp +++ b/SystemInfo/core/SystemInfo.cpp @@ -1,4 +1,5 @@ #include "SystemInfo.h" +#pragma comment (lib,"Gdiplus.lib") wstring SystemInfo::getCPU() { return (*this).CPU; } diff --git a/SystemInfo/core/SystemInfo.h b/SystemInfo/core/SystemInfo.h index 7400eec..677fb75 100644 --- a/SystemInfo/core/SystemInfo.h +++ b/SystemInfo/core/SystemInfo.h @@ -1,5 +1,6 @@ #pragma once #include +#include #include #include #include diff --git a/SystemInfo/core/sysinfo.cpp b/SystemInfo/core/sysinfo.cpp index a7b33ea..4c7d760 100644 --- a/SystemInfo/core/sysinfo.cpp +++ b/SystemInfo/core/sysinfo.cpp @@ -510,11 +510,17 @@ void fillBIOS(SystemInfo * localMachine) { DumpSMBIOSStruct(&(pDMIData->SMBIOSTableData), pDMIData->Length, biosData); } else { - MessageBox(NULL, _T("Failed to fetch firmware tables"), _T("Fatal Error"), MB_OK); + GenericMessageOK() + .withMessage(L"Fatal Error. Failed to fetch firmware tables") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); } } else { - MessageBox(NULL, _T("Memory allocation failed"), _T("Fatal Error"), MB_OK); + GenericMessageOK() + .withMessage(L"Fatal Error. Memory allocation failed") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); } _tcscat(biosData, (wchar_t*)getComputerType().c_str()); localMachine->setBIOS(biosData); diff --git a/SystemInfo/export/saveSpecs.cpp b/SystemInfo/export/saveSpecs.cpp index 20e6c88..36fab51 100644 --- a/SystemInfo/export/saveSpecs.cpp +++ b/SystemInfo/export/saveSpecs.cpp @@ -154,7 +154,10 @@ void importAsXML(HWND hwnd) { NULL, // Use parent's starting directory &si, // Pointer to STARTUPINFO structure &pi)) { - MessageBox(NULL, L"Unable to create process", L"Something happened", MB_OK | MB_ICONERROR); + GenericMessageOK() + .withMessage(L"Unable to create process") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); } } } diff --git a/SystemInfo/export/screenCapture.cpp b/SystemInfo/export/screenCapture.cpp index 9fa6b8d..d40d405 100644 --- a/SystemInfo/export/screenCapture.cpp +++ b/SystemInfo/export/screenCapture.cpp @@ -7,8 +7,6 @@ #include "../dialog/scrUploadDialog.h" #include "../network/rest/rest.h" -#pragma comment (lib,"Gdiplus.lib") - ACTION takeScreenshot(HWND hwnd, SCR_SAVETYPE scrSaveType, RESULT_STRUCT *res) { @@ -16,8 +14,15 @@ ACTION takeScreenshot(HWND hwnd, SCR_SAVETYPE scrSaveType, RESULT_STRUCT *res) { ULONG_PTR gdiPlusToken; Gdiplus::GdiplusStartupInput input; Gdiplus::GdiplusStartup(&gdiPlusToken, &input, nullptr); - CLSID pngEncoderCLSID = { 0x557cf406, 0x1a04, 0x11d3,{ 0x9a,0x73,0x00,0x00,0xf8,0x1e,0xf3,0x2e } }; + CLSID pngEncoderCLSID; + + if (!GetEncoderClsid( + encoderImgTypesToStringMap.at(ENCODER_IMG_TYPES::IMG_PNG).c_str(), + &pngEncoderCLSID)) { + pngEncoderCLSID = glbPngFallbackHardCodedEncoderClsID; + } + std::vector bitmapList; INT32 pixelsToOffset = 10; @@ -81,7 +86,10 @@ ACTION takeScreenshot(HWND hwnd, SCR_SAVETYPE scrSaveType, RESULT_STRUCT *res) { if (scrSaveType == SCR_SAVETYPE::INTERNET) { RESULT_STRUCT resStruct = {}; if (!uploadImage(&resStruct, fullSavePath)) { - MessageBox(NULL, _T("Failed to upload"), NULL, MB_ICONERROR | MB_OK); + GenericMessageOK() + .withMessage(L"Failed to upload") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); return ACTION::__ERROR; } else { @@ -128,7 +136,6 @@ Gdiplus::Bitmap* getBitmapFromAreaCoords(HWND hwnd, VisibleAreaCoordsStruct &coo Gdiplus::Bitmap *mergeBitmaps( std::vector bitmapsToMerge, INT32 adjustedImageSizeByYOffset) { - bitmapsToMerge.at(0)->GetWidth(); Gdiplus::Bitmap *completeBitmap = new Gdiplus::Bitmap( diff --git a/SystemInfo/glb/globalVars.cpp b/SystemInfo/glb/globalVars.cpp index 4510249..9bfdc3c 100644 --- a/SystemInfo/glb/globalVars.cpp +++ b/SystemInfo/glb/globalVars.cpp @@ -55,3 +55,4 @@ int currentCpuUsageGlobal = -1; int glbCpuInfoHolderXoffset = 0; int glbCpuInfoHolderYoffset = 0; + diff --git a/SystemInfo/glb/globalVars.h b/SystemInfo/glb/globalVars.h index 5f56b1c..b4a69c5 100644 --- a/SystemInfo/glb/globalVars.h +++ b/SystemInfo/glb/globalVars.h @@ -35,6 +35,13 @@ const static int cpuProgressStringWindowHeightSmall = 15; const static int cpuProgressStringWindowWidthLarge = 40; const static int cpuProgressStringWindowHeightLarge = 15; +//use this hardcoded value for png cls id if os failed to provide its own values for the png clsid +const static CLSID glbPngFallbackHardCodedEncoderClsID = { + 0x557cf406, + 0x1a04, + 0x11d3, + {0x9a, 0x73, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} }; + static WORD ICON_IDS[totalItemsCount]{ BIOS_ICON, OS_ICON, diff --git a/SystemInfo/main.cpp b/SystemInfo/main.cpp index b70984d..da3831f 100644 --- a/SystemInfo/main.cpp +++ b/SystemInfo/main.cpp @@ -39,7 +39,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wc.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(MAIN_APP_ICON), IMAGE_ICON, 0, 0, NULL); wc.hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(MAIN_APP_ICON), IMAGE_ICON, 32, 32, NULL); if (!RegisterClassEx(&wc)) { - MessageBox(NULL, L"Window class registration failed", L"Error", MB_ICONERROR); + GenericMessageOK() + .withMessage(L"Window class registration failed") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); return FALSE; } ghInstance = hInstance; diff --git a/SystemInfo/mainWindowProcedure.cpp b/SystemInfo/mainWindowProcedure.cpp index 4b10c2b..8cba6fb 100644 --- a/SystemInfo/mainWindowProcedure.cpp +++ b/SystemInfo/mainWindowProcedure.cpp @@ -111,20 +111,7 @@ LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break; } case ID_FILE_EXIT: { - for (int x = 0; x < 10; x++) { - if (scrollFullPageHeight) { - } - ScrollWindow(hwnd, 0, -10, NULL, NULL); - UpdateWindow(hwnd); - Sleep(1000); - } - for (int x = 0; x < 10; x++) { - ScrollWindow(hwnd, 0, 10, NULL, NULL); - UpdateWindow(hwnd); - Sleep(1000); - } - - //PostQuitMessage(WM_QUIT); + PostQuitMessage(WM_QUIT); break; } case AUX_IP_TOGGLE: { diff --git a/SystemInfo/network/rest/rest.cpp b/SystemInfo/network/rest/rest.cpp index cae0a2c..26df252 100644 --- a/SystemInfo/network/rest/rest.cpp +++ b/SystemInfo/network/rest/rest.cpp @@ -46,7 +46,10 @@ bool uploadImage(RESULT_STRUCT *res, TCHAR *fileName) { std::ifstream png; png.open(fileName, std::ios::binary); if (png.fail()) { - MessageBox(NULL, _T("Could not open PNG file"), NULL, MB_ICONERROR | MB_OK); + GenericMessageOK() + .withMessage(L"Could not open PNG file") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); png.close(); return FALSE; } @@ -64,8 +67,10 @@ bool uploadImage(RESULT_STRUCT *res, TCHAR *fileName) { HINTERNET hSession = InternetOpen(szTitle, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if (NULL == hSession) { - MessageBox(NULL, _T("Cannot configure wininet"), - szTitle, MB_ICONERROR | MB_OK); + GenericMessageOK() + .withMessage(L"Cannot configure wininet") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); return FALSE; } @@ -73,8 +78,10 @@ bool uploadImage(RESULT_STRUCT *res, TCHAR *fileName) { UPLOAD_SERVER, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, NULL); if (NULL == hSession) { - MessageBox(NULL, _T("Cannot initiate connection"), - szTitle, MB_ICONERROR | MB_OK); + GenericMessageOK() + .withMessage(L"Cannot initiate connection") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); return FALSE; } @@ -82,8 +89,10 @@ bool uploadImage(RESULT_STRUCT *res, TCHAR *fileName) { _T("POST"), UPLOAD_PATH, NULL, NULL, NULL, INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD, NULL); if (NULL == hSession) { - MessageBox(NULL, _T("Cannot compose post request"), - szTitle, MB_ICONERROR | MB_OK); + GenericMessageOK() + .withMessage(L"Cannot compose post request") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); return FALSE; } @@ -93,8 +102,11 @@ bool uploadImage(RESULT_STRUCT *res, TCHAR *fileName) { hRequest, ua, _tcslen(ua), HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE); if (FALSE == bResult) { - MessageBox(NULL, _T("Cannot set user agent"), - szTitle, MB_ICONERROR | MB_OK); + GenericMessageOK() + .withMessage(L"Cannot set user agent") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); + return FALSE; } @@ -110,9 +122,12 @@ bool uploadImage(RESULT_STRUCT *res, TCHAR *fileName) { HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE, resCode, &resLen, 0); int ress = _tcscmp(resCode, L"200\0"); if (ress) { + // upload (status error) - MessageBox(NULL, _T("Failed to upload (unexpected result code, under maintainance?)"), - szTitle, MB_ICONERROR | MB_OK); + GenericMessageOK() + .withMessage(L"Failed to upload (unexpected result code, under maintainance?)") + ->withIcon(ControlManager::UI_MESS_RES_ICON::FAILURE) + ->display(); } else { DWORD idLen = 100; TCHAR newid[100]; diff --git a/SystemInfo/util/utility.cpp b/SystemInfo/util/utility.cpp index 8dfd6e1..f7a3fec 100644 --- a/SystemInfo/util/utility.cpp +++ b/SystemInfo/util/utility.cpp @@ -6,7 +6,6 @@ #include "../glb/globalVars.h" #include "../util/utility.h" #include "../const/itemIDs.h" -#include "../core/SystemInfo.h" #include "../util/controlManager.h" void positionWindow(POINT *upperLeftCorner) { @@ -128,19 +127,22 @@ void getCurrentDateTime(TCHAR *buffer) { TCHAR finalTimeString[256]; TCHAR strMinBuff[16]; TCHAR strSecBuff[16]; + TCHAR strMonBuff[16]; - prependMinuteStr(currentTime.wMinute, strMinBuff); - prependMinuteStr(currentTime.wSecond, strSecBuff); - _stprintf(buffer, _T("%d-%d-%d_@_%d.%s.%s"), + prependZeroToStr(currentTime.wMinute, strMinBuff); + prependZeroToStr(currentTime.wSecond, strSecBuff); + prependZeroToStr(currentTime.wMonth, strMonBuff); + + _stprintf(buffer, _T("%d-%s-%d_@_%d.%s.%s"), currentTime.wYear, - currentTime.wMonth, + strMonBuff, currentTime.wDay, currentTime.wHour, strMinBuff, strSecBuff); } -void prependMinuteStr(WORD val, TCHAR *valBuff) { +void prependZeroToStr(WORD val, TCHAR *valBuff) { if (val < 10) { _itow(val, valBuff, 10); wstring temp = wstring(valBuff); @@ -157,7 +159,7 @@ void getCurrentDateTimeVerbose(TCHAR *buffer) { WORD min; TCHAR minBuff[16]; GetLocalTime(¤tTime); - prependMinuteStr(currentTime.wMinute, minBuff); + prependZeroToStr(currentTime.wMinute, minBuff); _stprintf(buffer, _T("%s, %s %d, %d @ %d:%s"), timeVerboseDaysOfWeek[currentTime.wDayOfWeek], timeVerboseMonths[currentTime.wMonth], @@ -466,10 +468,6 @@ void calculateTimeAndFormat(TCHAR *formattedTimeString) { } } -int displayPromptForAction(std::wstring promptMessage) { - return MessageBox(NULL, promptMessage.c_str(), - L"Notification", MB_YESNO); -} //opens external application to view exported data, opens 'open with' dialog BOOL openDefAppForExpData(WORD command, RESULT_STRUCT *res) { @@ -552,4 +550,34 @@ std::wstring formMessageForUIExportByExportAction(ControlManager::UI_MESS_RES_IC ControlManager::UIMessageExportFileExtByUserExportModeCommandMap .at((ControlManager::UI_MESS_EXPORT_ACTION)static_cast(act)) [0] + L" file"); +} + +int GetEncoderClsid(const TCHAR *format, CLSID *pClsid) { + UINT num = 0; // number of image encoders + UINT size = 0; // size of the image encoder array in bytes + + Gdiplus::ImageCodecInfo* pImageCodecInfo = NULL; + + Gdiplus::GetImageEncodersSize(&num, &size); + if (size == 0) + return -1; // Failure + + pImageCodecInfo = (Gdiplus::ImageCodecInfo*)(malloc(size)); + if (pImageCodecInfo == NULL) + return -1; // Failure + + GetImageEncoders(num, size, pImageCodecInfo); + + for (UINT j = 0; j < num; ++j) + { + if (wcscmp(pImageCodecInfo[j].MimeType, format) == 0) + { + *pClsid = pImageCodecInfo[j].Clsid; + free(pImageCodecInfo); + return j; // Success + } + } + + free(pImageCodecInfo); + return -1; // Failure } \ No newline at end of file diff --git a/SystemInfo/util/utility.h b/SystemInfo/util/utility.h index 0f96293..4cf42b6 100644 --- a/SystemInfo/util/utility.h +++ b/SystemInfo/util/utility.h @@ -1,5 +1,6 @@ #ifndef UTILITY_H #define UTILITY_H + #include #include #include @@ -75,6 +76,33 @@ static std::wstring storageMediumManufacturers[20]{ L"IMB" }; +enum class ENCODER_IMG_TYPES { + IMG_PNG = 0, + IMG_BMP, + IMG_JPG, + IMG_GIF, + IMG_TIFF +}; + +const +static +unordered_map + encoderImgTypesToStringMap = { + {ENCODER_IMG_TYPES::IMG_PNG, L"image/png"}, + {ENCODER_IMG_TYPES::IMG_BMP, L"image/bmp"}, + {ENCODER_IMG_TYPES::IMG_JPG, L"image/jpeg"}, + {ENCODER_IMG_TYPES::IMG_GIF, L"image/gif"}, + {ENCODER_IMG_TYPES::IMG_TIFF, L"image/tiff"} + }; + +static std::wstring imageEncodersForGdiPlus[]{ + L"image / bmp", + L"image / jpeg", + L"image / gif", + L"image / tiff", + L"image / png" +}; + typedef struct RESULT_STRUCT { ACTION result; std::wstring src; @@ -103,13 +131,12 @@ void writeToFile(wofstream&, SystemInfo*, int, WRITE_OUT_TYPE); wstring fromChToWideStr(char *value); wstring fromIntToWideStr(int); std::wstring convertStringToWide(const std::string& as); -void prependMinuteStr(WORD min, TCHAR *minBuff); +void prependZeroToStr(WORD min, TCHAR *minBuff); vector stringSplit(const wchar_t *s, wchar_t delimiter); std::wstring netAdapterStringWrapper(NetAdapter); void getFileNameFromPath(TCHAR *fullPath, TCHAR *fileName); ACTION fileIOCheck(wofstream&); void calculateTimeAndFormat(TCHAR*); -int displayPromptForAction(std::wstring); BOOL openDefAppForExpData(WORD command, RESULT_STRUCT *res); void configAppData(); bool dirExists(LPCTSTR); @@ -118,5 +145,5 @@ void removeTabulation(std::wstring&); void condenseSpaces(std::wstring&); std::wstring getSystemErrorCodeMessageForErrorCode(DWORD); std::wstring formMessageForUIExportByExportAction(ControlManager::UI_MESS_RES_ICON res, DWORD act); - +int GetEncoderClsid(const TCHAR *format, CLSID *pClsid); #endif \ No newline at end of file From d7fad4239313691c1909a3c07da20ab58a2c38ee Mon Sep 17 00:00:00 2001 From: CherryPill Date: Tue, 16 Jun 2020 17:12:51 +0300 Subject: [PATCH 08/10] Fix type --- SystemInfo/export/screenCapture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SystemInfo/export/screenCapture.cpp b/SystemInfo/export/screenCapture.cpp index d40d405..9533bf6 100644 --- a/SystemInfo/export/screenCapture.cpp +++ b/SystemInfo/export/screenCapture.cpp @@ -17,9 +17,9 @@ ACTION takeScreenshot(HWND hwnd, SCR_SAVETYPE scrSaveType, RESULT_STRUCT *res) { CLSID pngEncoderCLSID; - if (!GetEncoderClsid( + if (GetEncoderClsid( encoderImgTypesToStringMap.at(ENCODER_IMG_TYPES::IMG_PNG).c_str(), - &pngEncoderCLSID)) { + &pngEncoderCLSID) == -1) { pngEncoderCLSID = glbPngFallbackHardCodedEncoderClsID; } From 083e319505861e250583de65023de4f9f90e07ba Mon Sep 17 00:00:00 2001 From: CherryPill Date: Tue, 16 Jun 2020 23:44:24 +0300 Subject: [PATCH 09/10] Refactoring --- SystemInfo/mainWindowProcedure.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/SystemInfo/mainWindowProcedure.cpp b/SystemInfo/mainWindowProcedure.cpp index 8cba6fb..8961288 100644 --- a/SystemInfo/mainWindowProcedure.cpp +++ b/SystemInfo/mainWindowProcedure.cpp @@ -57,14 +57,13 @@ LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case ID_EXPORT_XML: case ID_EXPORT_TXT: case ID_EXPORT_HTML: { - TCHAR *dateTime = new TCHAR[256]; + std::unique_ptr pDateTime(new TCHAR[256]); //export xml - getCurrentDateTimeVerbose(dateTime); - wstring dateTimeConv(dateTime); + getCurrentDateTimeVerbose(pDateTime.get()); + wstring dateTimeConv(pDateTime.get()); localMachine-> getCurrentInstance()-> setSnapshotGenDateTime(dateTimeConv); - delete dateTime; RESULT_STRUCT resStruct = {}; saveSpecs::save(receivedCommand, &resStruct, hwnd, localMachine->getCurrentInstance()); From f9fcb4fb223a401e224679ce1983c976006e5be9 Mon Sep 17 00:00:00 2001 From: CherryPill Date: Mon, 22 Jun 2020 10:31:06 +0300 Subject: [PATCH 10/10] Gyazo upload window minor fixes --- SystemInfo/SystemInfo.aps | Bin 2053372 -> 2055764 bytes SystemInfo/SystemInfo.rc | Bin 13606 -> 13630 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/SystemInfo/SystemInfo.aps b/SystemInfo/SystemInfo.aps index 2b49a357c182c7d3b8abd7464fe4760677ea8a11..18da8d94f91ad8f54436e8e2aef518b2116e9c58 100644 GIT binary patch delta 4697 zcmZ`*eQZ@Bf!2=gIB(c~uKkjRkJX@#t`!IAKaid=US#~GG?REP#M=2ug*mF*Lu|rkb=C2;y)3{l zlIo{@%vERK=LA>)z^^H+qk44(+vi-+ZV@UNg2!M00H&svp#~u2o>@o#>EnBP*{eLz z#}14E6s@%rmfo9yCh;kmQAH}Ga>MBigaM3VWV#py2*(hUPfCSKvRJH0DY+n2p%};R;%;)odgR6aKZ6V7={%oC#_8? zl3WnhN*MU>le#@>wnu><8DN1iF+Xm$#{nxDj)RmgRq~m_a2Vn!_oAGxq@`p|&I(N= zYS2{5snT#UCnwX8&XlEWK`IQ&kR8U-<)lKU3=oa<_4XS5ED(+~_5X9mEm_t!cBa0T zD-W8ulEG}`)kp!f)UW_hXMs8xDOW}^rLrg#rH5EDbl}WXvXIK;AVRaHbaFs0DG*hK zQYNL8)?iJ937009GFTBIt-+P`sy_=d^r^p6Ik}vHepMLCn#Z_JXeNKjYRh8Yq%TT|nb4=rAXt}DLS;J2xtOzs<#-@`rjC+bQaMlnt zjGK$}E|siWZeiSGq-~haS7eb;&&Imxd?EG-r5Ba=NfRDH774x2NN}XPP&Q5{c^FwQ z^lpO_1JA<98DaPHZ^l`$8EdQeF#=KC7{GrOW&sQEWQ4UW3E^hZ0yUXA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