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