Files
fastfetch/src/util/windows/wmi.hpp
T
李通洲 49921f5ed1 Disk: add support for Windows
Also major refactoring of util/windows/wmi
2022-10-09 15:37:14 +08:00

47 lines
1.2 KiB
C++

#pragma once
#ifndef FF_INCLUDED_util_windows_wmi
#define FF_INCLUDED_util_windows_wmi
#ifdef __cplusplus
extern "C" {
#include "util/FFstrbuf.h"
}
#include <Wbemidl.h>
//<comdef.h> is not usable in MSYS, so provide our simple bstr_t implementation
struct bstr_t
{
explicit bstr_t(const wchar_t* str) noexcept: _bstr(SysAllocString(str)) {}
~bstr_t() noexcept { SysFreeString(_bstr); }
explicit operator const wchar_t*() const noexcept {
return _bstr;
}
operator BSTR() const noexcept {
return _bstr;
}
private:
BSTR _bstr;
};
void ffBstrToStrbuf(BSTR bstr, FFstrbuf* strbuf);
IEnumWbemClassObject* ffQueryWmi(const wchar_t* queryStr, FFstrbuf* error);
bool ffGetWmiObjString(IWbemClassObject* obj, const wchar_t* key, FFstrbuf* strbuf);
bool ffGetWmiObjSigned(IWbemClassObject* obj, const wchar_t* key, int64_t* integer);
bool ffGetWmiObjUnsigned(IWbemClassObject* obj, const wchar_t* key, uint64_t* integer);
bool ffGetWmiObjReal(IWbemClassObject* obj, const wchar_t* key, double* real);
#else
// Win32 COM headers requires C++ compiler
#error Must be included in C++ source file
#endif //__cplusplus
#endif //FF_INCLUDED_util_windows_wmi