Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB

  1. #include "pch.h"
  2. #include "policy.h"
  3. HRESULT MyRegQueryPolicyValueEx(HKEY hPreferenceKey, HKEY hPolicyKey, LPWSTR pwszValue, LPWSTR pwszReserved, DWORD *pdwType, BYTE *pbData, DWORD *pcbData) {
  4. bool bUsedPolicySettings = false;
  5. DWORD dwError;
  6. HRESULT hr;
  7. if (NULL != hPolicyKey) {
  8. // Override with policy settings:
  9. dwError=RegQueryValueEx(hPolicyKey, pwszValue, NULL, pdwType, pbData, pcbData);
  10. if (ERROR_SUCCESS!=dwError) {
  11. hr=HRESULT_FROM_WIN32(dwError);
  12. // We don't worry if we can't read the value, we'll just take our default from the preferences.
  13. _IgnoreErrorStr(hr, "RegQueryValueEx", pwszValue);
  14. } else {
  15. bUsedPolicySettings = true;
  16. }
  17. }
  18. if (!bUsedPolicySettings) { // Couldn't read value from policy
  19. // Read the value from our preferences in the registry:
  20. dwError=RegQueryValueEx(hPreferenceKey, pwszValue, NULL, pdwType, pbData, pcbData);
  21. if (ERROR_SUCCESS!=dwError) {
  22. hr=HRESULT_FROM_WIN32(dwError);
  23. _JumpErrorStr(hr, error, "RegQueryValueEx", pwszValue);
  24. }
  25. }
  26. hr = S_OK;
  27. error:
  28. return hr;
  29. }