Source code of Windows XP (NT5)
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.

72 lines
1.3 KiB

  1. // Copyright (C) 1999 Microsoft Corporation
  2. //
  3. // common routines
  4. //
  5. // sburns 5-3-99
  6. #include "headers.hxx"
  7. #include "common.hpp"
  8. void
  9. SetComError(
  10. unsigned descriptionMessageResID,
  11. DWORD helpContext)
  12. {
  13. SetComError(String::load(descriptionMessageResID), helpContext);
  14. }
  15. void
  16. SetComError(
  17. const String& description,
  18. DWORD helpContext)
  19. {
  20. LOG_FUNCTION2(SetComError, description);
  21. ICreateErrorInfo* cei = 0;
  22. HRESULT hr = S_OK;
  23. do
  24. {
  25. hr = ::CreateErrorInfo(&cei);
  26. BREAK_ON_FAILED_HRESULT(hr);
  27. hr = cei->SetGUID(IID_ICloneSecurityPrincipal);
  28. BREAK_ON_FAILED_HRESULT(hr);
  29. hr = cei->SetSource(PROGID_VERSION_STRING);
  30. BREAK_ON_FAILED_HRESULT(hr);
  31. hr =
  32. cei->SetDescription(
  33. const_cast<String::value_type*>(description.c_str()));
  34. BREAK_ON_FAILED_HRESULT(hr);
  35. hr = cei->SetHelpFile(L"" /* HELPFILE_NAME */ );
  36. BREAK_ON_FAILED_HRESULT(hr);
  37. hr = cei->SetHelpContext(helpContext);
  38. BREAK_ON_FAILED_HRESULT(hr);
  39. SmartInterface<IErrorInfo> ei;
  40. hr = ei.AcquireViaQueryInterface(*cei);
  41. BREAK_ON_FAILED_HRESULT(hr);
  42. hr = ::SetErrorInfo(0, ei);
  43. BREAK_ON_FAILED_HRESULT(hr);
  44. }
  45. while (0);
  46. if (cei)
  47. {
  48. cei->Release();
  49. }
  50. }