3030#include < windows.h>
3131#include < WbemIdl.h>
3232#include < comdef.h>
33- #include < comutil.h> // For _bstr_t
3433#include < string>
3534#pragma comment(lib, "wbemuuid.lib")
3635#endif
@@ -114,38 +113,38 @@ void printSystemInfo()
114113 IWbemClassObject* obj = nullptr ;
115114
116115 // CPU info
117- const std::wstring cpu_query (_bstr_t ( L" SELECT Name, NumberOfLogicalProcessors, MaxClockSpeed FROM Win32_Processor" ) );
118- service->ExecQuery (_bstr_t (L" WQL" ), _bstr_t (std::wstring (cpu_query.begin (), cpu_query.end ()).c_str ()), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, nullptr , &enumerator);
116+ const std::wstring cpu_query (L" SELECT Name, NumberOfLogicalProcessors, MaxClockSpeed FROM Win32_Processor" );
117+ service->ExecQuery (bstr_t (L" WQL" ), bstr_t (std::wstring (cpu_query.begin (), cpu_query.end ()).c_str ()), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, nullptr , &enumerator);
119118 while (enumerator)
120119 {
121120 enumerator->Next (WBEM_INFINITE, 1 , &obj, &u_return);
122121 if (!u_return)
123122 break ;
124123
125- hr = obj->Get (_bstr_t ( L" Name" ) , 0 , &vt_prop, nullptr , nullptr );
126- log (QString (" CPU name: %1" ).arg (vt_prop.bstrVal ));
124+ hr = obj->Get (L" Name" , 0 , &vt_prop, nullptr , nullptr );
125+ log (QString (" CPU name: %1" ).arg (vt_prop.bstrVal ));
127126
128- hr = obj->Get (_bstr_t ( L" MaxClockSpeed" ) , 0 , &vt_prop, nullptr , nullptr );
129- log (QString (" CPU maximum speed: %1 MHz" ).arg (vt_prop.uintVal ));
127+ hr = obj->Get (L" MaxClockSpeed" , 0 , &vt_prop, nullptr , nullptr );
128+ log (QString (" CPU maximum speed: %1 MHz" ).arg (vt_prop.uintVal ));
130129
131- hr = obj->Get (_bstr_t ( L" NumberOfLogicalProcessors" ) , 0 , &vt_prop, nullptr , nullptr );
132- log (QString (" CPU logical cores: %1" ).arg (vt_prop.intVal ));
130+ hr = obj->Get (L" NumberOfLogicalProcessors" , 0 , &vt_prop, nullptr , nullptr );
131+ log (QString (" CPU logical cores: %1" ).arg (vt_prop.intVal ));
133132
134133 VariantClear (&vt_prop);
135134 obj->Release ();
136135 }
137136
138137 // RAM info
139138 int64_t totalRAM = 0 ;
140- const std::wstring ram_query (_bstr_t ( L" SELECT Capacity FROM Win32_PhysicalMemory" ) );
141- service->ExecQuery (_bstr_t (L" WQL" ), _bstr_t (std::wstring (ram_query.begin (), ram_query.end ()).c_str ()), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, nullptr , &enumerator);
139+ const std::wstring ram_query (L" SELECT Capacity FROM Win32_PhysicalMemory" );
140+ service->ExecQuery (bstr_t (L" WQL" ), bstr_t (std::wstring (ram_query.begin (), ram_query.end ()).c_str ()), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, nullptr , &enumerator);
142141 while (enumerator)
143142 {
144143 enumerator->Next (WBEM_INFINITE, 1 , &obj, &u_return);
145144 if (!u_return)
146145 break ;
147146
148- hr = obj->Get (_bstr_t ( L" Capacity" ) , 0 , &vt_prop, nullptr , nullptr );
147+ hr = obj->Get (L" Capacity" , 0 , &vt_prop, nullptr , nullptr );
149148 totalRAM += std::stoll (vt_prop.bstrVal );
150149
151150 VariantClear (&vt_prop);
@@ -154,23 +153,23 @@ void printSystemInfo()
154153 log (QString (" Total physical memory: %1 MB" ).arg (totalRAM/(1024 <<10 )));
155154
156155 // GPU info (Enabled only)
157- const std::wstring gpu_query (_bstr_t ( L" SELECT Name, AdapterRAM, CurrentHorizontalResolution, CurrentVerticalResolution FROM Win32_VideoController WHERE Status='OK'" ) );
158- service->ExecQuery (_bstr_t (L" WQL" ), _bstr_t (std::wstring (gpu_query.begin (), gpu_query.end ()).c_str ()), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, nullptr , &enumerator);
156+ const std::wstring gpu_query (L" SELECT Name, AdapterRAM, CurrentHorizontalResolution, CurrentVerticalResolution FROM Win32_VideoController WHERE Status='OK'" );
157+ service->ExecQuery (bstr_t (L" WQL" ), bstr_t (std::wstring (gpu_query.begin (), gpu_query.end ()).c_str ()), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, nullptr , &enumerator);
159158 while (enumerator)
160159 {
161160 enumerator->Next (WBEM_INFINITE, 1 , &obj, &u_return);
162161 if (!u_return)
163162 break ;
164163
165- hr = obj->Get (_bstr_t ( L" Name" ) , 0 , &vt_prop, nullptr , nullptr );
166- log (QString (" GPU name: %1" ).arg (vt_prop.bstrVal ));
164+ hr = obj->Get (L" Name" , 0 , &vt_prop, nullptr , nullptr );
165+ log (QString (" GPU name: %1" ).arg (vt_prop.bstrVal ));
167166
168- hr = obj->Get (_bstr_t ( L" AdapterRAM" ) , 0 , &vt_prop, nullptr , nullptr );
169- log (QString (" GPU RAM: %1 MB" ).arg (vt_prop.ullVal /(1024 <<10 )));
167+ hr = obj->Get (L" AdapterRAM" , 0 , &vt_prop, nullptr , nullptr );
168+ log (QString (" GPU RAM: %1 MB" ).arg (vt_prop.ullVal /(1024 <<10 )));
170169
171- hr = obj->Get (_bstr_t ( L" CurrentHorizontalResolution" ) , 0 , &vt_prop, nullptr , nullptr );
170+ hr = obj->Get (L" CurrentHorizontalResolution" , 0 , &vt_prop, nullptr , nullptr );
172171 int currHRes = vt_prop.intVal ;
173- hr = obj->Get (_bstr_t ( L" CurrentVerticalResolution" ) , 0 , &vt_prop, nullptr , nullptr );
172+ hr = obj->Get (L" CurrentVerticalResolution" , 0 , &vt_prop, nullptr , nullptr );
174173 int currVRes = vt_prop.intVal ;
175174 log (QString (" Current resolution: %1x%2" ).arg (currHRes).arg (currVRes));
176175
0 commit comments