Changeset 536
- Timestamp:
- 11/13/2008 10:27:23 AM (3 years ago)
- Location:
- branches/eraser6/Installer/Bootstrapper
- Files:
-
- 3 edited
-
Bootstrapper.cpp (modified) (1 diff)
-
Bootstrapper.h (modified) (1 diff)
-
Main.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Installer/Bootstrapper/Bootstrapper.cpp
r535 r536 227 227 } 228 228 229 void InstallNetFramework() 230 { 231 } 229 int CreateProcessAndWait(const std::wstring& commandLine) 230 { 231 //Get a mutable version of the command line 232 wchar_t* cmdLine = new wchar_t[commandLine.length() + 1]; 233 wcscpy(cmdLine, commandLine.c_str()); 234 235 //Launch the process 236 STARTUPINFOW startupInfo; 237 PROCESS_INFORMATIONW pInfo; 238 ::ZeroMemory(&startupInfo, sizeof(startupInfo)); 239 ::ZeroMemory(&pInfo, sizeof(pInfo)); 240 if (!CreateProcessW(NULL, cmdLine, NULL, NULL, false, 0, NULL, NULL, &startupInfo, 241 &pInfo)) 242 { 243 delete[] cmdLine; 244 throw GetErrorMessage(GetLastError()); 245 } 246 delete[] cmdLine; 247 248 //Ok the process was created, wait for it to terminate. 249 DWORD lastWait = 0; 250 while ((lastWait = WaitForSingleObject(pInfo.hProcess, 50)) == WAIT_TIMEOUT) 251 Yield(); 252 if (lastWait == WAIT_ABANDONED) 253 throw std::wstring(L"The condition waiting on the termination of the .NET installer was abandoned."); 254 255 //Get the exit code 256 DWORD exitCode = 0; 257 if (!GetExitCodeProcess(pInfo.hProcess, &exitCode)) 258 throw GetErrorMessage(GetLastError()); 259 260 //Clean up 261 CloseHandle(pInfo.hProcess); 262 CloseHandle(pInfo.hThread); 263 264 //Return the exit code. 265 return exitCode; 266 } 267 268 bool InstallNetFramework(std::wstring tempDir) 269 { 270 //Update the UI 271 SetProgressIndeterminate(); 272 SetMessage(L"Installing .NET Framework..."); 273 274 //Get the path to the installer 275 if (std::wstring(L"\\/").find(tempDir[tempDir.length() - 1])) 276 tempDir += L"\\"; 277 std::wstring commandLine('"' + tempDir); 278 commandLine += L"dotnetfx.exe\""; 279 280 //And the return code is true if the process exited with 0. 281 return CreateProcessAndWait(commandLine) == 0; 282 } 283 284 bool InstallEraser(std::wstring tempDir) 285 { 286 SetProgressIndeterminate(); 287 SetMessage(L"Installing Eraser..."); 288 289 //Determine the system architecture. 290 SYSTEM_INFO sysInfo; 291 ZeroMemory(&sysInfo, sizeof(sysInfo)); 292 sysInfo.cbSize = sizeof(sysInfo); 293 GetSystemInfo(&sysInfo); 294 295 if (std::wstring(L"\\/").find(tempDir[tempDir.length() - 1])) 296 tempDir += L"\\"; 297 switch (sysInfo.wProcessorArchitecture) 298 { 299 case PROCESSOR_ARCHITECTURE_AMD64: 300 tempDir += L"Eraser (x64).msi"; 301 break; 302 303 default: 304 tempDir += L"Eraser (x86).msi"; 305 break; 306 } 307 308 std::wstring commandLine(L"msiexec.exe /i "); 309 commandLine += '"' + tempDir + '"'; 310 311 //And the return code is true if the process exited with 0. 312 return CreateProcessAndWait(commandLine) == 0; 313 } -
branches/eraser6/Installer/Bootstrapper/Bootstrapper.h
r535 r536 53 53 54 54 /// Extracts the included .NET framework installer and runs it. 55 void InstallNetFramework(); 55 /// 56 /// \param[in] srcDir The path to the directory holding dotnetfx.exe. 57 /// \return True if the .NET framework was successfully installed. 58 bool InstallNetFramework(std::wstring srcDir); 59 60 /// Installs the version of Eraser suited for the current operating platform. 61 /// 62 /// \param[in] srcDir The path to the directory holding the installers. 63 /// \return True if Eraser was successfully installed. 64 bool InstallEraser(std::wstring srcDir); -
branches/eraser6/Installer/Bootstrapper/Main.cpp
r535 r536 63 63 ~TempDir() 64 64 { 65 //TODO: remove files in the directory. 65 //Clean up the files in the directory. 66 67 66 68 RemoveDirectoryW(DirName.c_str()); 67 69 } … … 218 220 ExtractTempFiles(tempDir); 219 221 220 // Main message loop: 222 //Install the .NET framework 223 if (!HasNetFramework()) 224 InstallNetFramework(tempDir); 225 226 //Then install Eraser! 227 InstallEraser(); 228 229 //Main message loop 221 230 MSG msg; 222 231 while (GetMessage(&msg, NULL, 0, 0))
Note: See TracChangeset
for help on using the changeset viewer.
