Move registry reading to engine

git-svn-id: https://svn.eduke32.com/eduke32@8268 1a8010ca-5511-0410-912e-c29ae57300e0

# Conflicts:
#	source/duke3d/src/common.cpp
This commit is contained in:
hendricks266 2019-10-30 05:51:39 +00:00 committed by Christoph Oelckers
parent 418ec0d829
commit 797c79d4a5
3 changed files with 39 additions and 7 deletions

View File

@ -140,6 +140,10 @@ void COMMON_clearbackground(int32_t numcols, int32_t numrows);
#define EDUKE32_TMRTIC t[ti++]=timerGetTicks() #define EDUKE32_TMRTIC t[ti++]=timerGetTicks()
#define EDUKE32_TMRPRN do { int ii=0; fprintf(stderr,"%s: ",tmrstr); for (ii=1; ii<ti; ii++) fprintf(stderr,"%d ", t[ii]-t[ii-1]); fprintf(stderr,"\n"); } while (0) #define EDUKE32_TMRPRN do { int ii=0; fprintf(stderr,"%s: ",tmrstr); for (ii=1; ii<ti; ii++) fprintf(stderr,"%d ", t[ii]-t[ii-1]); fprintf(stderr,"\n"); } while (0)
#if defined _WIN32 && !defined EDUKE32_STANDALONE
int Paths_ReadRegistryValue(char const * const SubKey, char const * const Value, char * const Output, DWORD * OutputSize);
#endif
using SteamPathParseFunc = void(*)(const char *); using SteamPathParseFunc = void(*)(const char *);
void Paths_ParseSteamKeyValuesForPaths(const char *vdf, SteamPathParseFunc func); void Paths_ParseSteamKeyValuesForPaths(const char *vdf, SteamPathParseFunc func);

View File

@ -289,6 +289,41 @@ void COMMON_clearbackground(int numcols, int numrows)
COMMON_doclearbackground(numcols, 8 * numrows + 8); COMMON_doclearbackground(numcols, 8 * numrows + 8);
} }
#if defined _WIN32 && !defined EDUKE32_STANDALONE
# define NEED_SHLWAPI_H
# include "windows_inc.h"
# ifndef KEY_WOW64_64KEY
# define KEY_WOW64_64KEY 0x0100
# endif
# ifndef KEY_WOW64_32KEY
# define KEY_WOW64_32KEY 0x0200
# endif
int Paths_ReadRegistryValue(char const * const SubKey, char const * const Value, char * const Output, DWORD * OutputSize)
{
// KEY_WOW64_32KEY gets us around Wow6432Node on 64-bit builds
REGSAM const wow64keys[] = { KEY_WOW64_32KEY, KEY_WOW64_64KEY };
for (auto &wow64key : wow64keys)
{
HKEY hkey;
LONG keygood = RegOpenKeyEx(HKEY_LOCAL_MACHINE, NULL, 0, KEY_READ | wow64key, &hkey);
if (keygood != ERROR_SUCCESS)
continue;
LONG retval = SHGetValueA(hkey, SubKey, Value, NULL, Output, OutputSize);
RegCloseKey(hkey);
if (retval == ERROR_SUCCESS)
return 1;
}
return 0;
}
#endif
// A bare-bones "parser" for Valve's KeyValues VDF format. // A bare-bones "parser" for Valve's KeyValues VDF format.
// There is no guarantee this will function properly with ill-formed files. // There is no guarantee this will function properly with ill-formed files.
static void KeyValues_SkipWhitespace(char **vdfbuf, char * const vdfbufend) static void KeyValues_SkipWhitespace(char **vdfbuf, char * const vdfbufend)

View File

@ -16,15 +16,8 @@
#include "vfs.h" #include "vfs.h"
#ifdef _WIN32 #ifdef _WIN32
# define NEED_SHLWAPI_H
# include "windows_inc.h" # include "windows_inc.h"
# include "win32/winbits.h" # include "win32/winbits.h"
# ifndef KEY_WOW64_64KEY
# define KEY_WOW64_64KEY 0x0100
# endif
# ifndef KEY_WOW64_32KEY
# define KEY_WOW64_32KEY 0x0200
# endif
#elif defined __APPLE__ #elif defined __APPLE__
# include "osxbits.h" # include "osxbits.h"
#endif #endif