Update ooo320-m1
[ooovba.git] / setup_native / source / win32 / customactions / relnotes / relnotes.cxx
blob110df554a550d88c6d0dabae3775b13365d6ca9c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifdef _MSC_VER
29 #pragma warning(push,1) // disable warnings within system headers
30 #pragma warning(disable: 4917)
31 #endif
32 #include <windows.h>
33 #include <msiquery.h>
34 #include <shlobj.h>
35 #ifdef _MSC_VER
36 #pragma warning(pop)
37 #endif
39 #include <string.h>
40 #include <malloc.h>
41 #include <stdio.h>
42 #include <strsafe.h>
44 //----------------------------------------------------------
45 #ifdef DEBUG
46 inline void OutputDebugStringFormat( LPCTSTR pFormat, ... )
48 TCHAR buffer[1024];
49 va_list args;
51 va_start( args, pFormat );
52 StringCchVPrintf( buffer, sizeof(buffer), pFormat, args );
53 OutputDebugString( buffer );
55 #else
56 static inline void OutputDebugStringFormat( LPCTSTR, ... )
59 #endif
61 //----------------------------------------------------------
62 inline bool IsValidHandle( HANDLE handle )
64 return (NULL != handle) && (INVALID_HANDLE_VALUE != handle);
67 //----------------------------------------------------------
68 //----------------------------------------------------------
69 //----------------------------------------------------------
70 UINT ShowReleaseNotes( TCHAR* pFileName, TCHAR* pFilePath )
72 TCHAR sFullPath[ MAX_PATH ];
74 if ( FAILED( StringCchCopy( sFullPath, MAX_PATH, pFilePath ) ) )
76 OutputDebugStringFormat( TEXT("DEBUG: ShowReleaseNotes: Could not copy path [%s]"), pFilePath );
77 return ERROR_SUCCESS;
80 if ( FAILED( StringCchCat( sFullPath, MAX_PATH, pFileName ) ) )
82 OutputDebugStringFormat( TEXT("DEBUG: ShowReleaseNotes: Could not append filename [%s]"), pFileName );
83 return ERROR_SUCCESS;
86 HANDLE hFile = CreateFile( sFullPath, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
88 if ( IsValidHandle(hFile) )
90 CloseHandle( hFile );
91 OutputDebugStringFormat( TEXT("DEBUG: ShowReleaseNotes: Found file [%s]"), sFullPath );
93 SHELLEXECUTEINFOW aExecInf;
94 ZeroMemory( &aExecInf, sizeof( aExecInf ) );
96 aExecInf.cbSize = sizeof( aExecInf );
97 aExecInf.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI;
98 aExecInf.lpVerb = TEXT("open");
99 aExecInf.lpFile = sFullPath;
100 aExecInf.lpDirectory = NULL;
101 aExecInf.nShow = SW_SHOWNORMAL;
103 SetLastError( 0 );
104 ShellExecuteEx( &aExecInf );
106 else
108 OutputDebugStringFormat( TEXT("DEBUG: ShowReleaseNotes: File not found [%s]"), sFullPath );
111 return ERROR_SUCCESS;
114 //----------------------------------------------------------
115 extern "C" UINT __stdcall ShowReleaseNotesBefore( MSIHANDLE )
117 TCHAR szPath[MAX_PATH];
119 if( FAILED( SHGetSpecialFolderPath( NULL, szPath, CSIDL_COMMON_DOCUMENTS, true ) ) )
120 return ERROR_SUCCESS;
122 OutputDebugString( TEXT("DEBUG: ShowReleaseNotesBefore called") );
124 return ShowReleaseNotes( TEXT("\\sun\\releasenote1.url"), szPath );
127 //----------------------------------------------------------
128 extern "C" UINT __stdcall ShowReleaseNotesAfter( MSIHANDLE )
130 TCHAR szPath[MAX_PATH];
132 if( FAILED( SHGetSpecialFolderPath( NULL, szPath, CSIDL_COMMON_DOCUMENTS, true ) ) )
133 return ERROR_SUCCESS;
135 OutputDebugString( TEXT("DEBUG: ShowReleaseNotesAfter called") );
137 return ShowReleaseNotes( TEXT("\\sun\\releasenote2.url"), szPath );
140 //----------------------------------------------------------
141 extern "C" UINT __stdcall ShowSurveyAfter( MSIHANDLE )
143 OutputDebugString( TEXT("DEBUG: ShowSurveyAfter called") );
145 SHELLEXECUTEINFOW aExecInf;
146 ZeroMemory( &aExecInf, sizeof( aExecInf ) );
148 aExecInf.cbSize = sizeof( aExecInf );
149 aExecInf.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI;
150 aExecInf.lpVerb = TEXT("open");
151 aExecInf.lpFile = TEXT("http://surveys.services.openoffice.org/deinstall");
152 aExecInf.lpDirectory = NULL;
153 aExecInf.nShow = SW_SHOWNORMAL;
155 SetLastError( 0 );
156 ShellExecuteEx( &aExecInf );
158 return ERROR_SUCCESS;