libobs: Add wrapper function to query Windows registry
This commit is contained in:
parent
a76b919c6e
commit
0759eeb5da
@ -83,6 +83,7 @@ if(WIN32)
|
||||
util/platform-windows.c)
|
||||
set(libobs_PLATFORM_HEADERS
|
||||
util/threading-windows.h
|
||||
util/windows/win-registry.h
|
||||
util/windows/win-version.h
|
||||
util/windows/ComPtr.hpp
|
||||
util/windows/CoTaskMemPtr.hpp
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "platform.h"
|
||||
#include "darray.h"
|
||||
#include "dstr.h"
|
||||
#include "windows/win-registry.h"
|
||||
#include "windows/win-version.h"
|
||||
|
||||
#include "../../deps/w32-pthreads/pthread.h"
|
||||
@ -800,6 +801,28 @@ bool is_64_bit_windows(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void get_reg_dword(HKEY hkey, LPCWSTR sub_key, LPCWSTR value_name,
|
||||
struct reg_dword *info)
|
||||
{
|
||||
struct reg_dword reg = {0};
|
||||
HKEY key;
|
||||
LSTATUS status;
|
||||
|
||||
status = RegOpenKeyEx(hkey, sub_key, 0, KEY_READ, &key);
|
||||
|
||||
if (status != ERROR_SUCCESS)
|
||||
return;
|
||||
|
||||
reg.size = sizeof(reg.return_value);
|
||||
|
||||
reg.status = RegQueryValueExW(key, value_name, NULL, NULL,
|
||||
(LPBYTE)®.return_value, ®.size);
|
||||
|
||||
RegCloseKey(key);
|
||||
|
||||
*info = reg;
|
||||
}
|
||||
|
||||
#define WINVER_REG_KEY L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
|
||||
|
||||
void get_win_ver(struct win_version_info *info)
|
||||
|
38
libobs/util/windows/win-registry.h
Normal file
38
libobs/util/windows/win-registry.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Hugh Bailey <obs.jim@gmail.com>
|
||||
* Copyright (c) 2017 Ryan Foster <RytoEX@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include "../c99defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct reg_dword {
|
||||
LSTATUS status;
|
||||
DWORD size;
|
||||
DWORD return_value;
|
||||
};
|
||||
|
||||
EXPORT void get_reg_dword(HKEY hkey, LPCWSTR sub_key, LPCWSTR value_name,
|
||||
struct reg_dword *info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user