mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
Host: improve performance (Windows)
This commit is contained in:
parent
5aebb400da
commit
4355039329
@ -431,7 +431,7 @@ elseif(WIN32)
|
||||
src/detection/displayserver/displayserver_windows.c
|
||||
src/detection/font/font_windows.cpp
|
||||
src/detection/gpu/gpu_windows.cpp
|
||||
src/detection/host/host_windows.cpp
|
||||
src/detection/host/host_windows.c
|
||||
src/detection/localip/localip_windows.c
|
||||
src/detection/media/media_nosupport.c
|
||||
src/detection/memory/memory_windows.c
|
||||
|
27
src/detection/host/host_windows.c
Normal file
27
src/detection/host/host_windows.c
Normal file
@ -0,0 +1,27 @@
|
||||
#include "host.h"
|
||||
#include "util/windows/register.h"
|
||||
|
||||
void ffDetectHostImpl(FFHostResult* host)
|
||||
{
|
||||
ffStrbufInit(&host->error);
|
||||
|
||||
ffStrbufInit(&host->productName);
|
||||
ffStrbufInit(&host->productFamily);
|
||||
ffStrbufInit(&host->productVersion);
|
||||
ffStrbufInit(&host->productSku);
|
||||
ffStrbufInit(&host->sysVendor);
|
||||
ffStrbufInit(&host->chassisType);
|
||||
ffStrbufInit(&host->chassisVendor);
|
||||
ffStrbufInit(&host->chassisVersion);
|
||||
|
||||
FF_HKEY_AUTO_DESTROY hKey = NULL;
|
||||
|
||||
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, &host->error))
|
||||
return;
|
||||
|
||||
ffRegReadStrbuf(hKey, "SystemProductName", &host->productName, NULL);
|
||||
ffRegReadStrbuf(hKey, "SystemFamily", &host->productFamily, NULL);
|
||||
ffRegReadStrbuf(hKey, "SystemVersion", &host->productVersion, NULL);
|
||||
ffRegReadStrbuf(hKey, "SystemSKU", &host->productSku, NULL);
|
||||
ffRegReadStrbuf(hKey, "SystemManufacturer", &host->sysVendor, NULL);
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
extern "C" {
|
||||
#include "host.h"
|
||||
}
|
||||
#include "util/windows/wmi.hpp"
|
||||
|
||||
extern "C" void ffDetectHostImpl(FFHostResult* host)
|
||||
{
|
||||
ffStrbufInit(&host->error);
|
||||
|
||||
ffStrbufInit(&host->productName);
|
||||
ffStrbufInit(&host->productFamily);
|
||||
ffStrbufInit(&host->productVersion);
|
||||
ffStrbufInit(&host->productSku);
|
||||
ffStrbufInit(&host->sysVendor);
|
||||
ffStrbufInit(&host->chassisType);
|
||||
ffStrbufInit(&host->chassisVendor);
|
||||
ffStrbufInit(&host->chassisVersion);
|
||||
|
||||
FFWmiQuery query(L"SELECT Name, Version, SKUNumber, Vendor FROM Win32_ComputerSystemProduct", &host->error);
|
||||
if(!query)
|
||||
return;
|
||||
|
||||
if(FFWmiRecord record = query.next())
|
||||
{
|
||||
record.getString(L"Name", &host->productName);
|
||||
record.getString(L"Version", &host->productVersion);
|
||||
record.getString(L"SKUNumber", &host->productSku);
|
||||
record.getString(L"Vendor", &host->sysVendor);
|
||||
}
|
||||
else
|
||||
ffStrbufAppendS(&host->error, "No Wmi result returned");
|
||||
}
|
@ -35,8 +35,7 @@ void ffPrintHost(FFinstance* instance)
|
||||
|
||||
if(host->productVersion.length > 0)
|
||||
{
|
||||
ffStrbufAppendC(&output, ' ');
|
||||
ffStrbufAppend(&output, &host->productVersion);
|
||||
ffStrbufAppendF(&output, " (%s)", host->productVersion.chars);
|
||||
}
|
||||
|
||||
ffPrintAndWriteToCache(instance, FF_HOST_MODULE_NAME, &instance->config.host, &output, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user