Changeset 538 for branches/eraser6/Installer/Bootstrapper/Main.cpp
- Timestamp:
- 11/13/08 11:06:33 (5 years ago)
- File:
-
- 1 edited
-
branches/eraser6/Installer/Bootstrapper/Main.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Installer/Bootstrapper/Main.cpp
r537 r538 37 37 //Static variables 38 38 HINSTANCE hInstance = NULL; 39 HWND hWndParent = NULL; 40 HWND hWndStatusLbl = NULL; 41 HWND hWndProgressBar = NULL; 42 HWND hWndCancelBtn = NULL; 39 MainWindow MainWin; 43 40 44 41 bool InitInstance(HINSTANCE hInstance, HWND& hWnd); … … 87 84 }; 88 85 89 /// Registers the main window class and creates it. 90 bool InitInstance(HINSTANCE hInstance, HWND& hWnd) 91 { 92 WNDCLASSEX wcex; 93 ::ZeroMemory(&wcex, sizeof(wcex)); 94 95 wcex.cbSize = sizeof(WNDCLASSEX); 96 wcex.style = CS_HREDRAW | CS_VREDRAW; 97 wcex.lpfnWndProc = WndProc; 98 wcex.cbClsExtra = 0; 99 wcex.cbWndExtra = 0; 100 wcex.hInstance = hInstance; 101 wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(BOOTSTRAPPER_ICON)); 102 wcex.hCursor = LoadCursor(NULL, IDC_ARROW); 103 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 104 wcex.lpszClassName = szWindowClass; 105 wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(BOOTSTRAPPER_ICON)); 106 RegisterClassExW(&wcex); 107 InitCommonControls(); 108 109 //Create the window 110 hWnd = CreateWindowW(szWindowClass, L"Eraser Setup", WS_CAPTION | WS_SYSMENU, 111 CW_USEDEFAULT, 0, 300, 130, NULL, NULL, hInstance, NULL); 112 113 if (!hWnd) 114 return false; 115 116 //Set default settings (font) 117 SetWindowFont(hWnd); 118 return true; 119 } 86 87 120 88 121 89 /// Helper function to set the window font for created windows to the system default. … … 186 154 //Create the parent window and the child controls 187 155 ::hInstance = hInstance; 188 if (!InitInstance(hInstance, hWndParent)) 156 MainWin.Create(); 157 158 try 159 { 160 //OK, now we do the hard work. Create a folder to place our payload into 161 wchar_t tempPath[MAX_PATH]; 162 DWORD result = GetTempPathW(sizeof(tempPath) / sizeof(tempPath[0]), tempPath); 163 if (!result) 164 throw GetErrorMessage(GetLastError()); 165 166 std::wstring tempDir(tempPath, result); 167 if (std::wstring(L"\\/").find(tempDir[tempDir.length() - 1]) == std::wstring::npos) 168 tempDir += L"\\"; 169 tempDir += L"eraserInstallBootstrapper\\"; 170 TempDir dir(tempDir); 171 ExtractTempFiles(tempDir); 172 173 //Install the .NET framework 174 if (!HasNetFramework()) 175 InstallNetFramework(tempDir); 176 177 //Then install Eraser! 178 InstallEraser(tempDir); 179 } 180 catch (const std::wstring& e) 181 { 182 MessageBoxW(Application::Get().GetTopWindow().GetHandle(), e.c_str(), 183 L"Eraser Setup", MB_OK | MB_ICONERROR); 184 } 185 186 return 0; 187 } 188 189 bool MainWindow::Create() 190 { 191 if (!InitInstance()) 189 192 return false; 190 193 191 194 HWND hWndPanel = CreateWindowExW(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE, 192 0, 0, 294, 104, hWnd Parent, NULL, hInstance, NULL);195 0, 0, 294, 104, hWnd, NULL, hInstance, NULL); 193 196 hWndStatusLbl = CreateWindowExW(0, STATIC_CLASS, L"Extracting setup files...", 194 197 WS_CHILD | WS_VISIBLE, 13, 38, 270, 19, hWndPanel, NULL, hInstance, NULL); … … 208 211 SendMessage(hWndProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0, 1000)); 209 212 210 ShowWindow(hWndParent, nCmdShow); 211 UpdateWindow(hWndParent); 212 213 try 214 { 215 //OK, now we do the hard work. Create a folder to place our payload into 216 wchar_t tempPath[MAX_PATH]; 217 DWORD result = GetTempPathW(sizeof(tempPath) / sizeof(tempPath[0]), tempPath); 218 if (!result) 219 throw GetErrorMessage(GetLastError()); 220 221 std::wstring tempDir(tempPath, result); 222 if (std::wstring(L"\\/").find(tempDir[tempDir.length() - 1]) == std::wstring::npos) 223 tempDir += L"\\"; 224 tempDir += L"eraserInstallBootstrapper\\"; 225 TempDir dir(tempDir); 226 ExtractTempFiles(tempDir); 227 228 //Install the .NET framework 229 if (!HasNetFramework()) 230 InstallNetFramework(tempDir); 231 232 //Then install Eraser! 233 InstallEraser(tempDir); 234 } 235 catch (const std::wstring& e) 236 { 237 MessageBoxW(GetTopWindow(), e.c_str(), L"Eraser Setup", MB_OK | MB_ICONERROR); 238 } 239 240 return 0; 241 } 242 243 HWND GetTopWindow() 244 { 245 return hWndParent; 246 } 247 248 void SetProgress(float progress) 213 ShowWindow(hWnd, nCmdShow); 214 UpdateWindow(hWnd); 215 } 216 217 bool MainWindow::InitInstance() 218 { 219 WNDCLASSEX wcex; 220 ::ZeroMemory(&wcex, sizeof(wcex)); 221 222 wcex.cbSize = sizeof(WNDCLASSEX); 223 wcex.style = CS_HREDRAW | CS_VREDRAW; 224 wcex.lpfnWndProc = WndProc; 225 wcex.cbClsExtra = 0; 226 wcex.cbWndExtra = 0; 227 wcex.hInstance = hInstance; 228 wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(BOOTSTRAPPER_ICON)); 229 wcex.hCursor = LoadCursor(NULL, IDC_ARROW); 230 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 231 wcex.lpszClassName = szWindowClass; 232 wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(BOOTSTRAPPER_ICON)); 233 RegisterClassExW(&wcex); 234 InitCommonControls(); 235 236 //Create the window 237 hWnd = CreateWindowW(szWindowClass, L"Eraser Setup", WS_CAPTION | WS_SYSMENU, 238 CW_USEDEFAULT, 0, 300, 130, NULL, NULL, hInstance, NULL); 239 240 if (!hWnd) 241 return false; 242 243 //Set default settings (font) 244 SetWindowFont(hWnd); 245 return true; 246 } 247 248 void MainWindow::SetProgress(float progress) 249 249 { 250 250 SetWindowLong(hWndProgressBar, GWL_STYLE, … … 253 253 } 254 254 255 void SetProgressIndeterminate()255 void MainWindow::SetProgressIndeterminate() 256 256 { 257 257 SetWindowLong(hWndProgressBar, GWL_STYLE, … … 260 260 } 261 261 262 void SetMessage(std::wstring message)263 { 264 } 265 266 void Yield()262 void MainWindow::SetMessage(std::wstring message) 263 { 264 } 265 266 void Application::Yield() 267 267 { 268 268 MSG msg;
Note: See TracChangeset
for help on using the changeset viewer.
