aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/regutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/dutil/regutil.cpp59
1 files changed, 57 insertions, 2 deletions
diff --git a/src/dutil/regutil.cpp b/src/dutil/regutil.cpp
index e1ef19e8..afd2d089 100644
--- a/src/dutil/regutil.cpp
+++ b/src/dutil/regutil.cpp
@@ -283,7 +283,7 @@ LExit:
283 283
284 284
285/******************************************************************** 285/********************************************************************
286 RegKeyEnum - enumerates a registry key. 286 RegKeyEnum - enumerates child registry keys.
287 287
288*********************************************************************/ 288*********************************************************************/
289extern "C" HRESULT DAPI RegKeyEnum( 289extern "C" HRESULT DAPI RegKeyEnum(
@@ -340,7 +340,7 @@ LExit:
340 340
341 341
342/******************************************************************** 342/********************************************************************
343 RegValueEnum - enumerates a registry value. 343 RegValueEnum - enumerates registry values.
344 344
345*********************************************************************/ 345*********************************************************************/
346HRESULT DAPI RegValueEnum( 346HRESULT DAPI RegValueEnum(
@@ -939,6 +939,61 @@ LExit:
939 return hr; 939 return hr;
940} 940}
941 941
942/********************************************************************
943RegKeyReadNumber - reads a DWORD registry key value as a number from
944a specified subkey.
945
946*********************************************************************/
947extern "C" HRESULT DAPI RegKeyReadNumber(
948 __in HKEY hk,
949 __in_z LPCWSTR wzSubKey,
950 __in_z_opt LPCWSTR wzName,
951 __in BOOL f64Bit,
952 __out DWORD* pdwValue
953 )
954{
955 HRESULT hr = S_OK;
956 HKEY hkKey = NULL;
957
958 hr = RegOpen(hk, wzSubKey, KEY_READ | f64Bit ? KEY_WOW64_64KEY : 0, &hkKey);
959 RegExitOnFailure(hr, "Failed to open key: %ls", wzSubKey);
960
961 hr = RegReadNumber(hkKey, wzName, pdwValue);
962 RegExitOnFailure(hr, "Failed to read value: %ls/@%ls", wzSubKey, wzName);
963
964LExit:
965 ReleaseRegKey(hkKey);
966
967 return hr;
968}
969
970/********************************************************************
971RegValueExists - determines whether a named value exists in a
972specified subkey.
973
974*********************************************************************/
975extern "C" BOOL DAPI RegValueExists(
976 __in HKEY hk,
977 __in_z LPCWSTR wzSubKey,
978 __in_z_opt LPCWSTR wzName,
979 __in BOOL f64Bit
980 )
981{
982 HRESULT hr = S_OK;
983 HKEY hkKey = NULL;
984 DWORD dwType = 0;
985
986 hr = RegOpen(hk, wzSubKey, KEY_READ | f64Bit ? KEY_WOW64_64KEY : 0, &hkKey);
987 RegExitOnFailure(hr, "Failed to open key: %ls", wzSubKey);
988
989 hr = RegGetType(hkKey, wzName, &dwType);
990 RegExitOnFailure(hr, "Failed to read value type: %ls/@%ls", wzSubKey, wzName);
991
992LExit:
993 ReleaseRegKey(hkKey);
994
995 return SUCCEEDED(hr);
996}
942 997
943static HRESULT WriteStringToRegistry( 998static HRESULT WriteStringToRegistry(
944 __in HKEY hk, 999 __in HKEY hk,