1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_desktop.hxx"
26
27 #define UNICODE 1
28 #define _UNICODE 1
29
30 #if defined _MSC_VER
31 #pragma warning(push, 1)
32 #endif
33 #include <windows.h>
34 #if defined _MSC_VER
35 #pragma warning(pop)
36 #endif
37 #include <new>
38
39 #include "setup.hxx"
40
41 //--------------------------------------------------------------------------
42
newhandler()43 void __cdecl newhandler()
44 {
45 throw std::bad_alloc();
46 return;
47 }
48
49 //--------------------------------------------------------------------------
50 //--------------------------------------------------------------------------
51 //--------------------------------------------------------------------------
52
WinMain(HINSTANCE hInst,HINSTANCE,LPSTR,int)53 extern "C" int __stdcall WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, int )
54 {
55 SetupApp *pSetup = new SetupApp();
56
57 try
58 {
59 if ( ! pSetup->Initialize( hInst ) )
60 throw pSetup->GetError();
61
62 if ( pSetup->AlreadyRunning() )
63 throw (UINT) ERROR_INSTALL_ALREADY_RUNNING;
64
65 if ( ! pSetup->ReadProfile() )
66 throw pSetup->GetError();
67
68 if ( ! pSetup->CheckVersion() )
69 throw pSetup->GetError();
70
71 if ( ! pSetup->IsAdminInstall() )
72 if ( ! pSetup->GetPatches() )
73 throw pSetup->GetError();
74
75 // CheckForUpgrade() has to be called after calling GetPatches()!
76 if ( ! pSetup->CheckForUpgrade() )
77 throw pSetup->GetError();
78
79 long nLanguage;
80
81 if ( ! pSetup->ChooseLanguage( nLanguage ) )
82 throw pSetup->GetError();
83
84 if ( ! pSetup->InstallRuntimes() )
85 throw pSetup->GetError();
86
87 if ( ! pSetup->Install( nLanguage ) )
88 throw pSetup->GetError();
89 }
90 catch ( std::bad_alloc )
91 {
92 pSetup->DisplayError( ERROR_OUTOFMEMORY );
93 }
94 catch ( UINT nErr )
95 {
96 pSetup->DisplayError( nErr );
97 }
98
99 int nRet = pSetup->GetError();
100
101 delete pSetup;
102
103 return nRet;
104 }
105