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 // Refuse early and clearly on an unsupported Windows, rather than letting the
72 // runtime install fail later with a message that does not name the real cause.
73 if ( ! pSetup->CheckOSVersion() )
74 throw pSetup->GetError();
75
76 if ( ! pSetup->IsAdminInstall() )
77 if ( ! pSetup->GetPatches() )
78 throw pSetup->GetError();
79
80 // CheckForUpgrade() has to be called after calling GetPatches()!
81 if ( ! pSetup->CheckForUpgrade() )
82 throw pSetup->GetError();
83
84 long nLanguage;
85
86 if ( ! pSetup->ChooseLanguage( nLanguage ) )
87 throw pSetup->GetError();
88
89 if ( ! pSetup->InstallRuntimes() )
90 throw pSetup->GetError();
91
92 if ( ! pSetup->Install( nLanguage ) )
93 throw pSetup->GetError();
94 }
95 catch ( std::bad_alloc )
96 {
97 pSetup->DisplayError( ERROR_OUTOFMEMORY );
98 }
99 catch ( UINT nErr )
100 {
101 pSetup->DisplayError( nErr );
102 }
103
104 int nRet = pSetup->GetError();
105
106 delete pSetup;
107
108 return nRet;
109 }
110