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
45 #include <seterror.hxx>
47 //----------------------------------------------------------
48 BOOL
GetMsiProp( MSIHANDLE hMSI
, const wchar_t* pPropName
, wchar_t** ppValue
)
51 if ( MsiGetProperty( hMSI
, pPropName
, L
"", &sz
) == ERROR_MORE_DATA
)
54 DWORD nbytes
= sz
* sizeof( wchar_t );
55 wchar_t* buff
= reinterpret_cast<wchar_t*>( malloc( nbytes
) );
56 ZeroMemory( buff
, nbytes
);
57 MsiGetProperty( hMSI
, pPropName
, buff
, &sz
);
66 //----------------------------------------------------------
68 inline void OutputDebugStringFormat( LPCTSTR pFormat
, ... )
73 va_start( args
, pFormat
);
74 StringCchVPrintf( buffer
, sizeof(buffer
), pFormat
, args
);
75 OutputDebugString( buffer
);
78 static inline void OutputDebugStringFormat( LPCTSTR
, ... )
83 //----------------------------------------------------------
84 extern "C" UINT __stdcall
CheckVersions( MSIHANDLE hMSI
)
86 // MessageBox(NULL, L"CheckVersions", L"Information", MB_OK | MB_ICONINFORMATION);
90 if ( GetMsiProp( hMSI
, L
"NEWPRODUCTS", &pVal
) && pVal
)
92 OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTS found [%s]"), pVal
);
94 SetMsiErrorCode( MSI_ERROR_NEW_VERSION_FOUND
);
98 if ( GetMsiProp( hMSI
, L
"SAMEPRODUCTS", &pVal
) && pVal
)
100 OutputDebugStringFormat( TEXT("DEBUG: SAMEPRODUCTS found [%s]"), pVal
);
102 SetMsiErrorCode( MSI_ERROR_SAME_VERSION_FOUND
);
106 if ( GetMsiProp( hMSI
, L
"OLDPRODUCTS", &pVal
) && pVal
)
108 OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTS found [%s]"), pVal
);
110 SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND
);
114 if ( GetMsiProp( hMSI
, L
"BETAPRODUCTS", &pVal
) && pVal
)
116 OutputDebugStringFormat( TEXT("DEBUG: BETAPRODUCTS found [%s]"), pVal
);
118 SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND
);
123 if ( GetMsiProp( hMSI
, L
"NEWPRODUCTSPATCH", &pVal
) && pVal
)
125 OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTSPATCH found [%s]"), pVal
);
127 SetMsiErrorCode( MSI_ERROR_NEW_PATCH_FOUND
);
131 if ( GetMsiProp( hMSI
, L
"SAMEPRODUCTSPATCH", &pVal
) && pVal
)
133 OutputDebugStringFormat( TEXT("DEBUG: SAMEPRODUCTSPATCH found [%s]"), pVal
);
135 SetMsiErrorCode( MSI_ERROR_SAME_PATCH_FOUND
);
139 if ( GetMsiProp( hMSI
, L
"OLDPRODUCTSPATCH", &pVal
) && pVal
)
141 OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTSPATCH found [%s]"), pVal
);
143 SetMsiErrorCode( MSI_ERROR_OLD_PATCH_FOUND
);
147 return ERROR_SUCCESS
;
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */