Files
fastfetch/src/util/windows/register.h
T
李通洲 4fa3ca98a2 util/register: fix crashing when value string contains non-ascii chars
We can't use RegGetValueA because RegGetValueA converts wide string to non UTF-8 string, which results in crashing when printing
2022-11-23 17:44:57 +08:00

24 lines
631 B
C

#pragma once
#ifndef FASTFETCH_INCLUDED_REGISTER_H
#define FASTFETCH_INCLUDED_REGISTER_H
#include "fastfetch.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
static inline void wrapRegCloseKey(HKEY* phKey)
{
if(*phKey)
RegCloseKey(*phKey);
}
#define FF_HKEY_AUTO_DESTROY HKEY __attribute__((__cleanup__(wrapRegCloseKey)))
bool ffRegOpenKeyForRead(HKEY hKey, const wchar_t* subKeyW, HKEY* result, FFstrbuf* error);
bool ffRegReadStrbuf(HKEY hKey, const wchar_t* valueNameW, FFstrbuf* result, FFstrbuf* error);
bool ffRegReadUint(HKEY hKey, const wchar_t* valueNameW, uint32_t* result, FFstrbuf* error);
#endif