Changeset 539
- Timestamp:
- 11/13/08 11:26:52 (5 years ago)
- Location:
- branches/eraser6/Installer/Bootstrapper
- Files:
-
- 3 edited
-
Bootstrapper.cpp (modified) (2 diffs)
-
Bootstrapper.h (modified) (2 diffs)
-
Main.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Installer/Bootstrapper/Bootstrapper.cpp
r538 r539 110 110 //Open the file 111 111 #if _DEBUG 112 HANDLE srcFile = CreateFileW(( GetApplicationPath() + L".7z").c_str(), GENERIC_READ, FILE_SHARE_READ,113 NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);112 HANDLE srcFile = CreateFileW((Application::Get().GetPath() + L".7z").c_str(), 113 GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 114 114 if (srcFile == INVALID_HANDLE_VALUE) 115 115 throw GetErrorMessage(GetLastError()); … … 119 119 fPos.QuadPart = 0; 120 120 #else 121 HANDLE srcFile = CreateFileW( GetApplicationPath().c_str(), GENERIC_READ, FILE_SHARE_READ,122 NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);121 HANDLE srcFile = CreateFileW(Application::Get().GetPath().c_str(), GENERIC_READ, 122 FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 123 123 if (srcFile == INVALID_HANDLE_VALUE) 124 124 throw GetErrorMessage(GetLastError()); -
branches/eraser6/Installer/Bootstrapper/Bootstrapper.h
r538 r539 27 27 #include "resource.h" 28 28 #undef Yield 29 30 class Application31 {32 public:33 /// Gets the Singleton instance of the Application object.34 static Application& Get();35 36 /// Processes messages in the message queue.37 void Yield();38 39 /// Retrieves the MainWindow object representing the Application's top window.40 class MainWindow& GetTopWindow();41 42 private:43 Application();44 };45 29 46 30 class MainWindow … … 86 70 }; 87 71 72 class Application 73 { 74 public: 75 /// Gets the Singleton instance of the Application object. 76 static Application& Get(); 77 78 /// Retrieves the path to the executable file. 79 std::wstring GetPath(); 80 81 /// Processes messages in the message queue. 82 void Yield(); 83 84 /// Retrieves the MainWindow object representing the Application's top window. 85 MainWindow& GetTopWindow(); 86 87 private: 88 /// Constructor. 89 Application(); 90 91 private: 92 /// The Application main window. 93 MainWindow MainWin; 94 }; 95 88 96 /// Formats the system error code using FormatMessage, returning the message as 89 97 /// a std::wstring. 90 98 std::wstring GetErrorMessage(DWORD lastError); 91 92 /// Retrieves the path to the executable file.93 std::wstring GetApplicationPath();94 99 95 100 /// Extracts the setup files to the users' temporary folder. -
branches/eraser6/Installer/Bootstrapper/Main.cpp
r538 r539 37 37 //Static variables 38 38 HINSTANCE hInstance = NULL; 39 MainWindow MainWin;40 39 41 40 bool InitInstance(HINSTANCE hInstance, HWND& hWnd); … … 150 149 151 150 int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, 152 LPTSTR /*lpCmdLine*/, int nCmdShow)151 LPTSTR /*lpCmdLine*/, int /*nCmdShow*/) 153 152 { 154 153 //Create the parent window and the child controls 155 154 ::hInstance = hInstance; 156 MainWin.Create();155 Application::Get(); 157 156 158 157 try … … 185 184 186 185 return 0; 186 } 187 188 Application::Application() 189 { 190 MainWin.Create(); 191 } 192 193 Application& Application::Get() 194 { 195 static Application Instance; 196 return Instance; 197 } 198 199 MainWindow& Application::GetTopWindow() 200 { 201 return MainWin; 202 } 203 204 void Application::Yield() 205 { 206 MSG msg; 207 while (PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE) && msg.message != WM_QUIT) 208 { 209 if (GetMessageW(&msg, NULL, 0, 0) == 0) 210 return; 211 212 TranslateMessage(&msg); 213 DispatchMessage(&msg); 214 } 215 } 216 217 std::wstring Application::GetPath() 218 { 219 wchar_t filePath[MAX_PATH]; 220 DWORD result = GetModuleFileNameW(hInstance, filePath, 221 sizeof(filePath) / sizeof(filePath[0])); 222 223 if (result == 0) 224 throw GetErrorMessage(GetLastError()); 225 return std::wstring(filePath, result); 187 226 } 188 227 … … 211 250 SendMessage(hWndProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0, 1000)); 212 251 213 ShowWindow(hWnd, nCmdShow);252 ShowWindow(hWnd, SW_SHOWDEFAULT); 214 253 UpdateWindow(hWnd); 254 return true; 215 255 } 216 256 … … 264 304 } 265 305 266 void Application::Yield()267 {268 MSG msg;269 while (PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE) && msg.message != WM_QUIT)270 {271 if (GetMessageW(&msg, NULL, 0, 0) == 0)272 return;273 274 TranslateMessage(&msg);275 DispatchMessage(&msg);276 }277 }278 279 std::wstring GetApplicationPath()280 {281 wchar_t filePath[MAX_PATH];282 DWORD result = GetModuleFileNameW(hInstance, filePath,283 sizeof(filePath) / sizeof(filePath[0]));284 285 if (result == 0)286 throw GetErrorMessage(GetLastError());287 return std::wstring(filePath, result);288 }289 290 306 std::wstring GetErrorMessage(DWORD lastError) 291 307 {
Note: See TracChangeset
for help on using the changeset viewer.
