diff options
Diffstat (limited to 'src/dutil/regutil.cpp')
| -rw-r--r-- | src/dutil/regutil.cpp | 59 |
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 | *********************************************************************/ |
| 289 | extern "C" HRESULT DAPI RegKeyEnum( | 289 | extern "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 | *********************************************************************/ |
| 346 | HRESULT DAPI RegValueEnum( | 346 | HRESULT DAPI RegValueEnum( |
| @@ -939,6 +939,61 @@ LExit: | |||
| 939 | return hr; | 939 | return hr; |
| 940 | } | 940 | } |
| 941 | 941 | ||
| 942 | /******************************************************************** | ||
| 943 | RegKeyReadNumber - reads a DWORD registry key value as a number from | ||
| 944 | a specified subkey. | ||
| 945 | |||
| 946 | *********************************************************************/ | ||
| 947 | extern "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 | |||
| 964 | LExit: | ||
| 965 | ReleaseRegKey(hkKey); | ||
| 966 | |||
| 967 | return hr; | ||
| 968 | } | ||
| 969 | |||
| 970 | /******************************************************************** | ||
| 971 | RegValueExists - determines whether a named value exists in a | ||
| 972 | specified subkey. | ||
| 973 | |||
| 974 | *********************************************************************/ | ||
| 975 | extern "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 | |||
| 992 | LExit: | ||
| 993 | ReleaseRegKey(hkKey); | ||
| 994 | |||
| 995 | return SUCCEEDED(hr); | ||
| 996 | } | ||
| 942 | 997 | ||
| 943 | static HRESULT WriteStringToRegistry( | 998 | static HRESULT WriteStringToRegistry( |
| 944 | __in HKEY hk, | 999 | __in HKEY hk, |
