[PATCH] fix for fdo#39632 : Consolidate GetMsiProperty()

Mathias M (via Code Review) gerrit at gerrit.libreoffice.org
Tue Jan 22 14:05:23 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1816

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/16/1816/1

fix for fdo#39632 : Consolidate GetMsiProperty()

And did it also for GetMsiProp() and *MsiProperty()
Reworked some conditions related to that.

Change-Id: I1cd082361126db3d9aced3a878b19e7052514864
---
M setup_native/source/win32/customactions/languagepacks/respintest.cxx
M setup_native/source/win32/customactions/reg4allmsdoc/reg4allmsi.cxx
M setup_native/source/win32/customactions/regactivex/regactivex.cxx
M setup_native/source/win32/customactions/regpatchactivex/regpatchactivex.cxx
M setup_native/source/win32/customactions/sellang/sellang.cxx
M setup_native/source/win32/customactions/shellextensions/checkdirectory.cxx
M setup_native/source/win32/customactions/shellextensions/checkpatches.cxx
M setup_native/source/win32/customactions/shellextensions/completeinstallpath.cxx
M setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx
M setup_native/source/win32/customactions/shellextensions/dotnetcheck.cxx
M setup_native/source/win32/customactions/shellextensions/layerlinks.cxx
M setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx
M setup_native/source/win32/customactions/shellextensions/postuninstall.cxx
M setup_native/source/win32/customactions/shellextensions/setadmininstall.cxx
M setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx
M setup_native/source/win32/customactions/shellextensions/upgrade.cxx
M setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx
M setup_native/source/win32/customactions/thesaurus/thesaurus.cxx
M setup_native/source/win32/customactions/tools/checkversion.cxx
A setup_native/source/win32/customactions/tools/msiprop.hxx
20 files changed, 218 insertions(+), 584 deletions(-)



diff --git a/setup_native/source/win32/customactions/languagepacks/respintest.cxx b/setup_native/source/win32/customactions/languagepacks/respintest.cxx
index f757a88..864f9bf 100644
--- a/setup_native/source/win32/customactions/languagepacks/respintest.cxx
+++ b/setup_native/source/win32/customactions/languagepacks/respintest.cxx
@@ -27,7 +27,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -44,53 +44,18 @@
 
 using namespace std;
 
-namespace
-{
-    string GetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        string  result;
-        TCHAR   szDummy[1] = TEXT("");
-        DWORD   nChars = 0;
-
-        if (MsiGetProperty(handle, sProperty.c_str(), szDummy, &nChars) == ERROR_MORE_DATA)
-        {
-            DWORD nBytes = ++nChars * sizeof(TCHAR);
-            LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-            ZeroMemory( buffer, nBytes );
-            MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-            result = buffer;
-        }
-        return result;
-    }
-
-    inline bool IsSetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        return (GetMsiProperty(handle, sProperty).length() > 0);
-    }
-
-    inline void UnsetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        MsiSetProperty(handle, sProperty.c_str(), NULL);
-    }
-
-    inline void SetMsiProperty(MSIHANDLE handle, const string& sProperty, const string&)
-    {
-        MsiSetProperty(handle, sProperty.c_str(), TEXT("1"));
-    }
-} // namespace
-
 extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
 {
-    string sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
+    string sOfficeInstallPath = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
 
     // MessageBox(NULL, sOfficeInstallPath.c_str(), "DEBUG", MB_OK);
 
     // unsetting all properties
 
-    UnsetMsiProperty( handle, TEXT("INVALIDDIRECTORY") );
-    UnsetMsiProperty( handle, TEXT("ISWRONGPRODUCT") );
-    UnsetMsiProperty( handle, TEXT("PATCHISOLDER") );
-    UnsetMsiProperty( handle, TEXT("ALLUSERS") );
+    MsiSetProperty( handle, TEXT("INVALIDDIRECTORY"), NULL );
+    MsiSetProperty( handle, TEXT("ISWRONGPRODUCT"), NULL );
+    MsiSetProperty( handle, TEXT("PATCHISOLDER"), NULL );
+    MsiSetProperty( handle, TEXT("ALLUSERS"), NULL );
 
     // 1. Searching for "ProductCode" in setup.ini
 
@@ -110,7 +75,7 @@
     if ( !_tcsicmp( szValue, TEXT("INVALIDDIRECTORY") ) )
     {
         // No setup.ini or no "ProductCode" in setup.ini. This is an invalid directory.
-        SetMsiProperty( handle, TEXT("INVALIDDIRECTORY"), TEXT("YES") );
+        MsiSetProperty( handle, TEXT("INVALIDDIRECTORY"), TEXT("YES") );
         // MessageBox(NULL, "INVALIDDIRECTORY set, no setup.ini or ProductCode in setup.ini.", "DEBUG", MB_OK);
         SetMsiErrorCode( MSI_ERROR_INVALIDDIRECTORY );
         return ERROR_SUCCESS;
@@ -131,20 +96,20 @@
 
     if ( !_tcsicmp( szValue, TEXT("ISWRONGPRODUCT") ) )
     {
-        SetMsiProperty( handle, TEXT("ISWRONGPRODUCT"), TEXT("YES") );
+        MsiSetProperty( handle, TEXT("ISWRONGPRODUCT"), TEXT("YES") );
         // MessageBox(NULL, "ISWRONGPRODUCT 1 set after searching buildid", "DEBUG", MB_OK);
         SetMsiErrorCode( MSI_ERROR_ISWRONGPRODUCT );
         return ERROR_SUCCESS;
     }
 
-    string ProductMajor = GetMsiProperty(handle, TEXT("PRODUCTMAJOR"));
+    string ProductMajor = GetMsiPropValue(handle, TEXT("PRODUCTMAJOR"));
 
     // Comparing the first three characters, for example "680"
     // If not equal, this version is not suited for patch or language pack
 
     if (_tcsnicmp(ProductMajor.c_str(), szValue, 3))
     {
-        SetMsiProperty( handle, TEXT("ISWRONGPRODUCT"), TEXT("YES") );
+        MsiSetProperty( handle, TEXT("ISWRONGPRODUCT"), TEXT("YES") );
         // MessageBox(NULL, "ISWRONGPRODUCT 2 set after searching PRODUCTMAJOR", "DEBUG", MB_OK);
         SetMsiErrorCode( MSI_ERROR_ISWRONGPRODUCT );
         return ERROR_SUCCESS;
@@ -165,7 +130,7 @@
 
     if ( szValue[0] )
     {
-        SetMsiProperty( handle, TEXT("ALLUSERS"), szValue );
+        MsiSetProperty( handle, TEXT("ALLUSERS"), szValue );
         // MessageBox(NULL, "ALLUSERS set", "DEBUG", MB_OK);
     }
 
diff --git a/setup_native/source/win32/customactions/reg4allmsdoc/reg4allmsi.cxx b/setup_native/source/win32/customactions/reg4allmsdoc/reg4allmsi.cxx
index a0f930a..4197053 100644
--- a/setup_native/source/win32/customactions/reg4allmsdoc/reg4allmsi.cxx
+++ b/setup_native/source/win32/customactions/reg4allmsdoc/reg4allmsi.cxx
@@ -22,7 +22,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -66,6 +66,9 @@
 static const int POWERPOINT_START = 15;
 static const int VISIO_START = 23;
 static const int VISIO_END = 25;
+const string PROP_OFF = "0";
+const string PROP_ON = "1";
+
 
 //    ".xlam",    // Office Excel 2007 XML macro-enabled add-in
 //    ".ppam",    // Office PowerPoint 2007 macro-enabled XML add-in
@@ -174,30 +177,6 @@
     }
 
     return rc;
-}
-
-bool GetMsiProp( MSIHANDLE handle, LPCSTR name, /*out*/std::string& value )
-{
-    DWORD sz = 0;
-    LPSTR dummy = "";
-    if (MsiGetPropertyA(handle, name, dummy, &sz) == ERROR_MORE_DATA)
-    {
-        sz++;
-        DWORD nbytes = sz * sizeof(TCHAR);
-        LPSTR buff = reinterpret_cast<LPSTR>(_alloca(nbytes));
-        ZeroMemory(buff, nbytes);
-        MsiGetPropertyA(handle, name, buff, &sz);
-        value = buff;
-        return true;
-    }
-    return false;
-}
-
-bool IsSetMsiProp( MSIHANDLE handle, LPCSTR name )
-{
-    std::string val;
-    GetMsiProp( handle, name, val );
-    return (val == "1");
 }
 
 static void registerForExtension( MSIHANDLE handle, const int nIndex, bool bRegister )
@@ -313,56 +292,16 @@
     bool bCalcEnabled = false;
     bool bImpressEnabled = false;
     bool bDrawEnabled = false;
-    bool bRegisterNone = IsSetMsiProp( handle, "REGISTER_NO_MSO_TYPES" );
-
-    if ( ( ERROR_SUCCESS == MsiGetFeatureState( handle, L"gm_p_Wrt", &current_state, &future_state ) ) &&
-         ( (future_state == INSTALLSTATE_LOCAL) || ((current_state == INSTALLSTATE_LOCAL) && (future_state == INSTALLSTATE_UNKNOWN) ) ) )
-        bWriterEnabled = true;
-
-    OutputDebugStringFormat( "LookForRegisteredExtensions: Install state Writer is [%d], will be [%d]", current_state, future_state );
-    if ( bWriterEnabled )
-        OutputDebugStringFormat( "LookForRegisteredExtensions: Writer is enabled" );
-    else
-        OutputDebugStringFormat( "LookForRegisteredExtensions: Writer is NOT enabled" );
-
-    if ( ( ERROR_SUCCESS == MsiGetFeatureState( handle, L"gm_p_Calc", &current_state, &future_state ) ) &&
-         ( (future_state == INSTALLSTATE_LOCAL) || ((current_state == INSTALLSTATE_LOCAL) && (future_state == INSTALLSTATE_UNKNOWN) ) ) )
-        bCalcEnabled = true;
-
-    OutputDebugStringFormat( "LookForRegisteredExtensions: Install state Calc is [%d], will be [%d]", current_state, future_state );
-    if ( bCalcEnabled )
-        OutputDebugStringFormat( "LookForRegisteredExtensions: Calc is enabled" );
-    else
-        OutputDebugStringFormat( "LookForRegisteredExtensions: Calc is NOT enabled" );
-
-    if ( ( ERROR_SUCCESS == MsiGetFeatureState( handle, L"gm_p_Impress", &current_state, &future_state ) ) &&
-         ( (future_state == INSTALLSTATE_LOCAL) || ((current_state == INSTALLSTATE_LOCAL) && (future_state == INSTALLSTATE_UNKNOWN) ) ) )
-        bImpressEnabled = true;
-
-    OutputDebugStringFormat( "LookForRegisteredExtensions: Install state Impress is [%d], will be [%d]", current_state, future_state );
-    if ( bImpressEnabled )
-        OutputDebugStringFormat( "LookForRegisteredExtensions: Impress is enabled" );
-    else
-        OutputDebugStringFormat( "LookForRegisteredExtensions: Impress is NOT enabled" );
-
-    if ( ( ERROR_SUCCESS == MsiGetFeatureState( handle, L"gm_p_Draw", &current_state, &future_state ) ) &&
-         ( (future_state == INSTALLSTATE_LOCAL) || ((current_state == INSTALLSTATE_LOCAL) && (future_state == INSTALLSTATE_UNKNOWN) ) ) )
-        bDrawEnabled = true;
-
-    OutputDebugStringFormat( "LookForRegisteredExtensions: Install state Draw is [%d], will be [%d]", current_state, future_state );
-    if ( bImpressEnabled )
-        OutputDebugStringFormat( "LookForRegisteredExtensions: Draw is enabled" );
-    else
-        OutputDebugStringFormat( "LookForRegisteredExtensions: Draw is NOT enabled" );
 
     MsiSetPropertyA( handle, "SELECT_WORD", "" );
     MsiSetPropertyA( handle, "SELECT_EXCEL", "" );
     MsiSetPropertyA( handle, "SELECT_POWERPOINT", "" );
     MsiSetPropertyA( handle, "SELECT_VISIO", "" );
 
-    if ( ! bRegisterNone )
+    if ( GetMsiPropValue( handle, TEXT("REGISTER_NO_MSO_TYPES") ).compare( PROP_OFF ) == 0 )
     {
-        if ( IsSetMsiProp( handle, "REGISTER_ALL_MSO_TYPES" ) )
+
+        if ( GetMsiPropValue( handle, TEXT("REGISTER_ALL_MSO_TYPES") ).compare( PROP_ON ) == 0 )
         {
             if ( bWriterEnabled )
                 MsiSetPropertyA( handle, "SELECT_WORD", "1" );
@@ -375,6 +314,47 @@
         }
         else
         {
+            if ( ( ERROR_SUCCESS == MsiGetFeatureState( handle, L"gm_p_Wrt", &current_state, &future_state ) ) &&
+                 ( (future_state == INSTALLSTATE_LOCAL) || ((current_state == INSTALLSTATE_LOCAL) && (future_state == INSTALLSTATE_UNKNOWN) ) ) )
+                bWriterEnabled = true;
+
+            OutputDebugStringFormat( "LookForRegisteredExtensions: Install state Writer is [%d], will be [%d]", current_state, future_state );
+            if ( bWriterEnabled )
+                OutputDebugStringFormat( "LookForRegisteredExtensions: Writer is enabled" );
+            else
+                OutputDebugStringFormat( "LookForRegisteredExtensions: Writer is NOT enabled" );
+
+            if ( ( ERROR_SUCCESS == MsiGetFeatureState( handle, L"gm_p_Calc", &current_state, &future_state ) ) &&
+                 ( (future_state == INSTALLSTATE_LOCAL) || ((current_state == INSTALLSTATE_LOCAL) && (future_state == INSTALLSTATE_UNKNOWN) ) ) )
+                bCalcEnabled = true;
+
+            OutputDebugStringFormat( "LookForRegisteredExtensions: Install state Calc is [%d], will be [%d]", current_state, future_state );
+            if ( bCalcEnabled )
+                OutputDebugStringFormat( "LookForRegisteredExtensions: Calc is enabled" );
+            else
+                OutputDebugStringFormat( "LookForRegisteredExtensions: Calc is NOT enabled" );
+
+            if ( ( ERROR_SUCCESS == MsiGetFeatureState( handle, L"gm_p_Impress", &current_state, &future_state ) ) &&
+                 ( (future_state == INSTALLSTATE_LOCAL) || ((current_state == INSTALLSTATE_LOCAL) && (future_state == INSTALLSTATE_UNKNOWN) ) ) )
+                bImpressEnabled = true;
+
+            OutputDebugStringFormat( "LookForRegisteredExtensions: Install state Impress is [%d], will be [%d]", current_state, future_state );
+            if ( bImpressEnabled )
+                OutputDebugStringFormat( "LookForRegisteredExtensions: Impress is enabled" );
+            else
+                OutputDebugStringFormat( "LookForRegisteredExtensions: Impress is NOT enabled" );
+
+            if ( ( ERROR_SUCCESS == MsiGetFeatureState( handle, L"gm_p_Draw", &current_state, &future_state ) ) &&
+                 ( (future_state == INSTALLSTATE_LOCAL) || ((current_state == INSTALLSTATE_LOCAL) && (future_state == INSTALLSTATE_UNKNOWN) ) ) )
+                bDrawEnabled = true;
+
+            OutputDebugStringFormat( "LookForRegisteredExtensions: Install state Draw is [%d], will be [%d]", current_state, future_state );
+            if ( bImpressEnabled )
+                OutputDebugStringFormat( "LookForRegisteredExtensions: Draw is enabled" );
+            else
+                OutputDebugStringFormat( "LookForRegisteredExtensions: Draw is NOT enabled" );
+
+
             if ( bWriterEnabled && ! checkSomeExtensionInRegistry( WORD_START, EXCEL_START ) )
             {
                 MsiSetPropertyA( handle, "SELECT_WORD", "1" );
@@ -390,7 +370,7 @@
                 MsiSetPropertyA( handle, "SELECT_POWERPOINT", "1" );
                 OutputDebugStringFormat( "LookForRegisteredExtensions: Register for Microsoft PowerPoint" );
             }
-            if ( bImpressEnabled && ! checkSomeExtensionInRegistry( VISIO_START, VISIO_END ) )
+            if ( bDrawEnabled && ! checkSomeExtensionInRegistry( VISIO_START, VISIO_END ) )
             {
                 MsiSetPropertyA( handle, "SELECT_VISIO", "1" );
                 OutputDebugStringFormat( "LookForRegisteredExtensions: Register for Microsoft Visio" );
@@ -407,7 +387,7 @@
 {
     OutputDebugStringFormat( "RegisterSomeExtensions: " );
 
-    if ( IsSetMsiProp( handle, "SELECT_WORD" ) )
+    if ( GetMsiPropValue( handle, TEXT("SELECT_WORD") ).compare( PROP_ON ) == 0 )
     {
         registerSomeExtensions( handle, WORD_START, EXCEL_START, true );
         MsiSetFeatureState( handle, L"gm_p_Wrt_MSO_Reg", INSTALLSTATE_LOCAL );
@@ -419,7 +399,7 @@
         MsiSetFeatureState( handle, L"gm_p_Wrt_MSO_Reg", INSTALLSTATE_ABSENT );
     }
 
-    if ( IsSetMsiProp( handle, "SELECT_EXCEL" ) )
+    if ( GetMsiPropValue( handle, TEXT("SELECT_EXCEL") ).compare( PROP_ON ) == 0 )
     {
         registerSomeExtensions( handle, EXCEL_START, POWERPOINT_START, true );
         MsiSetFeatureState( handle, L"gm_p_Calc_MSO_Reg", INSTALLSTATE_LOCAL );
@@ -431,7 +411,7 @@
         MsiSetFeatureState( handle, L"gm_p_Calc_MSO_Reg", INSTALLSTATE_ABSENT );
     }
 
-    if ( IsSetMsiProp( handle, "SELECT_POWERPOINT" ) )
+    if ( GetMsiPropValue( handle, TEXT("SELECT_POWERPOINT") ).compare( PROP_ON ) == 0 )
     {
         registerSomeExtensions( handle, POWERPOINT_START, VISIO_START, true );
         MsiSetFeatureState( handle, L"gm_p_Impress_MSO_Reg", INSTALLSTATE_LOCAL );
@@ -443,7 +423,7 @@
         MsiSetFeatureState( handle, L"gm_p_Impress_MSO_Reg", INSTALLSTATE_ABSENT );
     }
 
-    if ( IsSetMsiProp( handle, "SELECT_VISIO" ) )
+    if ( GetMsiPropValue( handle, TEXT("SELECT_VISIO") ).compare( PROP_ON ) == 0 )
     {
         registerSomeExtensions( handle, VISIO_START, VISIO_END, true );
         MsiSetFeatureState( handle, L"gm_p_Draw_MSO_Reg", INSTALLSTATE_LOCAL );
@@ -459,7 +439,7 @@
 
 extern "C" UINT __stdcall FindRegisteredExtensions( MSIHANDLE handle )
 {
-    if ( IsSetMsiProp( handle, "FILETYPEDIALOGUSED" ) )
+    if ( GetMsiPropValue( handle, TEXT("FILETYPEDIALOGUSED") ).compare( PROP_ON ) == 0 )
     {
         OutputDebugStringFormat( "FindRegisteredExtensions: FILETYPEDIALOGUSED!" );
         return ERROR_SUCCESS;
@@ -467,9 +447,9 @@
 
     OutputDebugStringFormat( "FindRegisteredExtensions:" );
 
-    bool bRegisterAll = IsSetMsiProp( handle, "REGISTER_ALL_MSO_TYPES" );
+    bool bRegisterAll = GetMsiPropValue( handle, TEXT("REGISTER_ALL_MSO_TYPES") ).compare( PROP_ON ) == 0;
 
-    if ( IsSetMsiProp( handle, "REGISTER_NO_MSO_TYPES" ) )
+    if ( GetMsiPropValue( handle, TEXT("REGISTER_NO_MSO_TYPES") ).compare( PROP_ON ) == 0 )
     {
         OutputDebugStringFormat( "FindRegisteredExtensions: Register none!" );
         return ERROR_SUCCESS;
@@ -481,13 +461,13 @@
 
     // setting the msi properties SELECT_* will force registering for all corresponding
     // file types
-    if ( IsSetMsiProp( handle, "SELECT_WORD" ) )
+    if ( GetMsiPropValue( handle, TEXT("SELECT_WORD") ).compare( PROP_ON ) == 0 )
         registerSomeExtensions( handle, WORD_START, EXCEL_START, true );
-    if ( IsSetMsiProp( handle, "SELECT_EXCEL" ) )
+    if ( GetMsiPropValue( handle, TEXT("SELECT_EXCEL") ).compare( PROP_ON ) == 0 )
         registerSomeExtensions( handle, EXCEL_START, POWERPOINT_START, true );
-    if ( IsSetMsiProp( handle, "SELECT_POWERPOINT" ) )
+    if ( GetMsiPropValue( handle, TEXT("SELECT_POWERPOINT") ).compare( PROP_ON ) == 0)
         registerSomeExtensions( handle, POWERPOINT_START, VISIO_START, true );
-    if ( IsSetMsiProp( handle, "SELECT_VISIO" ) )
+    if ( GetMsiPropValue( handle, TEXT("SELECT_VISIO") ).compare( PROP_ON ) == 0)
         registerSomeExtensions( handle, VISIO_START, VISIO_END, true );
 
     registerForExtensions( handle, bRegisterAll );
diff --git a/setup_native/source/win32/customactions/regactivex/regactivex.cxx b/setup_native/source/win32/customactions/regactivex/regactivex.cxx
index 7be03a2..4f16a9f 100644
--- a/setup_native/source/win32/customactions/regactivex/regactivex.cxx
+++ b/setup_native/source/win32/customactions/regactivex/regactivex.cxx
@@ -23,7 +23,7 @@
 #pragma warning(push, 1) /* disable warnings within system headers */
 #endif
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -122,29 +122,10 @@
 }
 
 //----------------------------------------------------------
-BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
-{
-    DWORD sz = 0;
-       if ( MsiGetProperty( hMSI, pPropName, L"", &sz ) == ERROR_MORE_DATA )
-       {
-           sz++;
-           DWORD nbytes = sz * sizeof( wchar_t );
-           wchar_t* buff = reinterpret_cast<wchar_t*>( malloc( nbytes ) );
-           ZeroMemory( buff, nbytes );
-           MsiGetProperty( hMSI, pPropName, buff, &sz );
-           *ppValue = buff;
-
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-//----------------------------------------------------------
 BOOL GetActiveXControlPath( MSIHANDLE hMSI, char** ppActiveXPath )
 {
     wchar_t* pProgPath = NULL;
-    if ( GetMsiProp( hMSI, L"INSTALLLOCATION", &pProgPath ) && pProgPath )
+    if ( GetMsiProp( hMSI, L"INSTALLLOCATION", &pProgPath ) )
        {
         char* pCharProgPath = UnicodeToAnsiString( pProgPath );
 
@@ -271,7 +252,7 @@
 {
     BOOL bResult = FALSE;
     wchar_t* pVal = NULL;
-    if ( GetMsiProp( hMSI, L"ALLUSERS", &pVal ) && pVal )
+    if ( GetMsiProp( hMSI, L"ALLUSERS", &pVal ) )
     {
         bResult = UnicodeEquals( pVal , L"1" );
         free( pVal );
@@ -285,7 +266,7 @@
 {
     BOOL bResult = FALSE;
     wchar_t* pVal = NULL;
-    if ( GetMsiProp( hMSI, L"VersionNT64", &pVal ) && pVal )
+    if ( GetMsiProp( hMSI, L"VersionNT64", &pVal ) )
     {
         bResult = TRUE;
         free( pVal );
diff --git a/setup_native/source/win32/customactions/regpatchactivex/regpatchactivex.cxx b/setup_native/source/win32/customactions/regpatchactivex/regpatchactivex.cxx
index 0c51ccb..2362c61 100644
--- a/setup_native/source/win32/customactions/regpatchactivex/regpatchactivex.cxx
+++ b/setup_native/source/win32/customactions/regpatchactivex/regpatchactivex.cxx
@@ -23,7 +23,7 @@
 #pragma warning(push,1) // disable warnings within system headers
 #endif
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -33,46 +33,13 @@
 #include <stdio.h>
 
 //----------------------------------------------------------
-BOOL UnicodeEquals( wchar_t* pStr1, wchar_t* pStr2 )
-{
-    if ( pStr1 == NULL && pStr2 == NULL )
-        return TRUE;
-    else if ( pStr1 == NULL || pStr2 == NULL )
-        return FALSE;
-
-    while( *pStr1 == *pStr2 && *pStr1 && *pStr2 )
-        pStr1++, pStr2++;
-
-    return ( *pStr1 == 0 && *pStr2 == 0 );
-}
-
-//----------------------------------------------------------
-BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
-{
-    DWORD sz = 0;
-       if ( MsiGetProperty( hMSI, pPropName, L"", &sz ) == ERROR_MORE_DATA )
-       {
-           sz++;
-           DWORD nbytes = sz * sizeof( wchar_t );
-           wchar_t* buff = reinterpret_cast<wchar_t*>( malloc( nbytes ) );
-           ZeroMemory( buff, nbytes );
-           MsiGetProperty( hMSI, pPropName, buff, &sz );
-           *ppValue = buff;
-
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-//----------------------------------------------------------
 BOOL MakeInstallForAllUsers( MSIHANDLE hMSI )
 {
     BOOL bResult = FALSE;
-    wchar_t* pVal = NULL;
-    if ( GetMsiProp( hMSI, L"ALLUSERS", &pVal ) && pVal )
+    LPTSTR* pVal = NULL;
+    if ( GetMsiProp( hMSI, TEXT("ALLUSERS"), pVal ) )
     {
-        bResult = UnicodeEquals( pVal , L"1" );
+        bResult = ( int (pVal) == 1 );
         free( pVal );
     }
 
diff --git a/setup_native/source/win32/customactions/sellang/sellang.cxx b/setup_native/source/win32/customactions/sellang/sellang.cxx
index b6f7ec5..893a04f 100644
--- a/setup_native/source/win32/customactions/sellang/sellang.cxx
+++ b/setup_native/source/win32/customactions/sellang/sellang.cxx
@@ -28,7 +28,7 @@
 #define WINVER 0x0500
 
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #include <malloc.h>
 
 #include <stdio.h>
@@ -39,21 +39,6 @@
 #include <systools/win32/uwinapi.h>
 
 #include "spellchecker_selection.hxx"
-
-BOOL GetMsiProp( MSIHANDLE hMSI, const char* pPropName, char** ppValue )
-{
-    DWORD sz = 0;
-    if ( MsiGetProperty( hMSI, pPropName, "", &sz ) == ERROR_MORE_DATA ) {
-        sz++;
-        DWORD nbytes = sz * sizeof( char );
-        char* buff = reinterpret_cast<char*>( malloc( nbytes ) );
-        ZeroMemory( buff, nbytes );
-        MsiGetProperty( hMSI, pPropName, buff, &sz );
-        *ppValue = buff;
-        return ( strlen(buff) > 0 );
-    }
-    return FALSE;
-}
 
 static const char *
 langid_to_string( LANGID langid )
@@ -314,8 +299,8 @@
     /* Keep track of what UI languages are relevant, either the ones explicitly
      * requested with the UI_LANGS property, or all available on the system:
      */
-    char* pVal = NULL;
-    if ( (GetMsiProp( handle, "UI_LANGS", &pVal )) && pVal ) {
+    LPTSTR pVal = NULL;
+    if ( (GetMsiProp( handle, "UI_LANGS", &pVal )) ) {
         char *str_ptr;
         str_ptr = strtok(pVal, ",");
         for(; str_ptr != NULL ;) {
diff --git a/setup_native/source/win32/customactions/shellextensions/checkdirectory.cxx b/setup_native/source/win32/customactions/shellextensions/checkdirectory.cxx
index 7b35b3c..60ed8b5 100644
--- a/setup_native/source/win32/customactions/shellextensions/checkdirectory.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/checkdirectory.cxx
@@ -24,7 +24,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -46,44 +46,17 @@
 #include <systools/win32/uwinapi.h>
 #include <../tools/seterror.hxx>
 
-static std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty )
-{
-    std::_tstring result;
-    TCHAR szDummy[1] = TEXT("");
-    DWORD nChars = 0;
-
-    if ( MsiGetProperty( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
-    {
-        DWORD nBytes = ++nChars * sizeof(TCHAR);
-        LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-        ZeroMemory( buffer, nBytes );
-        MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-        result = buffer;
-    }
-
-    return result;
-}
-
-static void UnsetMsiProperty(MSIHANDLE handle, const std::_tstring& sProperty)
-{
-    MsiSetProperty(handle, sProperty.c_str(), NULL);
-}
-
-static void SetMsiProperty(MSIHANDLE handle, const std::_tstring& sProperty, const std::_tstring&)
-{
-    MsiSetProperty(handle, sProperty.c_str(), TEXT("1"));
-}
 
 extern "C" UINT __stdcall CheckInstallDirectory(MSIHANDLE handle)
 {
-    std::_tstring sInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
-    std::_tstring sOfficeHostnamePath = GetMsiProperty(handle, TEXT("OFFICEDIRHOSTNAME"));
+    std::_tstring sInstallPath = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
+    std::_tstring sOfficeHostnamePath = GetMsiPropValue(handle, TEXT("OFFICEDIRHOSTNAME"));
 
     // MessageBox(NULL, sInstallPath.c_str(), "DEBUG", MB_OK);
 
     // unsetting all properties
 
-    UnsetMsiProperty( handle, TEXT("DIRECTORY_NOT_EMPTY") );
+    MsiSetProperty( handle, TEXT("DIRECTORY_NOT_EMPTY"), NULL );
 
     // 1. Searching for file setup.ini
 
@@ -98,7 +71,7 @@
     if ( IsValidHandle(hdl) )
     {
         // setup.ini found -> directory cannot be used for installation.
-        SetMsiProperty( handle, TEXT("DIRECTORY_NOT_EMPTY"), TEXT("1") );
+        MsiSetProperty( handle, TEXT("DIRECTORY_NOT_EMPTY"), TEXT("1") );
         SetMsiErrorCode( MSI_ERROR_DIRECTORY_NOT_EMPTY );
         // std::_tstring notEmptyStr = "Directory is not empty. Please choose another installation directory.";
         // std::_tstring notEmptyTitle = "Directory not empty";
diff --git a/setup_native/source/win32/customactions/shellextensions/checkpatches.cxx b/setup_native/source/win32/customactions/shellextensions/checkpatches.cxx
index 94a24cd..99fb240 100644
--- a/setup_native/source/win32/customactions/shellextensions/checkpatches.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/checkpatches.cxx
@@ -24,7 +24,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -63,44 +63,24 @@
 }
 #endif
 
-static std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty )
-{
-    std::_tstring result;
-    TCHAR szDummy[1] = TEXT("");
-    DWORD nChars = 0;
-
-    if ( MsiGetProperty( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
-    {
-        DWORD nBytes = ++nChars * sizeof(TCHAR);
-        LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-        ZeroMemory( buffer, nBytes );
-        MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-        result = buffer;
-    }
-
-    return result;
-}
-
-static void SetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty )
-{
-    MsiSetProperty( handle, sProperty.c_str(), TEXT("1") );
-}
-
 extern "C" UINT __stdcall CheckPatchList( MSIHANDLE handle )
 {
-    std::_tstring sPatchList = GetMsiProperty( handle, TEXT("PATCH") );
-    std::_tstring sRequiredPatch = GetMsiProperty( handle, TEXT("PREREQUIREDPATCH") );
+    LPTSTR sPatchList = NULL;
+    LPTSTR sRequiredPatch = NULL;
 
-    OutputDebugStringFormat( "CheckPatchList called with PATCH=%s and PRQ= %s\n", sPatchList.c_str(), sRequiredPatch.c_str() );
-
-    if ( ( sPatchList.length() != 0 ) && ( sRequiredPatch.length() != 0 ) )
+    if ( GetMsiProp( handle, TEXT("PATCH"), &sPatchList ) && GetMsiProp( handle, TEXT("PREREQUIREDPATCH"), &sRequiredPatch ) )
     {
-        if ( _tcsstr( sPatchList.c_str(), sRequiredPatch.c_str() ) )
+        OutputDebugStringFormat( "CheckPatchList called with PATCH=%s and PRQ= %s\n", sPatchList, sRequiredPatch );
+        if ( _tcsstr( sPatchList, sRequiredPatch ) )
         {
-            SetMsiProperty( handle, TEXT("IGNOREPREREQUIREDPATCH") );
+            MsiSetProperty( handle, TEXT("IGNOREPREREQUIREDPATCH"), TEXT("1") );
             OutputDebugStringFormat( "Set Property IgnorePrerequiredPatch!\n" );
         }
     }
+    else
+    {
+        OutputDebugStringFormat( "CheckPatchList called with PATCH=%s and PRQ= %s\n", sPatchList, sRequiredPatch );
+    }
     return ERROR_SUCCESS;
 }
 
diff --git a/setup_native/source/win32/customactions/shellextensions/completeinstallpath.cxx b/setup_native/source/win32/customactions/shellextensions/completeinstallpath.cxx
index d56ad5e..5f684c1 100644
--- a/setup_native/source/win32/customactions/shellextensions/completeinstallpath.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/completeinstallpath.cxx
@@ -23,7 +23,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -41,27 +41,6 @@
 
 using namespace std;
 
-namespace
-{
-    std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty )
-    {
-        std::_tstring   result;
-        TCHAR   szDummy[1] = TEXT("");
-        DWORD   nChars = 0;
-
-        if ( MsiGetProperty( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
-        {
-            DWORD nBytes = ++nChars * sizeof(TCHAR);
-            LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-            ZeroMemory( buffer, nBytes );
-            MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-            result = buffer;
-        }
-
-        return  result;
-    }
-} // namespace
-
 extern "C" UINT __stdcall CompleteInstallPath( MSIHANDLE handle )
 {
     // This CustomAction is necessary for updates from OOo 3.0, OOo 3.1 and OOo 3.2 to versions
@@ -76,8 +55,8 @@
     // Reading property OFFICEDIRHOSTNAME_, that contains the part of the path behind
     // the program files folder.
 
-    std::_tstring   sInstallLocation = GetMsiProperty( handle, TEXT("INSTALLLOCATION") );
-    std::_tstring   sOfficeDirHostname = GetMsiProperty( handle, TEXT("OFFICEDIRHOSTNAME_") );
+    std::_tstring   sInstallLocation = GetMsiPropValue( handle, TEXT("INSTALLLOCATION") );
+    std::_tstring   sOfficeDirHostname = GetMsiPropValue( handle, TEXT("OFFICEDIRHOSTNAME_") );
 
     // If sInstallLocation ends with (contains) the string sOfficeDirHostname,
     // INSTALLLOCATION is good and nothing has to be done here.
@@ -94,9 +73,9 @@
 
     if ( pathCompletionRequired )
     {
-        std::_tstring   sManufacturer = GetMsiProperty( handle, TEXT("Manufacturer") );
-        std::_tstring   sDefinedName = GetMsiProperty( handle, TEXT("DEFINEDPRODUCT") );
-        std::_tstring   sUpgradeCode = GetMsiProperty( handle, TEXT("UpgradeCode") );
+        std::_tstring   sManufacturer = GetMsiPropValue( handle, TEXT("Manufacturer") );
+        std::_tstring   sDefinedName = GetMsiPropValue( handle, TEXT("DEFINEDPRODUCT") );
+        std::_tstring   sUpgradeCode = GetMsiPropValue( handle, TEXT("UpgradeCode") );
 
         // sUpdateVersion can be "3.0", "3.1" or "3.2"
 
diff --git a/setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx b/setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx
index 1a52dad..758d9d9 100644
--- a/setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx
@@ -28,7 +28,7 @@
 #define WIN32_LEAN_AND_MEAN
 #endif
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #include <shellapi.h>
 #ifdef _MSC_VER
 #pragma warning(pop)
@@ -48,27 +48,9 @@
 #include <string>
 
 
-static std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty )
-{
-    std::_tstring result;
-    TCHAR szDummy[1] = TEXT("");
-    DWORD nChars = 0;
-
-    if ( MsiGetProperty( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
-    {
-        DWORD nBytes = ++nChars * sizeof(TCHAR);
-        LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-        ZeroMemory( buffer, nBytes );
-        MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-        result = buffer;
-    }
-
-    return result;
-}
-
 extern "C" UINT __stdcall copyExtensionData(MSIHANDLE handle) {
 
-    std::_tstring sSourceDir = GetMsiProperty( handle, TEXT("SourceDir") );
+    std::_tstring sSourceDir = GetMsiPropValue( handle, TEXT("SourceDir") );
     std::_tstring sExtensionDir = sSourceDir + TEXT("extension\\");
     std::_tstring sPattern = sExtensionDir + TEXT("*.oxt");
 
@@ -83,7 +65,7 @@
         bool fNextFile = false;
         bool bFailIfExist = true;
 
-        std::_tstring sDestDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") );
+        std::_tstring sDestDir = GetMsiPropValue( handle, TEXT("INSTALLLOCATION") );
         std::_tstring sShareInstallDir = sDestDir + TEXT("share\\extension\\install\\");
 
         // creating directories
diff --git a/setup_native/source/win32/customactions/shellextensions/dotnetcheck.cxx b/setup_native/source/win32/customactions/shellextensions/dotnetcheck.cxx
index 864b886..42f7f09 100644
--- a/setup_native/source/win32/customactions/shellextensions/dotnetcheck.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/dotnetcheck.cxx
@@ -27,7 +27,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -45,28 +45,6 @@
 
 namespace
 {
-    string GetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        string  result;
-        TCHAR   szDummy[1] = TEXT("");
-        DWORD   nChars = 0;
-
-        if (MsiGetProperty(handle, sProperty.c_str(), szDummy, &nChars) == ERROR_MORE_DATA)
-        {
-            DWORD nBytes = ++nChars * sizeof(TCHAR);
-            LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-            ZeroMemory( buffer, nBytes );
-            MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-            result = buffer;
-        }
-        return result;
-    }
-
-    inline void SetMsiProperty(MSIHANDLE handle, const string& sProperty, const string& sValue)
-    {
-        MsiSetProperty(handle, sProperty.c_str(), sValue.c_str());
-    }
-
     void stripFinalBackslash(std::string * path) {
         std::string::size_type i = path->size();
         if (i > 1) {
@@ -126,20 +104,20 @@
 } // namespace
 
 extern "C" UINT __stdcall DotNetCheck(MSIHANDLE handle) {
-    string present(GetMsiProperty(handle, TEXT("MsiNetAssemblySupport")));
-    string required(GetMsiProperty(handle, TEXT("REQUIRED_DOTNET_VERSION")));
+    string present(GetMsiPropValue(handle, TEXT("MsiNetAssemblySupport")));
+    string required(GetMsiPropValue(handle, TEXT("REQUIRED_DOTNET_VERSION")));
 
     // string myText1 = TEXT("MsiNetAssemblySupport: ") + present;
     // string myText2 = TEXT("REQUIRED_DOTNET_VERSION: ") + required;
     // MessageBox(NULL, myText1.c_str(), "DEBUG", MB_OK);
     // MessageBox(NULL, myText2.c_str(), "DEBUG", MB_OK);
 
-    SetMsiProperty(
+    MsiSetProperty(
         handle, TEXT("DOTNET_SUFFICIENT"),
         (present.empty() || compareVersions(present, required) == ORDER_LESS ?
          TEXT("0") : TEXT("1")));
 
-    // string result(GetMsiProperty(handle, TEXT("DOTNET_SUFFICIENT")));
+    // string result(GetMsiPropValue(handle, TEXT("DOTNET_SUFFICIENT")));
     // string myText3 = TEXT("DOTNET_SUFFICIENT: ") + result;
     // MessageBox(NULL, myText3.c_str(), "DEBUG", MB_OK);
 
@@ -149,23 +127,23 @@
 
 extern "C" UINT __stdcall ShowProperties(MSIHANDLE handle)
 {
-    string property = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
+    string property = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
     string myText = TEXT("INSTALLLOCATION: ") + property;
     MessageBox(NULL, myText.c_str(), "INSTALLLOCATION", MB_OK);
 
-    property = GetMsiProperty(handle, TEXT("Installed"));
+    property = GetMsiPropValue(handle, TEXT("Installed"));
     myText = TEXT("Installed: ") + property;
     MessageBox(NULL, myText.c_str(), "Installed", MB_OK);
 
-    property = GetMsiProperty(handle, TEXT("PATCH"));
+    property = GetMsiPropValue(handle, TEXT("PATCH"));
     myText = TEXT("PATCH: ") + property;
     MessageBox(NULL, myText.c_str(), "PATCH", MB_OK);
 
-    property = GetMsiProperty(handle, TEXT("REMOVE"));
+    property = GetMsiPropValue(handle, TEXT("REMOVE"));
     myText = TEXT("REMOVE: ") + property;
     MessageBox(NULL, myText.c_str(), "REMOVE", MB_OK);
 
-    property = GetMsiProperty(handle, TEXT("ALLUSERS"));
+    property = GetMsiPropValue(handle, TEXT("ALLUSERS"));
     myText = TEXT("ALLUSERS: ") + property;
     MessageBox(NULL, myText.c_str(), "ALLUSERS", MB_OK);
 
diff --git a/setup_native/source/win32/customactions/shellextensions/layerlinks.cxx b/setup_native/source/win32/customactions/shellextensions/layerlinks.cxx
index 88e020f..67919ec 100644
--- a/setup_native/source/win32/customactions/shellextensions/layerlinks.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/layerlinks.cxx
@@ -27,7 +27,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -45,38 +45,6 @@
 
 namespace
 {
-    string GetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        string  result;
-        TCHAR   szDummy[1] = TEXT("");
-        DWORD   nChars = 0;
-
-        if (MsiGetProperty(handle, sProperty.c_str(), szDummy, &nChars) == ERROR_MORE_DATA)
-        {
-            DWORD nBytes = ++nChars * sizeof(TCHAR);
-            LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-            ZeroMemory( buffer, nBytes );
-            MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-            result = buffer;
-        }
-        return result;
-    }
-
-    inline bool IsSetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        return (GetMsiProperty(handle, sProperty).length() > 0);
-    }
-
-    inline void UnsetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        MsiSetProperty(handle, sProperty.c_str(), NULL);
-    }
-
-    inline void SetMsiProperty(MSIHANDLE handle, const string& sProperty, const string&)
-    {
-        MsiSetProperty(handle, sProperty.c_str(), TEXT("1"));
-    }
-
     void stripFinalBackslash(std::string * path) {
         std::string::size_type i = path->size();
         if (i > 1) {
@@ -90,13 +58,13 @@
 
 extern "C" UINT __stdcall CreateLayerLinks(MSIHANDLE handle)
 {
-    string sInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
+    string sInstallPath = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
 
     string sUreInstallPath = sInstallPath + TEXT("URE");
 
     string sUreLinkPath = sInstallPath + TEXT("ure-link");
 
-    if ( IsSetMsiProperty(handle, TEXT("ADMININSTALL")) )
+    if ( GetMsiPropValue(handle, TEXT("ADMININSTALL")).length() > 0 )
     {
         sUreInstallPath = TEXT("..\\URE");
     }
@@ -149,7 +117,7 @@
 
 extern "C" UINT __stdcall RemoveLayerLinks(MSIHANDLE handle)
 {
-    string sInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
+    string sInstallPath = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
 
     string sUreLinkPath = sInstallPath + TEXT("ure-link");
     string sUreDirName = sInstallPath + TEXT("URE\\bin");
diff --git a/setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx b/setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx
index 1b159fd..476d235 100644
--- a/setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/migrateinstallpath.cxx
@@ -23,7 +23,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -41,27 +41,6 @@
 
 using namespace std;
 
-namespace
-{
-    std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty )
-    {
-        std::_tstring   result;
-        TCHAR   szDummy[1] = TEXT("");
-        DWORD   nChars = 0;
-
-        if ( MsiGetProperty( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
-        {
-            DWORD nBytes = ++nChars * sizeof(TCHAR);
-            LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-            ZeroMemory( buffer, nBytes );
-            MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-            result = buffer;
-        }
-
-        return  result;
-    }
-} // namespace
-
 extern "C" UINT __stdcall MigrateInstallPath( MSIHANDLE handle )
 {
     TCHAR   szValue[8192];
@@ -69,10 +48,10 @@
     HKEY    hKey;
     std::_tstring   sInstDir;
 
-    std::_tstring   sManufacturer = GetMsiProperty( handle, TEXT("Manufacturer") );
-    std::_tstring   sDefinedName = GetMsiProperty( handle, TEXT("DEFINEDPRODUCT") );
-    std::_tstring   sUpdateVersion = GetMsiProperty( handle, TEXT("DEFINEDVERSION") );
-    std::_tstring   sUpgradeCode = GetMsiProperty( handle, TEXT("UpgradeCode") );
+    std::_tstring   sManufacturer = GetMsiPropValue( handle, TEXT("Manufacturer") );
+    std::_tstring   sDefinedName = GetMsiPropValue( handle, TEXT("DEFINEDPRODUCT") );
+    std::_tstring   sUpdateVersion = GetMsiPropValue( handle, TEXT("DEFINEDVERSION") );
+    std::_tstring   sUpgradeCode = GetMsiPropValue( handle, TEXT("UpgradeCode") );
 
     std::_tstring   sProductKey = "Software\\" + sManufacturer + "\\" + sDefinedName +
                                         "\\" + sUpdateVersion + "\\" + sUpgradeCode;
diff --git a/setup_native/source/win32/customactions/shellextensions/postuninstall.cxx b/setup_native/source/win32/customactions/shellextensions/postuninstall.cxx
index 2ae1769..b8f6e66 100644
--- a/setup_native/source/win32/customactions/shellextensions/postuninstall.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/postuninstall.cxx
@@ -23,7 +23,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -40,25 +40,6 @@
 #include <string>
 
 #include <io.h>
-
-static std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty )
-{
-    std::_tstring   result;
-    TCHAR   szDummy[1] = TEXT("");
-    DWORD   nChars = 0;
-
-    if ( MsiGetProperty( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
-    {
-        DWORD nBytes = ++nChars * sizeof(TCHAR);
-        LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-        ZeroMemory( buffer, nBytes );
-        MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-        result = buffer;
-    }
-
-    return  result;
-}
-
 
 static BOOL ExecuteCommand( LPCTSTR lpCommand, BOOL bSync )
 {
@@ -101,7 +82,7 @@
     HKEY    hKey;
     std::_tstring   sInstDir;
 
-    std::_tstring   sProductKey = GetMsiProperty( handle, TEXT("FINDPRODUCT") );
+    std::_tstring   sProductKey = GetMsiPropValue( handle, TEXT("FINDPRODUCT") );
 
     // MessageBox( NULL, sProductKey.c_str(), "Titel", MB_OK );
 
diff --git a/setup_native/source/win32/customactions/shellextensions/setadmininstall.cxx b/setup_native/source/win32/customactions/shellextensions/setadmininstall.cxx
index bc010c6..d1b7b9b 100644
--- a/setup_native/source/win32/customactions/shellextensions/setadmininstall.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/setadmininstall.cxx
@@ -24,7 +24,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -53,7 +53,7 @@
 
 extern "C" UINT __stdcall SetAdminInstallProperty(MSIHANDLE handle)
 {
-    SetMsiProperty(handle, TEXT("ADMININSTALL"));
+    MsiSetProperty(handle, TEXT("ADMININSTALL"), TEXT("1"));
     return ERROR_SUCCESS;
 }
 
diff --git a/setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx b/setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx
index de3f3f6..92ad25c 100644
--- a/setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx
@@ -24,40 +24,15 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
 
 #include <malloc.h>
-
-#ifdef UNICODE
-#define _UNICODE
-#define _tstring    wstring
-#else
-#define _tstring    string
-#endif
 #include <tchar.h>
 #include <string>
 
-
-std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty )
-{
-    std::_tstring   result;
-    TCHAR   szDummy[1] = TEXT("");
-    DWORD   nChars = 0;
-
-    if ( MsiGetProperty( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
-    {
-        DWORD nBytes = ++nChars * sizeof(TCHAR);
-        LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-        ZeroMemory( buffer, nBytes );
-        MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-        result = buffer;
-    }
-
-    return  result;
-}
 
 /*
     Called during installation to customize the start menu folder icon.
@@ -65,9 +40,9 @@
 */
 extern "C" UINT __stdcall InstallStartmenuFolderIcon( MSIHANDLE handle )
 {
-    std::_tstring   sOfficeMenuFolder = GetMsiProperty( handle, TEXT("OfficeMenuFolder") );
-    std::_tstring sDesktopFile = sOfficeMenuFolder + TEXT("Desktop.ini");
-    std::_tstring   sIconFile = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ) + TEXT("program\\soffice.exe");
+    std::string   sOfficeMenuFolder = GetMsiPropValue( handle, TEXT("OfficeMenuFolder") );
+    std::string   sDesktopFile = sOfficeMenuFolder + TEXT("Desktop.ini");
+    std::string   sIconFile = GetMsiPropValue( handle, TEXT("INSTALLLOCATION") ) + TEXT("program\\soffice.exe");
 
     OSVERSIONINFO   osverinfo;
     osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
@@ -109,8 +84,8 @@
 
 extern "C" UINT __stdcall DeinstallStartmenuFolderIcon(MSIHANDLE handle)
 {
-    std::_tstring   sOfficeMenuFolder = GetMsiProperty( handle, TEXT("OfficeMenuFolder") );
-    std::_tstring sDesktopFile = sOfficeMenuFolder + TEXT("Desktop.ini");
+    std::string   sOfficeMenuFolder = GetMsiPropValue( handle, TEXT("OfficeMenuFolder") );
+    std::string sDesktopFile = sOfficeMenuFolder + TEXT("Desktop.ini");
 
     SetFileAttributes( sDesktopFile.c_str(), FILE_ATTRIBUTE_NORMAL );
     DeleteFile( sDesktopFile.c_str() );
diff --git a/setup_native/source/win32/customactions/shellextensions/upgrade.cxx b/setup_native/source/win32/customactions/shellextensions/upgrade.cxx
index 9a54963..92e33c7 100644
--- a/setup_native/source/win32/customactions/shellextensions/upgrade.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/upgrade.cxx
@@ -27,7 +27,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -111,38 +111,6 @@
         return convertedGuid;
     }
 
-    string GetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        string  result;
-        TCHAR   szDummy[1] = TEXT("");
-        DWORD   nChars = 0;
-
-        if (MsiGetProperty(handle, sProperty.c_str(), szDummy, &nChars) == ERROR_MORE_DATA)
-        {
-            DWORD nBytes = ++nChars * sizeof(TCHAR);
-            LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-            ZeroMemory( buffer, nBytes );
-            MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-            result = buffer;
-        }
-        return  result;
-    }
-
-    inline bool IsSetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        return (GetMsiProperty(handle, sProperty).length() > 0);
-    }
-
-    inline void UnsetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        MsiSetProperty(handle, sProperty.c_str(), NULL);
-    }
-
-    inline void SetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        MsiSetProperty(handle, sProperty.c_str(), TEXT("1"));
-    }
-
     bool RegistryKeyHasUpgradeSubKey(
         HKEY hRootKey, const string& regKey, const string& upgradeKey)
     {
@@ -171,7 +139,7 @@
 
 extern "C" UINT __stdcall SetProductInstallMode(MSIHANDLE handle)
 {
-    string upgradeCode = GetMsiProperty(handle, TEXT("UpgradeCode"));
+    string upgradeCode = GetMsiPropValue(handle, TEXT("UpgradeCode"));
     upgradeCode = ConvertGuid(string(upgradeCode.c_str() + 1, upgradeCode.length() - 2));
 
     //MessageBox(NULL, upgradeCode.c_str(), TEXT("Debug"), MB_OK);
@@ -179,17 +147,17 @@
     if (RegistryKeyHasUpgradeSubKey(
         HKEY_CURRENT_USER,
         TEXT("Software\\Microsoft\\Installer\\UpgradeCodes"),
-        upgradeCode) && IsSetMsiProperty(handle, TEXT("ALLUSERS")))
+        upgradeCode))
     {
-        UnsetMsiProperty(handle, TEXT("ALLUSERS"));
+        MsiSetProperty(handle, TEXT("ALLUSERS"), NULL);
         //MessageBox(NULL, "ALLUSERS removed", "DEBUG", MB_OK);
     }
     else if (RegistryKeyHasUpgradeSubKey(
              HKEY_LOCAL_MACHINE,
              TEXT("Software\\Classes\\Installer\\UpgradeCodes"),
-             upgradeCode) && !IsSetMsiProperty(handle, TEXT("ALLUSERS")))
+             upgradeCode))
     {
-        SetMsiProperty(handle, TEXT("ALLUSERS"));
+        MsiSetProperty(handle, TEXT("ALLUSERS"), TEXT("1"));
         //MessageBox(NULL, "ALLUSERS set", "DEBUG", MB_OK);
     }
     return ERROR_SUCCESS;
diff --git a/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx b/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx
index 7011fcd..862c7a3 100644
--- a/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx
@@ -24,7 +24,7 @@
 #endif
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -65,25 +65,7 @@
 #endif
 
 
-static std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty )
-{
-    std::_tstring result;
-    TCHAR szDummy[1] = TEXT("");
-    DWORD nChars = 0;
-
-    if ( MsiGetProperty( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
-    {
-        DWORD nBytes = ++nChars * sizeof(TCHAR);
-        LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-        ZeroMemory( buffer, nBytes );
-        MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-        result = buffer;
-    }
-
-    return result;
-}
-
-static BOOL RemoveCompleteDirectory( std::_tstring sPath )
+static bool RemoveCompleteDirectory( std::_tstring sPath )
 {
     bool bDirectoryRemoved = true;
 
@@ -143,7 +125,7 @@
 
 extern "C" UINT __stdcall RenamePrgFolder( MSIHANDLE handle )
 {
-    std::_tstring sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
+    std::_tstring sOfficeInstallPath = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
 
     std::_tstring sRenameSrc = sOfficeInstallPath + TEXT("program");
     std::_tstring sRenameDst = sOfficeInstallPath + TEXT("program_old");
@@ -167,7 +149,7 @@
 
 extern "C" UINT __stdcall RemovePrgFolder( MSIHANDLE handle )
 {
-    std::_tstring sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
+    std::_tstring sOfficeInstallPath = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
     std::_tstring sRemoveDir = sOfficeInstallPath + TEXT("program_old");
 
     RemoveCompleteDirectory( sRemoveDir );
diff --git a/setup_native/source/win32/customactions/thesaurus/thesaurus.cxx b/setup_native/source/win32/customactions/thesaurus/thesaurus.cxx
index 349ed75..a27801c 100644
--- a/setup_native/source/win32/customactions/thesaurus/thesaurus.cxx
+++ b/setup_native/source/win32/customactions/thesaurus/thesaurus.cxx
@@ -23,7 +23,7 @@
 #define WINVER 0x0500
 
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #include <malloc.h>
 
 #include <stdio.h>
@@ -42,38 +42,6 @@
 using namespace std;
 namespace
 {
-
-    string GetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        string  result;
-        TCHAR   szDummy[1] = TEXT("");
-        DWORD   nChars = 0;
-
-        if (MsiGetProperty(handle, sProperty.c_str(), szDummy, &nChars) == ERROR_MORE_DATA)
-        {
-            DWORD nBytes = ++nChars * sizeof(TCHAR);
-            LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
-            ZeroMemory( buffer, nBytes );
-            MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
-            result = buffer;
-        }
-        return result;
-    }
-
-    inline bool IsSetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        return (GetMsiProperty(handle, sProperty).length() > 0);
-    }
-
-    inline void UnsetMsiProperty(MSIHANDLE handle, const string& sProperty)
-    {
-        MsiSetProperty(handle, sProperty.c_str(), NULL);
-    }
-
-    inline void SetMsiProperty(MSIHANDLE handle, const string& sProperty, const string&)
-    {
-        MsiSetProperty(handle, sProperty.c_str(), TEXT("1"));
-    }
 
     static const int MAXLINE = 1024*64;
 
@@ -193,7 +161,7 @@
 extern "C" UINT __stdcall CreateIndexes( MSIHANDLE handle )
 {
 
-    string sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
+    string sOfficeInstallPath = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
     createIndexesForThesaurusFiles(sOfficeInstallPath);
     return ERROR_SUCCESS;
 }
diff --git a/setup_native/source/win32/customactions/tools/checkversion.cxx b/setup_native/source/win32/customactions/tools/checkversion.cxx
index dc42bfa..0484488 100644
--- a/setup_native/source/win32/customactions/tools/checkversion.cxx
+++ b/setup_native/source/win32/customactions/tools/checkversion.cxx
@@ -23,7 +23,7 @@
 #pragma warning(push,1) // disable warnings within system headers
 #endif
 #include <windows.h>
-#include <msiquery.h>
+#include <../tools/msiprop.hxx>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -34,25 +34,6 @@
 #include "strsafe.h"
 
 #include <seterror.hxx>
-
-//----------------------------------------------------------
-BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
-{
-    DWORD sz = 0;
-       if ( MsiGetProperty( hMSI, pPropName, L"", &sz ) == ERROR_MORE_DATA )
-       {
-           sz++;
-           DWORD nbytes = sz * sizeof( wchar_t );
-           wchar_t* buff = reinterpret_cast<wchar_t*>( malloc( nbytes ) );
-           ZeroMemory( buff, nbytes );
-           MsiGetProperty( hMSI, pPropName, buff, &sz );
-           *ppValue = buff;
-
-        return TRUE;
-    }
-
-    return FALSE;
-}
 
 //----------------------------------------------------------
 #ifdef DEBUG
@@ -78,7 +59,7 @@
 
     wchar_t* pVal = NULL;
 
-    if ( GetMsiProp( hMSI, L"NEWPRODUCTS", &pVal ) && pVal )
+    if ( GetMsiProp( hMSI, L"NEWPRODUCTS", &pVal ) )
     {
         OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTS found [%s]"), pVal );
         if ( *pVal != 0 )
@@ -86,7 +67,7 @@
         free( pVal );
     }
     pVal = NULL;
-    if ( GetMsiProp( hMSI, L"SAMEPRODUCTS", &pVal ) && pVal )
+    if ( GetMsiProp( hMSI, L"SAMEPRODUCTS", &pVal ) )
     {
         OutputDebugStringFormat( TEXT("DEBUG: SAMEPRODUCTS found [%s]"), pVal );
         if ( *pVal != 0 )
@@ -94,7 +75,7 @@
         free( pVal );
     }
     pVal = NULL;
-    if ( GetMsiProp( hMSI, L"OLDPRODUCTS", &pVal ) && pVal )
+    if ( GetMsiProp( hMSI, L"OLDPRODUCTS", &pVal ) )
     {
         OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTS found [%s]"), pVal );
         if ( *pVal != 0 )
@@ -102,7 +83,7 @@
         free( pVal );
     }
     pVal = NULL;
-    if ( GetMsiProp( hMSI, L"BETAPRODUCTS", &pVal ) && pVal )
+    if ( GetMsiProp( hMSI, L"BETAPRODUCTS", &pVal ) )
     {
         OutputDebugStringFormat( TEXT("DEBUG: BETAPRODUCTS found [%s]"), pVal );
         if ( *pVal != 0 )
@@ -111,7 +92,7 @@
     }
 
     pVal = NULL;
-    if ( GetMsiProp( hMSI, L"NEWPRODUCTSPATCH", &pVal ) && pVal )
+    if ( GetMsiProp( hMSI, L"NEWPRODUCTSPATCH", &pVal ) )
     {
         OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTSPATCH found [%s]"), pVal );
         if ( *pVal != 0 )
@@ -119,7 +100,7 @@
         free( pVal );
     }
     pVal = NULL;
-    if ( GetMsiProp( hMSI, L"SAMEPRODUCTSPATCH", &pVal ) && pVal )
+    if ( GetMsiProp( hMSI, L"SAMEPRODUCTSPATCH", &pVal ) )
     {
         OutputDebugStringFormat( TEXT("DEBUG: SAMEPRODUCTSPATCH found [%s]"), pVal );
         if ( *pVal != 0 )
@@ -127,7 +108,7 @@
         free( pVal );
     }
     pVal = NULL;
-    if ( GetMsiProp( hMSI, L"OLDPRODUCTSPATCH", &pVal ) && pVal )
+    if ( GetMsiProp( hMSI, L"OLDPRODUCTSPATCH", &pVal ) )
     {
         OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTSPATCH found [%s]"), pVal );
         if ( *pVal != 0 )
diff --git a/setup_native/source/win32/customactions/tools/msiprop.hxx b/setup_native/source/win32/customactions/tools/msiprop.hxx
new file mode 100755
index 0000000..5d75130
--- /dev/null
+++ b/setup_native/source/win32/customactions/tools/msiprop.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+#include <windows.h>
+#include <string>
+//#include <malloc.h>
+#include <msiquery.h>
+#ifdef UNICODE
+#define _UNICODE
+#define _tstring    wstring
+#else
+#define _tstring    string
+#endif
+
+using namespace std;
+
+namespace {
+inline bool GetMsiProp(MSIHANDLE hMSI, LPCTSTR pPropName, LPTSTR* ppValue)
+{
+    DWORD sz = 0;
+    ppValue = NULL;
+    if (MsiGetProperty(hMSI, pPropName, TEXT(""), &sz) == ERROR_MORE_DATA)
+    {
+        DWORD nBytes = ++sz * sizeof(TCHAR); // add 1 for null termination
+        LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca( nBytes ));
+        ZeroMemory(buffer, nBytes);
+        MsiGetProperty(hMSI, pPropName, buffer, &sz);
+        *ppValue = buffer;
+    }
+
+    return ppValue?true:false ;
+
+}
+
+//std::_tstring GMPV(  ,  const std::_tstring& sProperty)
+inline string GetMsiPropValue(MSIHANDLE hMSI, LPCTSTR pPropName)
+{
+    LPTSTR ppValue = NULL;
+    (void)GetMsiProp(hMSI, pPropName, &ppValue);
+    string toto =  reinterpret_cast<const char *> (ppValue);
+    return toto;
+}
+
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file

-- 
To view, visit https://gerrit.libreoffice.org/1816
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1cd082361126db3d9aced3a878b19e7052514864
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Mathias M <matm at gmx.fr>



More information about the LibreOffice mailing list