3
3
#include < string>
4
4
#include < sstream>
5
5
#include < vector>
6
- #include < regex>
7
6
8
7
#include < unicode/unistr.h>
9
8
10
9
#define _WIN32_DCOM
10
+ #define _WIN32_WINNT 0x0600
11
11
#include < iostream>
12
12
#include < windows.h>
13
13
#include < wbemidl.h>
14
14
#include < comdef.h>
15
+ #include < winuser.h>
15
16
16
17
std::string exc_value (" invalid" );
17
18
@@ -262,18 +263,6 @@ std::string wmi_value(std::wstring const& table,
262
263
return exc_value;
263
264
}
264
265
265
- std::string match_regex (std::string const & input,
266
- char const * r_string)
267
- {
268
- std::regex r (r_string);
269
- std::smatch sm;
270
- if (std::regex_search (input, sm, r))
271
- {
272
- return sm[1 ];
273
- }
274
- return exc_value;
275
- }
276
-
277
266
std::string machine_info_uuid ()
278
267
{
279
268
return wmi_value (L" Win32_ComputerSystemProduct" ,
@@ -294,24 +283,14 @@ std::string machine_info_manufacturer()
294
283
295
284
std::string machine_info_display_width ()
296
285
{
297
- std::string v_mode_desc = wmi_value (L" Win32_VideoController" ,
298
- L" VideoModeDescription" );
299
- if (v_mode_desc == exc_value)
300
- {
301
- return exc_value;
302
- }
303
- return match_regex (v_mode_desc, " (\\ d+) x \\ d+ x \\ d+ colors" );
286
+ SetProcessDPIAware ();
287
+ return std::to_string (GetSystemMetrics (SM_CXSCREEN));
304
288
}
305
289
306
290
std::string machine_info_display_height ()
307
291
{
308
- std::string v_mode_desc = wmi_value (L" Win32_VideoController" ,
309
- L" VideoModeDescription" );
310
- if (v_mode_desc == exc_value)
311
- {
312
- return exc_value;
313
- }
314
- return match_regex (v_mode_desc, " \\ d+ x (\\ d+) x \\ d+ colors" );
292
+ SetProcessDPIAware ();
293
+ return std::to_string (GetSystemMetrics (SM_CYSCREEN));
315
294
}
316
295
317
296
std::string machine_info_memory_serial0 ()
0 commit comments