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