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 #ifndef INCLUDED_MSIHELPER_HXX 23 #define INCLUDED_MSIHELPER_HXX 24 25 #ifdef _MSC_VER 26 #pragma warning(push, 1) /* disable warnings within system headers */ 27 #endif 28 #define WIN32_LEAN_AND_MEAN 29 #include <windows.h> 30 #include <msiquery.h> 31 #ifdef _MSC_VER 32 #pragma warning(pop) 33 #endif 34 35 #include <string> 36 37 /** 38 Get the value of the named property 39 40 @param handle 41 [in] a valid msi handle. 42 43 @param name 44 [in] the name of the property. 45 46 @param value 47 [out] receives thes value of the property. 48 49 @returns 50 <TRUE/>if the property was found. 51 */ 52 bool GetMsiProp(MSIHANDLE handle, LPCTSTR name, /*out*/std::wstring& value); 53 54 /** 55 Set the value of a binary property which can only 56 have the values "0" or "1" to "1". 57 58 @param handle 59 [in] a valid msi handle. 60 61 @param name 62 [in] the name of the property. 63 */ 64 void SetMsiProp(MSIHANDLE handle, LPCTSTR name); 65 66 /** 67 Set the value of a binary property which can only 68 have the values "0" or "1" to "0". 69 70 @param handle 71 [in] a valid msi handle. 72 73 @param name 74 [in] the name of the property. 75 */ 76 void UnsetMsiProp(MSIHANDLE handle, LPCTSTR name); 77 78 /** 79 Returns whether a certain property is set meaning 80 its value is "1". This method should be used for 81 binary properties whose value can be "0" or "1". 82 83 @returns 84 <TRUE/>if the value of the specified property is 85 "1" else if the property is not defined or its 86 value is other than "1" <FALSE/> will be returned. 87 */ 88 bool IsSetMsiProp(MSIHANDLE handle, LPCTSTR name); 89 90 /** 91 Returns whether a certain property is set meaning 92 its value is not empty. This method should be used for 93 properties, that can have different values. 94 95 @returns 96 <TRUE/>if the value of the specified property is 97 not empty. If it is empty <FALSE/> will be returned. 98 */ 99 bool IsMsiPropNotEmpty(MSIHANDLE handle, LPCTSTR name); 100 101 /** 102 Query if this is an installation for all user or not. 103 104 @param handle 105 [in] a valid msi handle. 106 107 @returns 108 <TRUE/>if this is an all user installation 109 */ 110 bool IsAllUserInstallation(MSIHANDLE handle); 111 112 /** 113 Returns the destination folder of the office installation 114 as system path. The returned path contains a final '\'. 115 116 @param handle 117 [in] a valid msi handle. 118 119 @returns 120 the destination path of the office installation finalized 121 with a '\'. 122 */ 123 std::wstring GetOfficeInstallationPath(MSIHANDLE handle); 124 125 /** 126 Returns the absolute path of the office executable that 127 will be installed as system path. 128 129 @param handle 130 [in] a valid msi handle. 131 132 @returns 133 the absolute system path of the office executable (e.g. 134 (C:\Program Files\StarOffice 8\program\soffice.exe"). 135 */ 136 std::wstring GetOfficeExecutablePath(MSIHANDLE handle); 137 138 /** 139 Get the name of the office that will be installed 140 (e.g. StarOffice 8, StarSuite 8, ...). 141 142 @param handle 143 [in] a valid msi handle. 144 145 @returns 146 the name of the office product that will be installed. 147 */ 148 std::wstring GetProductName(MSIHANDLE handle); 149 150 /** 151 Determine if the specified module is installed locally. 152 153 @param handle 154 [in] a valid msi handle. 155 156 @param name 157 [in] the name of the module. 158 159 @returns 160 <TRUE/>if the specified module is installed locally. 161 */ 162 bool IsModuleInstalled(MSIHANDLE handle, LPCTSTR name); 163 164 /** 165 Determine if the specified module is selected to be installed 166 locally. 167 168 @param handle 169 [in] a valid msi handle. 170 171 @param name 172 [in] the name of the module. 173 174 @returns 175 <TRUE/>if the specified module is about to be installed locally. 176 */ 177 bool IsModuleSelectedForInstallation(MSIHANDLE handle, LPCTSTR name); 178 179 /** 180 Determine if the specified module which is locally installed is 181 selected for deinstallation. 182 183 @param handle 184 [in] a valid msi handle. 185 186 @param name 187 [in] the name of the module. 188 189 @returns 190 <TRUE/>if the specified module is about to be deinstalled. 191 */ 192 bool IsModuleSelectedForDeinstallation(MSIHANDLE handle, LPCTSTR name); 193 194 /** 195 Determine whether this is a complete uninstallation or not. 196 197 @param handle 198 [in] a valid msi handle. 199 200 @returns 201 <TRUE/>if this is a complete deinstallation. 202 */ 203 bool IsCompleteDeinstallation(MSIHANDLE handle); 204 205 #endif 206