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: checkversion.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
47 #include <seterror.hxx>
49 //----------------------------------------------------------
50 BOOL
GetMsiProp( MSIHANDLE hMSI
, const wchar_t* pPropName
, wchar_t** ppValue
)
53 if ( MsiGetProperty( hMSI
, pPropName
, L
"", &sz
) == ERROR_MORE_DATA
)
56 DWORD nbytes
= sz
* sizeof( wchar_t );
57 wchar_t* buff
= reinterpret_cast<wchar_t*>( malloc( nbytes
) );
58 ZeroMemory( buff
, nbytes
);
59 MsiGetProperty( hMSI
, pPropName
, buff
, &sz
);
68 //----------------------------------------------------------
70 inline void OutputDebugStringFormat( LPCTSTR pFormat
, ... )
75 va_start( args
, pFormat
);
76 StringCchVPrintf( buffer
, sizeof(buffer
), pFormat
, args
);
77 OutputDebugString( buffer
);
80 static inline void OutputDebugStringFormat( LPCTSTR
, ... )
85 //----------------------------------------------------------
86 extern "C" UINT __stdcall
CheckVersions( MSIHANDLE hMSI
)
88 // MessageBox(NULL, L"CheckVersions", L"Information", MB_OK | MB_ICONINFORMATION);
92 if ( GetMsiProp( hMSI
, L
"NEWPRODUCTS", &pVal
) && pVal
)
94 OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTS found [%s]"), pVal
);
96 SetMsiErrorCode( MSI_ERROR_NEW_VERSION_FOUND
);
100 if ( GetMsiProp( hMSI
, L
"SAMEPRODUCTS", &pVal
) && pVal
)
102 OutputDebugStringFormat( TEXT("DEBUG: SAMEPRODUCTS found [%s]"), pVal
);
104 SetMsiErrorCode( MSI_ERROR_SAME_VERSION_FOUND
);
108 if ( GetMsiProp( hMSI
, L
"OLDPRODUCTS", &pVal
) && pVal
)
110 OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTS found [%s]"), pVal
);
112 SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND
);
116 if ( GetMsiProp( hMSI
, L
"BETAPRODUCTS", &pVal
) && pVal
)
118 OutputDebugStringFormat( TEXT("DEBUG: BETAPRODUCTS found [%s]"), pVal
);
120 SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND
);
125 if ( GetMsiProp( hMSI
, L
"NEWPRODUCTSPATCH", &pVal
) && pVal
)
127 OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTSPATCH found [%s]"), pVal
);
129 SetMsiErrorCode( MSI_ERROR_NEW_PATCH_FOUND
);
133 if ( GetMsiProp( hMSI
, L
"SAMEPRODUCTSPATCH", &pVal
) && pVal
)
135 OutputDebugStringFormat( TEXT("DEBUG: SAMEPRODUCTSPATCH found [%s]"), pVal
);
137 SetMsiErrorCode( MSI_ERROR_SAME_PATCH_FOUND
);
141 if ( GetMsiProp( hMSI
, L
"OLDPRODUCTSPATCH", &pVal
) && pVal
)
143 OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTSPATCH found [%s]"), pVal
);
145 SetMsiErrorCode( MSI_ERROR_OLD_PATCH_FOUND
);
149 return ERROR_SUCCESS
;