1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: regpatchactivex.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #pragma warning(push,1) // disable warnings within system headers
46 //----------------------------------------------------------
47 BOOL
UnicodeEquals( wchar_t* pStr1
, wchar_t* pStr2
)
49 if ( pStr1
== NULL
&& pStr2
== NULL
)
51 else if ( pStr1
== NULL
|| pStr2
== NULL
)
54 while( *pStr1
== *pStr2
&& *pStr1
&& *pStr2
)
57 return ( *pStr1
== 0 && *pStr2
== 0 );
60 //----------------------------------------------------------
61 BOOL
GetMsiProp( MSIHANDLE hMSI
, const wchar_t* pPropName
, wchar_t** ppValue
)
64 if ( MsiGetProperty( hMSI
, pPropName
, L
"", &sz
) == ERROR_MORE_DATA
)
67 DWORD nbytes
= sz
* sizeof( wchar_t );
68 wchar_t* buff
= reinterpret_cast<wchar_t*>( malloc( nbytes
) );
69 ZeroMemory( buff
, nbytes
);
70 MsiGetProperty( hMSI
, pPropName
, buff
, &sz
);
79 //----------------------------------------------------------
80 BOOL
MakeInstallForAllUsers( MSIHANDLE hMSI
)
84 if ( GetMsiProp( hMSI
, L
"ALLUSERS", &pVal
) && pVal
)
86 bResult
= UnicodeEquals( pVal
, L
"1" );
93 //----------------------------------------------------------
94 extern "C" UINT __stdcall
PatchActiveXControl( MSIHANDLE hMSI
)
96 // MessageBox(NULL, L"PatchActiveXControl", L"Information", MB_OK | MB_ICONINFORMATION);
98 INSTALLSTATE current_state
;
99 INSTALLSTATE future_state
;
101 if ( ERROR_SUCCESS
== MsiGetFeatureState( hMSI
, L
"gm_o_Activexcontrol", ¤t_state
, &future_state
) )
103 BOOL bInstallForAllUsers
= MakeInstallForAllUsers( hMSI
);
105 if ( future_state
== INSTALLSTATE_LOCAL
106 || ( current_state
== INSTALLSTATE_LOCAL
&& future_state
== INSTALLSTATE_UNKNOWN
) )
109 char* aSubKey
= "Software\\Classes\\MIME\\DataBase\\Content Type\\application/vnd.sun.xml.base";
110 if ( ERROR_SUCCESS
== RegCreateKeyA(bInstallForAllUsers
? HKEY_LOCAL_MACHINE
: HKEY_CURRENT_USER
, aSubKey
, &hkey
) )
112 RegDeleteValueA( hkey
, "CLSID" );
113 RegCloseKey( hkey
), hkey
= NULL
;
122 return ERROR_SUCCESS
;