Changeset 537 for branches/eraser6/Installer/Bootstrapper/Main.cpp
- Timestamp:
- 11/13/2008 10:54:09 AM (4 years ago)
- File:
-
- 1 edited
-
branches/eraser6/Installer/Bootstrapper/Main.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Installer/Bootstrapper/Main.cpp
r536 r537 57 57 : DirName(dirName) 58 58 { 59 if (std::wstring(L"\\/").find(dirName[dirName.length() - 1]) == std::wstring::npos) 60 dirName += L"\\"; 61 59 62 if (!CreateDirectoryW(dirName.c_str(), NULL)) 60 63 throw GetErrorMessage(GetLastError()); … … 64 67 { 65 68 //Clean up the files in the directory. 66 67 69 WIN32_FIND_DATAW findData; 70 ZeroMemory(&findData, sizeof(findData)); 71 HANDLE findHandle = FindFirstFileW((DirName + L"*").c_str(), &findData); 72 if (findHandle == INVALID_HANDLE_VALUE) 73 throw GetErrorMessage(GetLastError()); 74 75 //Delete! 76 do 77 DeleteFileW((DirName + findData.cFileName).c_str()); 78 while (FindNextFileW(findHandle, &findData)); 79 80 //Clean up. 81 FindClose(findHandle); 68 82 RemoveDirectoryW(DirName.c_str()); 69 83 } … … 155 169 } 156 170 157 case WM_PAINT:158 {159 PAINTSTRUCT ps;160 HDC hdc = BeginPaint(hWnd, &ps);161 162 // TODO: Add any drawing code here...163 EndPaint(hWnd, &ps);164 break;165 }166 167 171 case WM_DESTROY: 168 172 PostQuitMessage(0); … … 207 211 UpdateWindow(hWndParent); 208 212 209 //OK, now we do the hard work. Create a folder to place our payload into 210 wchar_t tempPath[MAX_PATH]; 211 DWORD result = GetTempPathW(sizeof(tempPath) / sizeof(tempPath[0]), tempPath); 212 if (!result) 213 throw GetErrorMessage(GetLastError()); 214 215 std::wstring tempDir(tempPath, result); 216 if (std::wstring(L"\\/").find(tempDir[tempDir.length() - 1]) == std::wstring::npos) 217 tempDir += L"\\"; 218 tempDir += L"eraserInstallBootstrapper\\"; 219 TempDir dir(tempDir); 220 ExtractTempFiles(tempDir); 221 222 //Install the .NET framework 223 if (!HasNetFramework()) 224 InstallNetFramework(tempDir); 225 226 //Then install Eraser! 227 InstallEraser(); 228 229 //Main message loop 230 MSG msg; 231 while (GetMessage(&msg, NULL, 0, 0)) 232 { 233 TranslateMessage(&msg); 234 DispatchMessage(&msg); 235 } 236 237 return (int) msg.wParam; 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; 238 241 } 239 242 … … 265 268 MSG msg; 266 269 while (PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE) && msg.message != WM_QUIT) 267 { 270 { 271 if (GetMessageW(&msg, NULL, 0, 0) == 0) 272 return; 273 268 274 TranslateMessage(&msg); 269 275 DispatchMessage(&msg); 270 }276 } 271 277 } 272 278
Note: See TracChangeset
for help on using the changeset viewer.
