1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #define UNICODE 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #ifdef _MSC_VER 31*cdf0e10cSrcweir #pragma warning(push, 1) /* disable warnings within system headers */ 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir #include <windows.h> 34*cdf0e10cSrcweir #include <msiquery.h> 35*cdf0e10cSrcweir #ifdef _MSC_VER 36*cdf0e10cSrcweir #pragma warning(pop) 37*cdf0e10cSrcweir #endif 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <string.h> 40*cdf0e10cSrcweir #include <malloc.h> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #define CHART_COMPONENT 1 43*cdf0e10cSrcweir #define DRAW_COMPONENT 2 44*cdf0e10cSrcweir #define IMPRESS_COMPONENT 4 45*cdf0e10cSrcweir #define CALC_COMPONENT 8 46*cdf0e10cSrcweir #define WRITER_COMPONENT 16 47*cdf0e10cSrcweir #define MATH_COMPONENT 32 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir // #define OWN_DEBUG_PRINT 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir typedef int ( __stdcall * DllNativeRegProc ) ( int, BOOL, BOOL, const char* ); 52*cdf0e10cSrcweir typedef int ( __stdcall * DllNativeUnregProc ) ( int, BOOL, BOOL ); 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir BOOL UnicodeEquals( wchar_t* pStr1, wchar_t* pStr2 ) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir if ( pStr1 == NULL && pStr2 == NULL ) 57*cdf0e10cSrcweir return TRUE; 58*cdf0e10cSrcweir else if ( pStr1 == NULL || pStr2 == NULL ) 59*cdf0e10cSrcweir return FALSE; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir while( *pStr1 == *pStr2 && *pStr1 && *pStr2 ) 62*cdf0e10cSrcweir pStr1++, pStr2++; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir return ( *pStr1 == 0 && *pStr2 == 0 ); 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir //---------------------------------------------------------- 68*cdf0e10cSrcweir char* UnicodeToAnsiString( wchar_t* pUniString ) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir int len = WideCharToMultiByte( 71*cdf0e10cSrcweir CP_ACP, 0, pUniString, -1, 0, 0, 0, 0 ); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir char* buff = reinterpret_cast<char*>( malloc( len ) ); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir WideCharToMultiByte( 76*cdf0e10cSrcweir CP_ACP, 0, pUniString, -1, buff, len, 0, 0 ); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir return buff; 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir #ifdef OWN_DEBUG_PRINT 82*cdf0e10cSrcweir void WarningMessageInt( wchar_t* pWarning, unsigned int nValue ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir wchar_t pStr[5] = { nValue%10000/1000 + 48, nValue%1000/100 + 48, nValue%100/10 + 48, nValue%10 + 48, 0 }; 85*cdf0e10cSrcweir MessageBox(NULL, pStr, pWarning, MB_OK | MB_ICONINFORMATION); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir #endif 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir //---------------------------------------------------------- 90*cdf0e10cSrcweir void RegisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallForAllUser, BOOL InstallFor64Bit ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir #ifdef OWN_DEBUG_PRINT 93*cdf0e10cSrcweir MessageBoxW(NULL, L"RegisterActiveXNative", L"Information", MB_OK | MB_ICONINFORMATION); 94*cdf0e10cSrcweir MessageBoxA(NULL, pActiveXPath, "Library Path", MB_OK | MB_ICONINFORMATION); 95*cdf0e10cSrcweir #endif 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir // For Win98/WinME the values should be written to the local machine 98*cdf0e10cSrcweir OSVERSIONINFO aVerInfo; 99*cdf0e10cSrcweir aVerInfo.dwOSVersionInfoSize = sizeof( aVerInfo ); 100*cdf0e10cSrcweir if ( GetVersionEx( &aVerInfo ) && aVerInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ) 101*cdf0e10cSrcweir InstallForAllUser = TRUE; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir HINSTANCE hModule = LoadLibraryExA( pActiveXPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ); 104*cdf0e10cSrcweir if( !( hModule <= ( HINSTANCE )HINSTANCE_ERROR ) ) 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir DllNativeRegProc pNativeProc = ( DllNativeRegProc )GetProcAddress( hModule, "DllRegisterServerNative" ); 107*cdf0e10cSrcweir if( pNativeProc!=NULL ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir #ifdef OWN_DEBUG_PRINT 110*cdf0e10cSrcweir MessageBoxA(NULL, pActiveXPath, "Library Path", MB_OK | MB_ICONINFORMATION); 111*cdf0e10cSrcweir #endif 112*cdf0e10cSrcweir int nLen = strlen( pActiveXPath ); 113*cdf0e10cSrcweir int nRemoveLen = strlen( "\\so_activex.dll" ); 114*cdf0e10cSrcweir if ( nLen > nRemoveLen ) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir char* pProgramPath = reinterpret_cast<char*>( malloc( nLen - nRemoveLen + 1 ) ); 117*cdf0e10cSrcweir strncpy( pProgramPath, pActiveXPath, nLen - nRemoveLen ); 118*cdf0e10cSrcweir pProgramPath[ nLen - nRemoveLen ] = 0; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir ( *pNativeProc )( nMode, InstallForAllUser, InstallFor64Bit, pProgramPath ); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir free( pProgramPath ); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir FreeLibrary( hModule ); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir //---------------------------------------------------------- 131*cdf0e10cSrcweir void UnregisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallForAllUser, BOOL InstallFor64Bit ) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir // For Win98/WinME the values should be written to the local machine 134*cdf0e10cSrcweir OSVERSIONINFO aVerInfo; 135*cdf0e10cSrcweir aVerInfo.dwOSVersionInfoSize = sizeof( aVerInfo ); 136*cdf0e10cSrcweir if ( GetVersionEx( &aVerInfo ) && aVerInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ) 137*cdf0e10cSrcweir InstallForAllUser = TRUE; 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir HINSTANCE hModule = LoadLibraryExA( pActiveXPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ); 140*cdf0e10cSrcweir if( !( hModule <= ( HINSTANCE )HINSTANCE_ERROR ) ) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir DllNativeUnregProc pNativeProc = ( DllNativeUnregProc )GetProcAddress( hModule, "DllUnregisterServerNative" ); 143*cdf0e10cSrcweir if( pNativeProc!=NULL ) 144*cdf0e10cSrcweir ( *pNativeProc )( nMode, InstallForAllUser, InstallFor64Bit ); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir FreeLibrary( hModule ); 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir //---------------------------------------------------------- 151*cdf0e10cSrcweir BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir DWORD sz = 0; 154*cdf0e10cSrcweir if ( MsiGetProperty( hMSI, pPropName, L"", &sz ) == ERROR_MORE_DATA ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir sz++; 157*cdf0e10cSrcweir DWORD nbytes = sz * sizeof( wchar_t ); 158*cdf0e10cSrcweir wchar_t* buff = reinterpret_cast<wchar_t*>( malloc( nbytes ) ); 159*cdf0e10cSrcweir ZeroMemory( buff, nbytes ); 160*cdf0e10cSrcweir MsiGetProperty( hMSI, pPropName, buff, &sz ); 161*cdf0e10cSrcweir *ppValue = buff; 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir return TRUE; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir return FALSE; 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir //---------------------------------------------------------- 170*cdf0e10cSrcweir BOOL GetActiveXControlPath( MSIHANDLE hMSI, char** ppActiveXPath ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir wchar_t* pProgPath = NULL; 173*cdf0e10cSrcweir if ( GetMsiProp( hMSI, L"INSTALLLOCATION", &pProgPath ) && pProgPath ) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir char* pCharProgPath = UnicodeToAnsiString( pProgPath ); 176*cdf0e10cSrcweir #ifdef OWN_DEBUG_PRINT 177*cdf0e10cSrcweir MessageBox(NULL, pProgPath, L"Basis Installation Path", MB_OK | MB_ICONINFORMATION); 178*cdf0e10cSrcweir MessageBoxA(NULL, pCharProgPath, "Basis Installation Path( char )", MB_OK | MB_ICONINFORMATION); 179*cdf0e10cSrcweir #endif 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir if ( pCharProgPath ) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir int nLen = strlen( pCharProgPath ); 184*cdf0e10cSrcweir *ppActiveXPath = reinterpret_cast<char*>( malloc( nLen + 23 ) ); 185*cdf0e10cSrcweir strncpy( *ppActiveXPath, pCharProgPath, nLen ); 186*cdf0e10cSrcweir strncpy( (*ppActiveXPath) + nLen, "program\\so_activex.dll", 22 ); 187*cdf0e10cSrcweir (*ppActiveXPath)[nLen+22] = 0; 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir free( pCharProgPath ); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir return TRUE; 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir free( pProgPath ); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir return FALSE; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir //---------------------------------------------------------- 201*cdf0e10cSrcweir BOOL GetDelta( MSIHANDLE hMSI, int& nOldInstallMode, int& nInstallMode, int& nDeinstallMode ) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir // for now the chart is always installed 204*cdf0e10cSrcweir nOldInstallMode = CHART_COMPONENT; 205*cdf0e10cSrcweir nInstallMode = CHART_COMPONENT; 206*cdf0e10cSrcweir nDeinstallMode = 0; 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir INSTALLSTATE current_state; 209*cdf0e10cSrcweir INSTALLSTATE future_state; 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_p_Wrt_Bin", ¤t_state, &future_state ) ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir #ifdef OWN_DEBUG_PRINT 214*cdf0e10cSrcweir WarningMessageInt( L"writer current_state = ", current_state ); 215*cdf0e10cSrcweir WarningMessageInt( L"writer future_state = ", future_state ); 216*cdf0e10cSrcweir #endif 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir // analyze writer installation mode 219*cdf0e10cSrcweir if ( current_state == INSTALLSTATE_LOCAL ) 220*cdf0e10cSrcweir nOldInstallMode |= WRITER_COMPONENT; 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir if ( future_state == INSTALLSTATE_LOCAL 223*cdf0e10cSrcweir || ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_UNKNOWN ) ) 224*cdf0e10cSrcweir nInstallMode |= WRITER_COMPONENT; 225*cdf0e10cSrcweir else if ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_ABSENT ) 226*cdf0e10cSrcweir nDeinstallMode |= WRITER_COMPONENT; 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir else 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir // assert( FALSE ); 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_p_Calc_Bin", ¤t_state, &future_state ) ) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir #ifdef OWN_DEBUG_PRINT 236*cdf0e10cSrcweir WarningMessageInt( L"calc current_state = ", current_state ); 237*cdf0e10cSrcweir WarningMessageInt( L"calc future_state = ", future_state ); 238*cdf0e10cSrcweir #endif 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir // analyze calc installation mode 241*cdf0e10cSrcweir if ( current_state == INSTALLSTATE_LOCAL ) 242*cdf0e10cSrcweir nOldInstallMode |= CALC_COMPONENT; 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir if ( future_state == INSTALLSTATE_LOCAL 245*cdf0e10cSrcweir || ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_UNKNOWN ) ) 246*cdf0e10cSrcweir nInstallMode |= CALC_COMPONENT; 247*cdf0e10cSrcweir else if ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_ABSENT ) 248*cdf0e10cSrcweir nDeinstallMode |= CALC_COMPONENT; 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir else 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir // assert( FALSE ); 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_p_Draw_Bin", ¤t_state, &future_state ) ) 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir // analyze draw installation mode 258*cdf0e10cSrcweir if ( current_state == INSTALLSTATE_LOCAL ) 259*cdf0e10cSrcweir nOldInstallMode |= DRAW_COMPONENT; 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir if ( future_state == INSTALLSTATE_LOCAL 262*cdf0e10cSrcweir || ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_UNKNOWN ) ) 263*cdf0e10cSrcweir nInstallMode |= DRAW_COMPONENT; 264*cdf0e10cSrcweir else if ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_ABSENT ) 265*cdf0e10cSrcweir nDeinstallMode |= DRAW_COMPONENT; 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir else 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir // assert( FALSE ); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_p_Impress_Bin", ¤t_state, &future_state ) ) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir // analyze impress installation mode 275*cdf0e10cSrcweir if ( current_state == INSTALLSTATE_LOCAL ) 276*cdf0e10cSrcweir nOldInstallMode |= IMPRESS_COMPONENT; 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir if ( future_state == INSTALLSTATE_LOCAL 279*cdf0e10cSrcweir || ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_UNKNOWN ) ) 280*cdf0e10cSrcweir nInstallMode |= IMPRESS_COMPONENT; 281*cdf0e10cSrcweir else if ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_ABSENT ) 282*cdf0e10cSrcweir nDeinstallMode |= IMPRESS_COMPONENT; 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir else 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir // assert( FALSE ); 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_p_Math_Bin", ¤t_state, &future_state ) ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir // analyze math installation mode 292*cdf0e10cSrcweir if ( current_state == INSTALLSTATE_LOCAL ) 293*cdf0e10cSrcweir nOldInstallMode |= MATH_COMPONENT; 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir if ( future_state == INSTALLSTATE_LOCAL 296*cdf0e10cSrcweir || ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_UNKNOWN ) ) 297*cdf0e10cSrcweir nInstallMode |= MATH_COMPONENT; 298*cdf0e10cSrcweir else if ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_ABSENT ) 299*cdf0e10cSrcweir nDeinstallMode |= MATH_COMPONENT; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir else 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir // assert( FALSE ); 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir return TRUE; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir //---------------------------------------------------------- 310*cdf0e10cSrcweir BOOL MakeInstallForAllUsers( MSIHANDLE hMSI ) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir BOOL bResult = FALSE; 313*cdf0e10cSrcweir wchar_t* pVal = NULL; 314*cdf0e10cSrcweir if ( GetMsiProp( hMSI, L"ALLUSERS", &pVal ) && pVal ) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir bResult = UnicodeEquals( pVal , L"1" ); 317*cdf0e10cSrcweir free( pVal ); 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir return bResult; 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir //---------------------------------------------------------- 324*cdf0e10cSrcweir BOOL MakeInstallFor64Bit( MSIHANDLE hMSI ) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir BOOL bResult = FALSE; 327*cdf0e10cSrcweir wchar_t* pVal = NULL; 328*cdf0e10cSrcweir if ( GetMsiProp( hMSI, L"VersionNT64", &pVal ) && pVal ) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir bResult = TRUE; 331*cdf0e10cSrcweir free( pVal ); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir return bResult; 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir //---------------------------------------------------------- 337*cdf0e10cSrcweir extern "C" UINT __stdcall InstallActiveXControl( MSIHANDLE hMSI ) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir int nOldInstallMode = 0; 340*cdf0e10cSrcweir int nInstallMode = 0; 341*cdf0e10cSrcweir int nDeinstallMode = 0; 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir #ifdef OWN_DEBUG_PRINT 344*cdf0e10cSrcweir MessageBox(NULL, L"InstallActiveXControl", L"Information", MB_OK | MB_ICONINFORMATION); 345*cdf0e10cSrcweir #endif 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir INSTALLSTATE current_state; 348*cdf0e10cSrcweir INSTALLSTATE future_state; 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_o_Activexcontrol", ¤t_state, &future_state ) ) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir #ifdef OWN_DEBUG_PRINT 353*cdf0e10cSrcweir MessageBox(NULL, L"InstallActiveXControl Step2", L"Information", MB_OK | MB_ICONINFORMATION); 354*cdf0e10cSrcweir #endif 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir BOOL bInstallForAllUser = MakeInstallForAllUsers( hMSI ); 357*cdf0e10cSrcweir BOOL bInstallFor64Bit = MakeInstallFor64Bit( hMSI ); 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir char* pActiveXPath = NULL; 360*cdf0e10cSrcweir if ( GetActiveXControlPath( hMSI, &pActiveXPath ) && pActiveXPath 361*cdf0e10cSrcweir && GetDelta( hMSI, nOldInstallMode, nInstallMode, nDeinstallMode ) ) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir #ifdef OWN_DEBUG_PRINT 364*cdf0e10cSrcweir MessageBox(NULL, L"InstallActiveXControl Step3", L"Information", MB_OK | MB_ICONINFORMATION); 365*cdf0e10cSrcweir #endif 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir if ( future_state == INSTALLSTATE_LOCAL 368*cdf0e10cSrcweir || ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_UNKNOWN ) ) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir #ifdef OWN_DEBUG_PRINT 371*cdf0e10cSrcweir MessageBox(NULL, L"InstallActiveXControl, adjusting", L"Information", MB_OK | MB_ICONINFORMATION); 372*cdf0e10cSrcweir WarningMessageInt( L"nInstallMode = ", nInstallMode ); 373*cdf0e10cSrcweir #endif 374*cdf0e10cSrcweir // the control is installed in the new selected configuration 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir if ( current_state == INSTALLSTATE_LOCAL && nDeinstallMode ) 377*cdf0e10cSrcweir UnregisterActiveXNative( pActiveXPath, nDeinstallMode, bInstallForAllUser, bInstallFor64Bit ); 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir if ( nInstallMode ) 380*cdf0e10cSrcweir RegisterActiveXNative( pActiveXPath, nInstallMode, bInstallForAllUser, bInstallFor64Bit ); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir else if ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_ABSENT ) 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir #ifdef OWN_DEBUG_PRINT 385*cdf0e10cSrcweir MessageBox(NULL, L"InstallActiveXControl, removing", L"Information", MB_OK | MB_ICONINFORMATION); 386*cdf0e10cSrcweir #endif 387*cdf0e10cSrcweir if ( nOldInstallMode ) 388*cdf0e10cSrcweir UnregisterActiveXNative( pActiveXPath, nOldInstallMode, bInstallForAllUser, bInstallFor64Bit ); 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir if ( pActiveXPath ) 393*cdf0e10cSrcweir free( pActiveXPath ); 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir else 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir // assert( FALSE ); 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir return ERROR_SUCCESS; 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir //---------------------------------------------------------- 404*cdf0e10cSrcweir extern "C" UINT __stdcall DeinstallActiveXControl( MSIHANDLE hMSI ) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir INSTALLSTATE current_state; 407*cdf0e10cSrcweir INSTALLSTATE future_state; 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir #ifdef OWN_DEBUG_PRINT 410*cdf0e10cSrcweir MessageBox(NULL, L"DeinstallActiveXControl", L"Information", MB_OK | MB_ICONINFORMATION); 411*cdf0e10cSrcweir #endif 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_o_Activexcontrol", ¤t_state, &future_state ) ) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir char* pActiveXPath = NULL; 416*cdf0e10cSrcweir if ( current_state == INSTALLSTATE_LOCAL && GetActiveXControlPath( hMSI, &pActiveXPath ) && pActiveXPath ) 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir BOOL bInstallForAllUser = MakeInstallForAllUsers( hMSI ); 419*cdf0e10cSrcweir BOOL bInstallFor64Bit = MakeInstallFor64Bit( hMSI ); 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir UnregisterActiveXNative( pActiveXPath, 423*cdf0e10cSrcweir CHART_COMPONENT 424*cdf0e10cSrcweir | DRAW_COMPONENT 425*cdf0e10cSrcweir | IMPRESS_COMPONENT 426*cdf0e10cSrcweir | CALC_COMPONENT 427*cdf0e10cSrcweir | WRITER_COMPONENT 428*cdf0e10cSrcweir | MATH_COMPONENT, 429*cdf0e10cSrcweir bInstallForAllUser, 430*cdf0e10cSrcweir bInstallFor64Bit ); 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir free( pActiveXPath ); 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir return ERROR_SUCCESS; 438*cdf0e10cSrcweir } 439