1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #define WIN32_LEAN_AND_MEAN
30 #include "seterror.hxx"
33 static bool GetMsiPropW( MSIHANDLE hMSI
, const wchar_t* pPropName
, wchar_t** ppValue
)
36 if ( MsiGetPropertyW( hMSI
, pPropName
, const_cast<wchar_t *>(L
""), &sz
) == ERROR_MORE_DATA
)
39 DWORD nbytes
= sz
* sizeof( wchar_t );
40 wchar_t* buff
= static_cast<wchar_t*>( malloc( nbytes
) );
41 assert(buff
); // Don't handle OOM conditions
42 ZeroMemory( buff
, nbytes
);
43 MsiGetPropertyW( hMSI
, pPropName
, buff
, &sz
);
54 inline void OutputDebugStringFormatW( PCWSTR pFormat
, ... )
59 va_start( args
, pFormat
);
60 StringCchVPrintfW( buffer
, sizeof(buffer
)/sizeof(buffer
[0]), pFormat
, args
);
61 OutputDebugStringW( buffer
);
65 static void OutputDebugStringFormatW( PCWSTR
, ... )
71 extern "C" __declspec(dllexport
) UINT __stdcall
CheckVersions( MSIHANDLE hMSI
)
73 // MessageBoxW(NULL, L"CheckVersions", L"Information", MB_OK | MB_ICONINFORMATION);
75 wchar_t* pVal
= nullptr;
77 if ( GetMsiPropW( hMSI
, L
"NEWPRODUCTS", &pVal
) && pVal
)
79 OutputDebugStringFormatW( L
"DEBUG: NEWPRODUCTS found [%s]", pVal
);
81 SetMsiErrorCode( MSI_ERROR_NEW_VERSION_FOUND
);
85 if ( GetMsiPropW( hMSI
, L
"OLDPRODUCTS", &pVal
) && pVal
)
87 OutputDebugStringFormatW( L
"DEBUG: OLDPRODUCTS found [%s]", pVal
);
89 SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND
);
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */