|
1 | | -extern "C" { |
2 | 1 | #include "os.h" |
3 | 2 | #include "common/library.h" |
4 | | -} |
5 | | -#include "util/windows/unicode.hpp" |
6 | | -#include "util/windows/wmi.hpp" |
| 3 | +#include "util/windows/unicode.h" |
7 | 4 | #include "util/stringUtils.h" |
8 | 5 |
|
9 | | -static const char* getOsNameByWmi(FFstrbuf* osName) |
10 | | -{ |
11 | | - FFWmiQuery query(L"SELECT Caption FROM Win32_OperatingSystem"); |
12 | | - if(!query) |
13 | | - return "Query WMI service failed"; |
14 | | - |
15 | | - if(FFWmiRecord record = query.next()) |
16 | | - { |
17 | | - if(auto vtCaption = record.get(L"Caption")) |
18 | | - { |
19 | | - ffStrbufSetWSV(osName, vtCaption.get<std::wstring_view>()); |
20 | | - ffStrbufTrimRight(osName, ' '); |
21 | | - return NULL; |
22 | | - } |
23 | | - return "Get Caption failed"; |
24 | | - } |
25 | | - |
26 | | - return "No WMI result returned"; |
27 | | -} |
| 6 | +#include <windows.h> |
28 | 7 |
|
29 | 8 | PWSTR WINAPI BrandingFormatString(PCWSTR format); |
30 | 9 |
|
31 | | -static const char* getOsNameByWinbrand(FFstrbuf* osName) |
| 10 | +void ffDetectOSImpl(FFOSResult* os) |
32 | 11 | { |
33 | 12 | //https://dennisbabkin.com/blog/?t=how-to-tell-the-real-version-of-windows-your-app-is-running-on#ver_string |
34 | | - FF_LIBRARY_LOAD(winbrand, "dlopen winbrand" FF_LIBRARY_EXTENSION " failed", "winbrand" FF_LIBRARY_EXTENSION, 1); |
35 | | - FF_LIBRARY_LOAD_SYMBOL_MESSAGE(winbrand, BrandingFormatString); |
36 | | - |
37 | | - const wchar_t* rawName = ffBrandingFormatString(L"%WINDOWS_LONG%"); |
38 | | - ffStrbufSetWS(osName, rawName); |
| 13 | + const wchar_t* rawName = BrandingFormatString(L"%WINDOWS_LONG%"); |
| 14 | + ffStrbufSetWS(&os->variant, rawName); |
39 | 15 | GlobalFree((HGLOBAL)rawName); |
40 | | - return NULL; |
41 | | -} |
42 | | - |
43 | | -extern "C" |
44 | | -void ffDetectOSImpl(FFOSResult* os) |
45 | | -{ |
46 | | - if(getOsNameByWinbrand(&os->variant) && getOsNameByWmi(&os->variant)) |
47 | | - return; |
48 | | - |
49 | 16 | ffStrbufTrimRight(&os->variant, ' '); |
50 | 17 |
|
51 | 18 | //WMI returns the "Microsoft" prefix while BrandingFormatString doesn't. Make them consistent. |
|
0 commit comments