LogResult.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (C) by Michael Schuster <michael.schuster@nextcloud.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. *
  14. * Parts of this file are based on:
  15. * https://www.codeproject.com/articles/570751/devmsi-an-example-cplusplus-msi-wix-deferred-custo
  16. *
  17. * Licensed under the The Code Project Open License (CPOL):
  18. * https://www.codeproject.com/info/cpol10.aspx
  19. *
  20. */
  21. /**
  22. * Function prototype for LogResult()
  23. */
  24. #pragma once
  25. /**
  26. * Log a message.
  27. *
  28. * If the DLL is being used in a WiX MSI environment, LogResult() will
  29. * route any log messages to the MSI log file via WcaLog() or WcaLogError().
  30. *
  31. * If the DLL is NOT being used in a WiX MSI environment, LogResult() will
  32. * route any log messages to stdout or stderr.
  33. *
  34. * If the result is an error code, LogResult will attempt to gather a
  35. * text version of the error code and place it in the log. For example,
  36. * if the error code means ERROR_FILE_NOT_FOUND, it will look up the appropriate
  37. * message ( via FormatMessage() ) and add "The system cannot find the file specified."
  38. * to the log.
  39. *
  40. * @param hr The HRESULT to be interrogated for success or failure.
  41. * @param fmt The string format for a user-specified error message.
  42. */
  43. void LogResult(
  44. __in HRESULT hr,
  45. __in_z __format_string PCSTR fmt, ...
  46. );