Kaydet (Commit) 55fc2b96 authored tarafından Andras Timar's avatar Andras Timar

Revert "fix for fdo#39632 : Consolidate GetMsiProperty()"

This reverts commit 95ee7d9c.
üst 2d70b928
......@@ -27,7 +27,7 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -44,18 +44,53 @@
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 = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
string sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
// MessageBox(NULL, sOfficeInstallPath.c_str(), "DEBUG", MB_OK);
// unsetting all properties
MsiSetProperty( handle, TEXT("INVALIDDIRECTORY"), NULL );
MsiSetProperty( handle, TEXT("ISWRONGPRODUCT"), NULL );
MsiSetProperty( handle, TEXT("PATCHISOLDER"), NULL );
MsiSetProperty( handle, TEXT("ALLUSERS"), NULL );
UnsetMsiProperty( handle, TEXT("INVALIDDIRECTORY") );
UnsetMsiProperty( handle, TEXT("ISWRONGPRODUCT") );
UnsetMsiProperty( handle, TEXT("PATCHISOLDER") );
UnsetMsiProperty( handle, TEXT("ALLUSERS") );
// 1. Searching for "ProductCode" in setup.ini
......@@ -75,7 +110,7 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
if ( !_tcsicmp( szValue, TEXT("INVALIDDIRECTORY") ) )
{
// No setup.ini or no "ProductCode" in setup.ini. This is an invalid directory.
MsiSetProperty( handle, TEXT("INVALIDDIRECTORY"), TEXT("YES") );
SetMsiProperty( 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;
......@@ -96,20 +131,20 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
if ( !_tcsicmp( szValue, TEXT("ISWRONGPRODUCT") ) )
{
MsiSetProperty( handle, TEXT("ISWRONGPRODUCT"), TEXT("YES") );
SetMsiProperty( 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 = GetMsiPropValue(handle, TEXT("PRODUCTMAJOR"));
string ProductMajor = GetMsiProperty(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))
{
MsiSetProperty( handle, TEXT("ISWRONGPRODUCT"), TEXT("YES") );
SetMsiProperty( handle, TEXT("ISWRONGPRODUCT"), TEXT("YES") );
// MessageBox(NULL, "ISWRONGPRODUCT 2 set after searching PRODUCTMAJOR", "DEBUG", MB_OK);
SetMsiErrorCode( MSI_ERROR_ISWRONGPRODUCT );
return ERROR_SUCCESS;
......@@ -130,7 +165,7 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
if ( szValue[0] )
{
MsiSetProperty( handle, TEXT("ALLUSERS"), szValue );
SetMsiProperty( handle, TEXT("ALLUSERS"), szValue );
// MessageBox(NULL, "ALLUSERS set", "DEBUG", MB_OK);
}
......
......@@ -23,7 +23,7 @@
#pragma warning(push, 1) /* disable warnings within system headers */
#endif
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -121,11 +121,30 @@ void UnregisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallF
}
}
//----------------------------------------------------------
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 ) )
if ( GetMsiProp( hMSI, L"INSTALLLOCATION", &pProgPath ) && pProgPath )
{
char* pCharProgPath = UnicodeToAnsiString( pProgPath );
......@@ -252,7 +271,7 @@ BOOL MakeInstallForAllUsers( MSIHANDLE hMSI )
{
BOOL bResult = FALSE;
wchar_t* pVal = NULL;
if ( GetMsiProp( hMSI, L"ALLUSERS", &pVal ) )
if ( GetMsiProp( hMSI, L"ALLUSERS", &pVal ) && pVal )
{
bResult = UnicodeEquals( pVal , L"1" );
free( pVal );
......@@ -266,7 +285,7 @@ BOOL MakeInstallFor64Bit( MSIHANDLE hMSI )
{
BOOL bResult = FALSE;
wchar_t* pVal = NULL;
if ( GetMsiProp( hMSI, L"VersionNT64", &pVal ) )
if ( GetMsiProp( hMSI, L"VersionNT64", &pVal ) && pVal )
{
bResult = TRUE;
free( pVal );
......
......@@ -23,7 +23,7 @@
#pragma warning(push,1) // disable warnings within system headers
#endif
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -32,14 +32,47 @@
#include <malloc.h>
#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;
LPTSTR* pVal = NULL;
if ( GetMsiProp( hMSI, TEXT("ALLUSERS"), pVal ) )
wchar_t* pVal = NULL;
if ( GetMsiProp( hMSI, L"ALLUSERS", &pVal ) && pVal )
{
bResult = ( int (pVal) == 1 );
bResult = UnicodeEquals( pVal , L"1" );
free( pVal );
}
......
......@@ -28,7 +28,7 @@
#define WINVER 0x0500
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#include <malloc.h>
#include <stdio.h>
......@@ -40,6 +40,21 @@
#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 )
{
......@@ -299,8 +314,8 @@ extern "C" UINT __stdcall SelectLanguage( MSIHANDLE handle )
/* Keep track of what UI languages are relevant, either the ones explicitly
* requested with the UI_LANGS property, or all available on the system:
*/
LPTSTR pVal = NULL;
if ( (GetMsiProp( handle, "UI_LANGS", &pVal )) ) {
char* pVal = NULL;
if ( (GetMsiProp( handle, "UI_LANGS", &pVal )) && pVal ) {
char *str_ptr;
str_ptr = strtok(pVal, ",");
for(; str_ptr != NULL ;) {
......
......@@ -24,7 +24,7 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -46,17 +46,44 @@
#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 = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
std::_tstring sOfficeHostnamePath = GetMsiPropValue(handle, TEXT("OFFICEDIRHOSTNAME"));
std::_tstring sInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
std::_tstring sOfficeHostnamePath = GetMsiProperty(handle, TEXT("OFFICEDIRHOSTNAME"));
// MessageBox(NULL, sInstallPath.c_str(), "DEBUG", MB_OK);
// unsetting all properties
MsiSetProperty( handle, TEXT("DIRECTORY_NOT_EMPTY"), NULL );
UnsetMsiProperty( handle, TEXT("DIRECTORY_NOT_EMPTY") );
// 1. Searching for file setup.ini
......@@ -71,7 +98,7 @@ extern "C" UINT __stdcall CheckInstallDirectory(MSIHANDLE handle)
if ( IsValidHandle(hdl) )
{
// setup.ini found -> directory cannot be used for installation.
MsiSetProperty( handle, TEXT("DIRECTORY_NOT_EMPTY"), TEXT("1") );
SetMsiProperty( 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";
......
......@@ -24,7 +24,7 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -63,24 +63,44 @@ static inline void OutputDebugStringFormat( LPCSTR, ... )
}
#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 )
{
LPTSTR sPatchList = NULL;
LPTSTR sRequiredPatch = NULL;
std::_tstring sPatchList = GetMsiProperty( handle, TEXT("PATCH") );
std::_tstring sRequiredPatch = GetMsiProperty( handle, TEXT("PREREQUIREDPATCH") );
if ( GetMsiProp( handle, TEXT("PATCH"), &sPatchList ) && GetMsiProp( handle, TEXT("PREREQUIREDPATCH"), &sRequiredPatch ) )
OutputDebugStringFormat( "CheckPatchList called with PATCH=%s and PRQ= %s\n", sPatchList.c_str(), sRequiredPatch.c_str() );
if ( ( sPatchList.length() != 0 ) && ( sRequiredPatch.length() != 0 ) )
{
OutputDebugStringFormat( "CheckPatchList called with PATCH=%s and PRQ= %s\n", sPatchList, sRequiredPatch );
if ( _tcsstr( sPatchList, sRequiredPatch ) )
if ( _tcsstr( sPatchList.c_str(), sRequiredPatch.c_str() ) )
{
MsiSetProperty( handle, TEXT("IGNOREPREREQUIREDPATCH"), TEXT("1") );
SetMsiProperty( handle, TEXT("IGNOREPREREQUIREDPATCH") );
OutputDebugStringFormat( "Set Property IgnorePrerequiredPatch!\n" );
}
}
else
{
OutputDebugStringFormat( "CheckPatchList called with PATCH=%s and PRQ= %s\n", sPatchList, sRequiredPatch );
}
return ERROR_SUCCESS;
}
......
......@@ -23,7 +23,7 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -41,6 +41,27 @@
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
......@@ -55,8 +76,8 @@ extern "C" UINT __stdcall CompleteInstallPath( MSIHANDLE handle )
// Reading property OFFICEDIRHOSTNAME_, that contains the part of the path behind
// the program files folder.
std::_tstring sInstallLocation = GetMsiPropValue( handle, TEXT("INSTALLLOCATION") );
std::_tstring sOfficeDirHostname = GetMsiPropValue( handle, TEXT("OFFICEDIRHOSTNAME_") );
std::_tstring sInstallLocation = GetMsiProperty( handle, TEXT("INSTALLLOCATION") );
std::_tstring sOfficeDirHostname = GetMsiProperty( handle, TEXT("OFFICEDIRHOSTNAME_") );
// If sInstallLocation ends with (contains) the string sOfficeDirHostname,
// INSTALLLOCATION is good and nothing has to be done here.
......@@ -73,9 +94,9 @@ extern "C" UINT __stdcall CompleteInstallPath( MSIHANDLE handle )
if ( pathCompletionRequired )
{
std::_tstring sManufacturer = GetMsiPropValue( handle, TEXT("Manufacturer") );
std::_tstring sDefinedName = GetMsiPropValue( handle, TEXT("DEFINEDPRODUCT") );
std::_tstring sUpgradeCode = GetMsiPropValue( handle, TEXT("UpgradeCode") );
std::_tstring sManufacturer = GetMsiProperty( handle, TEXT("Manufacturer") );
std::_tstring sDefinedName = GetMsiProperty( handle, TEXT("DEFINEDPRODUCT") );
std::_tstring sUpgradeCode = GetMsiProperty( handle, TEXT("UpgradeCode") );
// sUpdateVersion can be "3.0", "3.1" or "3.2"
......
......@@ -28,7 +28,7 @@
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#include <shellapi.h>
#ifdef _MSC_VER
#pragma warning(pop)
......@@ -48,9 +48,27 @@
#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 = GetMsiPropValue( handle, TEXT("SourceDir") );
std::_tstring sSourceDir = GetMsiProperty( handle, TEXT("SourceDir") );
std::_tstring sExtensionDir = sSourceDir + TEXT("extension\\");
std::_tstring sPattern = sExtensionDir + TEXT("*.oxt");
......@@ -65,7 +83,7 @@ extern "C" UINT __stdcall copyExtensionData(MSIHANDLE handle) {
bool fNextFile = false;
bool bFailIfExist = true;
std::_tstring sDestDir = GetMsiPropValue( handle, TEXT("INSTALLLOCATION") );
std::_tstring sDestDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") );
std::_tstring sShareInstallDir = sDestDir + TEXT("share\\extension\\install\\");
// creating directories
......
......@@ -27,7 +27,7 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -45,6 +45,28 @@ 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 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) {
......@@ -104,20 +126,20 @@ Order compareVersions(string const & version1, string const & version2) {
} // namespace
extern "C" UINT __stdcall DotNetCheck(MSIHANDLE handle) {
string present(GetMsiPropValue(handle, TEXT("MsiNetAssemblySupport")));
string required(GetMsiPropValue(handle, TEXT("REQUIRED_DOTNET_VERSION")));
string present(GetMsiProperty(handle, TEXT("MsiNetAssemblySupport")));
string required(GetMsiProperty(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);
MsiSetProperty(
SetMsiProperty(
handle, TEXT("DOTNET_SUFFICIENT"),
(present.empty() || compareVersions(present, required) == ORDER_LESS ?
TEXT("0") : TEXT("1")));
// string result(GetMsiPropValue(handle, TEXT("DOTNET_SUFFICIENT")));
// string result(GetMsiProperty(handle, TEXT("DOTNET_SUFFICIENT")));
// string myText3 = TEXT("DOTNET_SUFFICIENT: ") + result;
// MessageBox(NULL, myText3.c_str(), "DEBUG", MB_OK);
......@@ -127,23 +149,23 @@ extern "C" UINT __stdcall DotNetCheck(MSIHANDLE handle) {
extern "C" UINT __stdcall ShowProperties(MSIHANDLE handle)
{
string property = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
string property = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
string myText = TEXT("INSTALLLOCATION: ") + property;
MessageBox(NULL, myText.c_str(), "INSTALLLOCATION", MB_OK);
property = GetMsiPropValue(handle, TEXT("Installed"));
property = GetMsiProperty(handle, TEXT("Installed"));
myText = TEXT("Installed: ") + property;
MessageBox(NULL, myText.c_str(), "Installed", MB_OK);
property = GetMsiPropValue(handle, TEXT("PATCH"));
property = GetMsiProperty(handle, TEXT("PATCH"));
myText = TEXT("PATCH: ") + property;
MessageBox(NULL, myText.c_str(), "PATCH", MB_OK);
property = GetMsiPropValue(handle, TEXT("REMOVE"));
property = GetMsiProperty(handle, TEXT("REMOVE"));
myText = TEXT("REMOVE: ") + property;
MessageBox(NULL, myText.c_str(), "REMOVE", MB_OK);
property = GetMsiPropValue(handle, TEXT("ALLUSERS"));
property = GetMsiProperty(handle, TEXT("ALLUSERS"));
myText = TEXT("ALLUSERS: ") + property;
MessageBox(NULL, myText.c_str(), "ALLUSERS", MB_OK);
......
......@@ -27,7 +27,7 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -45,6 +45,38 @@ 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"));
}
void stripFinalBackslash(std::string * path) {
std::string::size_type i = path->size();
if (i > 1) {
......@@ -58,13 +90,13 @@ namespace
extern "C" UINT __stdcall CreateLayerLinks(MSIHANDLE handle)
{
string sInstallPath = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
string sInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
string sUreInstallPath = sInstallPath + TEXT("URE");
string sUreLinkPath = sInstallPath + TEXT("ure-link");
if ( GetMsiPropValue(handle, TEXT("ADMININSTALL")).length() > 0 )
if ( IsSetMsiProperty(handle, TEXT("ADMININSTALL")) )
{
sUreInstallPath = TEXT("..\\URE");
}
......@@ -117,7 +149,7 @@ extern "C" UINT __stdcall CreateLayerLinks(MSIHANDLE handle)
extern "C" UINT __stdcall RemoveLayerLinks(MSIHANDLE handle)
{
string sInstallPath = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
string sInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
string sUreLinkPath = sInstallPath + TEXT("ure-link");
string sUreDirName = sInstallPath + TEXT("URE\\bin");
......
......@@ -23,7 +23,7 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -41,6 +41,27 @@
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];
......@@ -48,10 +69,10 @@ extern "C" UINT __stdcall MigrateInstallPath( MSIHANDLE handle )
HKEY hKey;
std::_tstring sInstDir;
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 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 sProductKey = "Software\\" + sManufacturer + "\\" + sDefinedName +
"\\" + sUpdateVersion + "\\" + sUpgradeCode;
......
......@@ -23,7 +23,7 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -41,6 +41,25 @@
#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 )
{
BOOL fSuccess = FALSE;
......@@ -82,7 +101,7 @@ extern "C" UINT __stdcall ExecutePostUninstallScript( MSIHANDLE handle )
HKEY hKey;
std::_tstring sInstDir;
std::_tstring sProductKey = GetMsiPropValue( handle, TEXT("FINDPRODUCT") );
std::_tstring sProductKey = GetMsiProperty( handle, TEXT("FINDPRODUCT") );
// MessageBox( NULL, sProductKey.c_str(), "Titel", MB_OK );
......
......@@ -24,7 +24,7 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -53,7 +53,7 @@ static void SetMsiProperty(MSIHANDLE handle, const std::_tstring& sProperty)
extern "C" UINT __stdcall SetAdminInstallProperty(MSIHANDLE handle)
{
MsiSetProperty(handle, TEXT("ADMININSTALL"), TEXT("1"));
SetMsiProperty(handle, TEXT("ADMININSTALL"));
return ERROR_SUCCESS;
}
......
......@@ -24,25 +24,50 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#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.
See: http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/custom.asp
*/
extern "C" UINT __stdcall InstallStartmenuFolderIcon( MSIHANDLE handle )
{
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");
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");
OSVERSIONINFO osverinfo;
osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
......@@ -84,8 +109,8 @@ extern "C" UINT __stdcall InstallStartmenuFolderIcon( MSIHANDLE handle )
extern "C" UINT __stdcall DeinstallStartmenuFolderIcon(MSIHANDLE handle)
{
std::string sOfficeMenuFolder = GetMsiPropValue( handle, TEXT("OfficeMenuFolder") );
std::string sDesktopFile = sOfficeMenuFolder + TEXT("Desktop.ini");
std::_tstring sOfficeMenuFolder = GetMsiProperty( handle, TEXT("OfficeMenuFolder") );
std::_tstring sDesktopFile = sOfficeMenuFolder + TEXT("Desktop.ini");
SetFileAttributes( sDesktopFile.c_str(), FILE_ATTRIBUTE_NORMAL );
DeleteFile( sDesktopFile.c_str() );
......
......@@ -27,7 +27,7 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -111,6 +111,38 @@ namespace
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)
{
......@@ -139,7 +171,7 @@ namespace
extern "C" UINT __stdcall SetProductInstallMode(MSIHANDLE handle)
{
string upgradeCode = GetMsiPropValue(handle, TEXT("UpgradeCode"));
string upgradeCode = GetMsiProperty(handle, TEXT("UpgradeCode"));
upgradeCode = ConvertGuid(string(upgradeCode.c_str() + 1, upgradeCode.length() - 2));
//MessageBox(NULL, upgradeCode.c_str(), TEXT("Debug"), MB_OK);
......@@ -147,17 +179,17 @@ extern "C" UINT __stdcall SetProductInstallMode(MSIHANDLE handle)
if (RegistryKeyHasUpgradeSubKey(
HKEY_CURRENT_USER,
TEXT("Software\\Microsoft\\Installer\\UpgradeCodes"),
upgradeCode))
upgradeCode) && IsSetMsiProperty(handle, TEXT("ALLUSERS")))
{
MsiSetProperty(handle, TEXT("ALLUSERS"), NULL);
UnsetMsiProperty(handle, TEXT("ALLUSERS"));
//MessageBox(NULL, "ALLUSERS removed", "DEBUG", MB_OK);
}
else if (RegistryKeyHasUpgradeSubKey(
HKEY_LOCAL_MACHINE,
TEXT("Software\\Classes\\Installer\\UpgradeCodes"),
upgradeCode))
upgradeCode) && !IsSetMsiProperty(handle, TEXT("ALLUSERS")))
{
MsiSetProperty(handle, TEXT("ALLUSERS"), TEXT("1"));
SetMsiProperty(handle, TEXT("ALLUSERS"));
//MessageBox(NULL, "ALLUSERS set", "DEBUG", MB_OK);
}
return ERROR_SUCCESS;
......
......@@ -24,7 +24,7 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -65,7 +65,25 @@ static inline void OutputDebugStringFormat( LPCSTR, ... )
#endif
static bool RemoveCompleteDirectory( std::_tstring sPath )
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 )
{
bool bDirectoryRemoved = true;
......@@ -125,7 +143,7 @@ static bool RemoveCompleteDirectory( std::_tstring sPath )
extern "C" UINT __stdcall RenamePrgFolder( MSIHANDLE handle )
{
std::_tstring sOfficeInstallPath = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
std::_tstring sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
std::_tstring sRenameSrc = sOfficeInstallPath + TEXT("program");
std::_tstring sRenameDst = sOfficeInstallPath + TEXT("program_old");
......@@ -149,7 +167,7 @@ extern "C" UINT __stdcall RenamePrgFolder( MSIHANDLE handle )
extern "C" UINT __stdcall RemovePrgFolder( MSIHANDLE handle )
{
std::_tstring sOfficeInstallPath = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
std::_tstring sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
std::_tstring sRemoveDir = sOfficeInstallPath + TEXT("program_old");
RemoveCompleteDirectory( sRemoveDir );
......
......@@ -23,7 +23,7 @@
#define WINVER 0x0500
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#include <malloc.h>
#include <stdio.h>
......@@ -43,6 +43,38 @@ 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;
......@@ -161,7 +193,7 @@ namespace
extern "C" UINT __stdcall CreateIndexes( MSIHANDLE handle )
{
string sOfficeInstallPath = GetMsiPropValue(handle, TEXT("INSTALLLOCATION"));
string sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
createIndexesForThesaurusFiles(sOfficeInstallPath);
return ERROR_SUCCESS;
}
......
......@@ -23,7 +23,7 @@
#pragma warning(push,1) // disable warnings within system headers
#endif
#include <windows.h>
#include <../tools/msiprop.hxx>
#include <msiquery.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
......@@ -35,6 +35,25 @@
#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
inline void OutputDebugStringFormat( LPCTSTR pFormat, ... )
......@@ -59,7 +78,7 @@ extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
wchar_t* pVal = NULL;
if ( GetMsiProp( hMSI, L"NEWPRODUCTS", &pVal ) )
if ( GetMsiProp( hMSI, L"NEWPRODUCTS", &pVal ) && pVal )
{
OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTS found [%s]"), pVal );
if ( *pVal != 0 )
......@@ -67,7 +86,7 @@ extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
free( pVal );
}
pVal = NULL;
if ( GetMsiProp( hMSI, L"SAMEPRODUCTS", &pVal ) )
if ( GetMsiProp( hMSI, L"SAMEPRODUCTS", &pVal ) && pVal )
{
OutputDebugStringFormat( TEXT("DEBUG: SAMEPRODUCTS found [%s]"), pVal );
if ( *pVal != 0 )
......@@ -75,7 +94,7 @@ extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
free( pVal );
}
pVal = NULL;
if ( GetMsiProp( hMSI, L"OLDPRODUCTS", &pVal ) )
if ( GetMsiProp( hMSI, L"OLDPRODUCTS", &pVal ) && pVal )
{
OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTS found [%s]"), pVal );
if ( *pVal != 0 )
......@@ -83,7 +102,7 @@ extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
free( pVal );
}
pVal = NULL;
if ( GetMsiProp( hMSI, L"BETAPRODUCTS", &pVal ) )
if ( GetMsiProp( hMSI, L"BETAPRODUCTS", &pVal ) && pVal )
{
OutputDebugStringFormat( TEXT("DEBUG: BETAPRODUCTS found [%s]"), pVal );
if ( *pVal != 0 )
......@@ -92,7 +111,7 @@ extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
}
pVal = NULL;
if ( GetMsiProp( hMSI, L"NEWPRODUCTSPATCH", &pVal ) )
if ( GetMsiProp( hMSI, L"NEWPRODUCTSPATCH", &pVal ) && pVal )
{
OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTSPATCH found [%s]"), pVal );
if ( *pVal != 0 )
......@@ -100,7 +119,7 @@ extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
free( pVal );
}
pVal = NULL;
if ( GetMsiProp( hMSI, L"SAMEPRODUCTSPATCH", &pVal ) )
if ( GetMsiProp( hMSI, L"SAMEPRODUCTSPATCH", &pVal ) && pVal )
{
OutputDebugStringFormat( TEXT("DEBUG: SAMEPRODUCTSPATCH found [%s]"), pVal );
if ( *pVal != 0 )
......@@ -108,7 +127,7 @@ extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
free( pVal );
}
pVal = NULL;
if ( GetMsiProp( hMSI, L"OLDPRODUCTSPATCH", &pVal ) )
if ( GetMsiProp( hMSI, L"OLDPRODUCTSPATCH", &pVal ) && pVal )
{
OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTSPATCH found [%s]"), pVal );
if ( *pVal != 0 )
......
/* -*- 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment