Debian Codegraph @

admin/win/tools/NCMsiHelper/NCMsiHelper.h

raw
1 /*
2 * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
3 * SPDX-License-Identifier: GPL-2.0-or-later OR CPOL-1.02
4 *
5 * Parts of this file are based on:
6 * https://www.codeproject.com/articles/570751/devmsi-an-example-cplusplus-msi-wix-deferred-custo
7 *
8 * Licensed under the The Code Project Open License (CPOL):
9 * https://www.codeproject.com/info/cpol10.aspx
10 */
11
12 /**
13 * Function prototypes for external "C" interfaces into the DLL.
14 *
15 * This project builds a "hybrid" DLL that will work either from
16 * a MSI Custom Action environment or from an external C program.
17 * The former routes through "C" interface functions defined in
18 * CustomAction.def. The latter uses the interfaces defined here.
19 *
20 * This header is suitable for inclusion by a project wanting to
21 * call these methods. Note that _NCMSIHELPER_EXPORTS should not be
22 * defined for the accessing application source code.
23 */
24 #pragma once
25
26 #include <windows.h>
27
28 #ifdef _NCMSIHELPER_EXPORTS
29 # pragma comment (lib, "newdev")
30 # pragma comment (lib, "setupapi")
31 # pragma comment (lib, "msi")
32 # pragma comment (lib, "dutil")
33 # pragma comment (lib, "wcautil")
34 # pragma comment (lib, "Version")
35
36 # include <cstdlib>
37 # include <string>
38 # include <tchar.h>
39 # include <msiquery.h>
40 # include <lmerr.h>
41
42 // WiX Header Files:
43 # include <wcautil.h>
44 # include <strutil.h>
45
46 # define NCMSIHELPER_API __declspec(dllexport)
47 #else
48 # define NCMSIHELPER_API __declspec(dllimport)
49 #endif
50
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
66 /**
67 * Removes the Explorer's Navigation Pane entries.
68 *
69 * argc MUST be 1.
70 *
71 * argv[0] is APPLICATION_NAME, e.g. "Nextcloud"
72 *
73 * @param argc The count of valid arguments in argv.
74 * @param argv An array of string arguments for the function.
75 * @return Returns an HRESULT indicating success or failure.
76 */
77 HRESULT NCMSIHELPER_API DoRemoveNavigationPaneEntries(int argc, LPWSTR *argv);
78
79 /**
80 * Standardized function prototype for NCMsiHelper.
81 *
82 * Functions in NCMsiHelper can be called through the MSI Custom
83 * Action DLL or through an external C program. Both
84 * methods expect to wrap things into this function prototype.
85 *
86 * As a result, all functions defined in this header should
87 * conform to this function prototype.
88 */
89 using CUSTOM_ACTION_ARGC_ARGV = NCMSIHELPER_API HRESULT(*)(int argc, LPWSTR *argv);