mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-31 18:13:38 +01:00
Host (Windows): detect serial number and UUID
This commit is contained in:
@@ -13,4 +13,4 @@ typedef struct FFHostResult
|
||||
FFstrbuf vendor;
|
||||
} FFHostResult;
|
||||
|
||||
const char* ffDetectHost(FFHostResult* host);
|
||||
const char* ffDetectHost(FFHostResult* host, FFHostOptions* options);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "common/settings.h"
|
||||
#include <ctype.h>
|
||||
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
const char* ffDetectHost(FFHostResult* host, FF_MAYBE_UNUSED FFHostOptions* options)
|
||||
{
|
||||
// http://newandroidbook.com/ddb/
|
||||
ffSettingsGetAndroidProperty("ro.product.device", &host->family);
|
||||
|
||||
@@ -201,7 +201,7 @@ const char* getOthersByIokit(FFHostResult* host)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
const char* ffDetectHost(FFHostResult* host, FF_MAYBE_UNUSED FFHostOptions* options)
|
||||
{
|
||||
const char* error = ffSysctlGetString("hw.model", &host->family);
|
||||
if (error) return error;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "common/settings.h"
|
||||
#include "util/smbiosHelper.h"
|
||||
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
const char* ffDetectHost(FFHostResult* host, FF_MAYBE_UNUSED FFHostOptions* options)
|
||||
{
|
||||
ffSettingsGetFreeBSDKenv("smbios.system.product", &host->name);
|
||||
ffCleanUpSmbiosValue(&host->name);
|
||||
|
||||
@@ -27,7 +27,7 @@ static void getHostProductName(FFstrbuf* name)
|
||||
ffStrbufClear(name);
|
||||
}
|
||||
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
const char* ffDetectHost(FFHostResult* host, FF_MAYBE_UNUSED FFHostOptions* options)
|
||||
{
|
||||
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/product_family", "/sys/class/dmi/id/product_family", &host->family);
|
||||
getHostProductName(&host->name);
|
||||
|
||||
@@ -1,8 +1,30 @@
|
||||
extern "C"
|
||||
{
|
||||
#include "host.h"
|
||||
#include "util/windows/registry.h"
|
||||
#include "util/smbiosHelper.h"
|
||||
}
|
||||
#include "util/windows/wmi.hpp"
|
||||
#include "util/windows/unicode.hpp"
|
||||
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
const char* detectWithWmi(FFHostResult* host)
|
||||
{
|
||||
FFWmiQuery query(L"SELECT IdentifyingNumber, UUID FROM Win32_ComputerSystemProduct", nullptr, FFWmiNamespace::CIMV2);
|
||||
if(!query)
|
||||
return "Query WMI service failed";
|
||||
|
||||
if (FFWmiRecord record = query.next())
|
||||
{
|
||||
if (auto identifyingNumber = record.get(L"IdentifyingNumber"))
|
||||
ffStrbufSetWSV(&host->serial, identifyingNumber.get<std::wstring_view>());
|
||||
if (auto uuid = record.get(L"UUID"))
|
||||
ffStrbufSetWSV(&host->uuid, uuid.get<std::wstring_view>());
|
||||
return NULL;
|
||||
}
|
||||
return "No WMI result returned";
|
||||
}
|
||||
|
||||
const char* ffDetectHost(FFHostResult* host, FFHostOptions* options)
|
||||
{
|
||||
FF_HKEY_AUTO_DESTROY hKey = NULL;
|
||||
|
||||
@@ -20,5 +42,8 @@ const char* ffDetectHost(FFHostResult* host)
|
||||
ffRegReadStrbuf(hKey, L"SystemManufacturer", &host->vendor, NULL);
|
||||
ffCleanUpSmbiosValue(&host->vendor);
|
||||
|
||||
if (options->useWmi)
|
||||
detectWithWmi(host);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user