1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
32 #pragma warning(push,1) // disable warnings within system headers
44 //----------------------------------------------------------
45 BOOL
UnicodeEquals( wchar_t* pStr1
, wchar_t* pStr2
)
47 if ( pStr1
== NULL
&& pStr2
== NULL
)
49 else if ( pStr1
== NULL
|| pStr2
== NULL
)
52 while( *pStr1
== *pStr2
&& *pStr1
&& *pStr2
)
55 return ( *pStr1
== 0 && *pStr2
== 0 );
58 //----------------------------------------------------------
59 BOOL
GetMsiProp( MSIHANDLE hMSI
, const wchar_t* pPropName
, wchar_t** ppValue
)
62 if ( MsiGetProperty( hMSI
, pPropName
, L
"", &sz
) == ERROR_MORE_DATA
)
65 DWORD nbytes
= sz
* sizeof( wchar_t );
66 wchar_t* buff
= reinterpret_cast<wchar_t*>( malloc( nbytes
) );
67 ZeroMemory( buff
, nbytes
);
68 MsiGetProperty( hMSI
, pPropName
, buff
, &sz
);
77 //----------------------------------------------------------
78 BOOL
MakeInstallForAllUsers( MSIHANDLE hMSI
)
82 if ( GetMsiProp( hMSI
, L
"ALLUSERS", &pVal
) && pVal
)
84 bResult
= UnicodeEquals( pVal
, L
"1" );
91 //----------------------------------------------------------
92 extern "C" UINT __stdcall
PatchActiveXControl( MSIHANDLE hMSI
)
94 // MessageBox(NULL, L"PatchActiveXControl", L"Information", MB_OK | MB_ICONINFORMATION);
96 INSTALLSTATE current_state
;
97 INSTALLSTATE future_state
;
99 if ( ERROR_SUCCESS
== MsiGetFeatureState( hMSI
, L
"gm_o_Activexcontrol", ¤t_state
, &future_state
) )
101 BOOL bInstallForAllUsers
= MakeInstallForAllUsers( hMSI
);
103 if ( future_state
== INSTALLSTATE_LOCAL
104 || ( current_state
== INSTALLSTATE_LOCAL
&& future_state
== INSTALLSTATE_UNKNOWN
) )
107 char* aSubKey
= "Software\\Classes\\MIME\\DataBase\\Content Type\\application/vnd.sun.xml.base";
108 if ( ERROR_SUCCESS
== RegCreateKeyA(bInstallForAllUsers
? HKEY_LOCAL_MACHINE
: HKEY_CURRENT_USER
, aSubKey
, &hkey
) )
110 RegDeleteValueA( hkey
, "CLSID" );
111 RegCloseKey( hkey
), hkey
= NULL
;
120 return ERROR_SUCCESS
;
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */