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.

87 lines
2.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: N C C F G M G R . C P P
  7. //
  8. // Contents: Common code useful when using the Configuration Manager APIs.
  9. //
  10. // Notes: Pollute this under penalty of death.
  11. //
  12. // Author: shaunco 6 May 1998
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <pch.h>
  16. #pragma hdrstop
  17. #include "nccfgmgr.h"
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Function: HrFromConfigManagerError
  21. //
  22. // Purpose: Convert a CONFIGRET into an HRESULT.
  23. //
  24. // Arguments:
  25. // cr [in] CONFIGRET to convert.
  26. // hrDefault [in] Default HRESULT to use if mapping not found.
  27. //
  28. // Returns: HRESULT
  29. //
  30. // Author: shaunco 6 May 1998
  31. //
  32. // Notes:
  33. //
  34. NOTHROW
  35. HRESULT
  36. HrFromConfigManagerError (
  37. CONFIGRET cr,
  38. HRESULT hrDefault)
  39. {
  40. switch (cr)
  41. {
  42. case CR_SUCCESS:
  43. return NO_ERROR;
  44. case CR_OUT_OF_MEMORY:
  45. return E_OUTOFMEMORY;
  46. case CR_INVALID_POINTER:
  47. return E_POINTER;
  48. case CR_INVALID_DEVINST:
  49. return HRESULT_FROM_WIN32 (ERROR_NO_SUCH_DEVINST);
  50. case CR_ALREADY_SUCH_DEVINST:
  51. return HRESULT_FROM_WIN32 (ERROR_DEVINST_ALREADY_EXISTS);
  52. case CR_INVALID_DEVICE_ID:
  53. return HRESULT_FROM_WIN32 (ERROR_INVALID_DEVINST_NAME);
  54. case CR_INVALID_MACHINENAME:
  55. return HRESULT_FROM_WIN32 (ERROR_INVALID_MACHINENAME);
  56. case CR_REMOTE_COMM_FAILURE:
  57. return HRESULT_FROM_WIN32 (ERROR_REMOTE_COMM_FAILURE);
  58. case CR_MACHINE_UNAVAILABLE:
  59. return HRESULT_FROM_WIN32 (ERROR_MACHINE_UNAVAILABLE);
  60. case CR_NO_CM_SERVICES:
  61. return HRESULT_FROM_WIN32 (ERROR_NO_CONFIGMGR_SERVICES);
  62. case CR_ACCESS_DENIED:
  63. return E_ACCESSDENIED;
  64. case CR_CALL_NOT_IMPLEMENTED:
  65. return E_NOTIMPL;
  66. case CR_INVALID_REFERENCE_STRING :
  67. return HRESULT_FROM_WIN32 (ERROR_INVALID_REFERENCE_STRING);
  68. default:
  69. return hrDefault;
  70. }
  71. }