1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_MSIHELPER_HXX
25 #define INCLUDED_MSIHELPER_HXX
26 
27 #ifdef _MSC_VER
28 #pragma warning(push, 1) /* disable warnings within system headers */
29 #endif
30 #define WIN32_LEAN_AND_MEAN
31 #include <windows.h>
32 #include <msiquery.h>
33 #ifdef _MSC_VER
34 #pragma warning(pop)
35 #endif
36 
37 #include <string>
38 
39 /**
40     Get the value of the named property
41 
42     @param handle
43     [in] a valid msi handle.
44 
45     @param name
46     [in] the name of the property.
47 
48     @param value
49     [out] receives this value of the property.
50 
51     @returns
52     <TRUE/>if the property was found.
53 */
54 bool GetMsiProp(MSIHANDLE handle, LPCTSTR name, /*out*/std::wstring& value);
55 
56 /**
57     Set the value of a binary property which can only
58     have the values "0" or "1" to "1".
59 
60     @param handle
61     [in] a valid msi handle.
62 
63     @param name
64     [in] the name of the property.
65 */
66 void SetMsiProp(MSIHANDLE handle, LPCTSTR name);
67 
68 /**
69     Set the value of a binary property which can only
70     have the values "0" or "1" to "0".
71 
72     @param handle
73     [in] a valid msi handle.
74 
75     @param name
76     [in] the name of the property.
77 */
78 void UnsetMsiProp(MSIHANDLE handle, LPCTSTR name);
79 
80 /**
81     Returns whether a certain property is set meaning
82     its value is "1". This method should be used for
83     binary properties whose value can be "0" or "1".
84 
85     @returns
86     <TRUE/>if the value of the specified property is
87     "1" else if the property is not defined or its
88     value is other than "1" <FALSE/> will be returned.
89 */
90 bool IsSetMsiProp(MSIHANDLE handle, LPCTSTR name);
91 
92 /**
93     Returns whether a certain property is set meaning
94     its value is not empty. This method should be used for
95     properties, that can have different values.
96 
97     @returns
98     <TRUE/>if the value of the specified property is
99     not empty. If it is empty <FALSE/> will be returned.
100 */
101 bool IsMsiPropNotEmpty(MSIHANDLE handle, LPCTSTR name);
102 
103 /**
104     Query if this is an installation for all user or not.
105 
106     @param handle
107     [in] a valid msi handle.
108 
109     @returns
110     <TRUE/>if this is an all user installation
111 */
112 bool IsAllUserInstallation(MSIHANDLE handle);
113 
114 /**
115     Returns the destination folder of the office installation
116     as system path. The returned path contains a final '\'.
117 
118     @param handle
119     [in] a valid msi handle.
120 
121     @returns
122     the destination path of the office installation finalized
123     with a '\'.
124 */
125 std::wstring GetOfficeInstallationPath(MSIHANDLE handle);
126 
127 /**
128     Returns the absolute path of the office executable that
129     will be installed as system path.
130 
131     @param handle
132     [in] a valid msi handle.
133 
134     @returns
135     the absolute system path of the office executable (e.g.
136     "C:\Program Files (x86)\OpenOffice 4\program\soffice.exe").
137 */
138 std::wstring GetOfficeExecutablePath(MSIHANDLE handle);
139 
140 /**
141     Get the name of the office that will be installed
142 
143     @param handle
144     [in] a valid msi handle.
145 
146     @returns
147     the name of the office product that will be installed.
148 */
149 std::wstring GetProductName(MSIHANDLE handle);
150 
151 /**
152     Determine if the specified module is installed locally.
153 
154     @param handle
155     [in] a valid msi handle.
156 
157     @param name
158     [in] the name of the module.
159 
160     @returns
161     <TRUE/>if the specified module is installed locally.
162 */
163 bool IsModuleInstalled(MSIHANDLE handle, LPCTSTR name);
164 
165 /**
166     Determine if the specified module is selected to be installed
167     locally.
168 
169     @param handle
170     [in] a valid msi handle.
171 
172     @param name
173     [in] the name of the module.
174 
175     @returns
176     <TRUE/>if the specified module is about to be installed locally.
177 */
178 bool IsModuleSelectedForInstallation(MSIHANDLE handle, LPCTSTR name);
179 
180 /**
181     Determine if the specified module which is locally installed is
182     selected for deinstallation.
183 
184     @param handle
185     [in] a valid msi handle.
186 
187     @param name
188     [in] the name of the module.
189 
190     @returns
191     <TRUE/>if the specified module is about to be deinstalled.
192 */
193 bool IsModuleSelectedForDeinstallation(MSIHANDLE handle, LPCTSTR name);
194 
195 /**
196     Determine whether this is a complete deinstallation or not.
197 
198     @param handle
199     [in] a valid msi handle.
200 
201     @returns
202     <TRUE/>if this is a complete deinstallation.
203 */
204 bool IsCompleteDeinstallation(MSIHANDLE handle);
205 
206 #endif
207