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