NCMsiHelper.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 prototypes for external "C" interfaces into the DLL.
  23. *
  24. * This project builds a "hybrid" DLL that will work either from
  25. * a MSI Custom Action environment or from an external C program.
  26. * The former routes through "C" interface functions defined in
  27. * CustomAction.def. The latter uses the interfaces defined here.
  28. *
  29. * This header is suitable for inclusion by a project wanting to
  30. * call these methods. Note that _NCMSIHELPER_EXPORTS should not be
  31. * defined for the accessing application source code.
  32. */
  33. #pragma once
  34. #ifdef _NCMSIHELPER_EXPORTS
  35. # pragma comment (lib, "newdev")
  36. # pragma comment (lib, "setupapi")
  37. # pragma comment (lib, "msi")
  38. # pragma comment (lib, "dutil")
  39. # pragma comment (lib, "wcautil")
  40. # pragma comment (lib, "Version")
  41. # include <msiquery.h>
  42. # include <stdlib.h>
  43. # include <lmerr.h>
  44. // WiX Header Files:
  45. # include <wcautil.h>
  46. # include <strutil.h>
  47. # define NCMSIHELPER_API __declspec(dllexport)
  48. #else
  49. # define NCMSIHELPER_API __declspec(dllimport)
  50. #endif
  51. /**
  52. * Runs the NSIS uninstaller and waits for its completion.
  53. *
  54. * argc MUST be 2.
  55. *
  56. * argv[0] is APPLICATION_EXECUTABLE, e.g. "nextcloud"
  57. * argv[1] is the full path to "Uninstall.exe"
  58. *
  59. * @param argc The count of valid arguments in argv.
  60. * @param argv An array of string arguments for the function.
  61. * @return Returns an HRESULT indicating success or failure.
  62. */
  63. HRESULT NCMSIHELPER_API DoExecNsisUninstaller(int argc, LPWSTR *argv);
  64. /**
  65. * Removes the Explorer's Navigation Pane entries.
  66. *
  67. * argc MUST be 1.
  68. *
  69. * argv[0] is APPLICATION_NAME, e.g. "Nextcloud"
  70. *
  71. * @param argc The count of valid arguments in argv.
  72. * @param argv An array of string arguments for the function.
  73. * @return Returns an HRESULT indicating success or failure.
  74. */
  75. HRESULT NCMSIHELPER_API DoRemoveNavigationPaneEntries(int argc, LPWSTR *argv);
  76. /**
  77. * Standardized function prototype for NCMsiHelper.
  78. *
  79. * Functions in NCMsiHelper can be called through the MSI Custom
  80. * Action DLL or through an external C program. Both
  81. * methods expect to wrap things into this function prototype.
  82. *
  83. * As a result, all functions defined in this header should
  84. * conform to this function prototype.
  85. */
  86. typedef HRESULT NCMSIHELPER_API (*CUSTOM_ACTION_ARGC_ARGV)(
  87. int argc, LPWSTR *argv);