Changeset 1445 for branches/eraser6/6.0
- Timestamp:
- 1/4/2010 10:12:06 AM (3 years ago)
- Location:
- branches/eraser6/6.0
- Files:
-
- 4 edited
- 1 copied
-
. (modified) (1 prop)
-
Installer/Bootstrapper/Bootstrapper.cpp (modified) (6 diffs)
-
Installer/Bootstrapper/Bootstrapper.vcproj (modified) (1 diff)
-
Installer/Bootstrapper/Handle.h (copied) (copied from trunk/eraser6/Installer/Bootstrapper/Handle.h)
-
Installer/Bootstrapper/stdafx.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/6.0
- Property svn:mergeinfo changed
/trunk/eraser6 merged: 1443-1444
- Property svn:mergeinfo changed
-
branches/eraser6/6.0/Installer/Bootstrapper/Bootstrapper.cpp
r1360 r1445 22 22 #include "stdafx.h" 23 23 #include "Bootstrapper.h" 24 25 class Handle 26 { 27 public: 28 Handle(HANDLE handle) 29 { 30 thisHandle = handle; 31 } 32 33 ~Handle() 34 { 35 CloseHandle(thisHandle); 36 } 37 38 operator HANDLE() 39 { 40 return thisHandle; 41 } 42 43 private: 44 HANDLE thisHandle; 45 }; 24 #include "Handle.h" 46 25 47 26 const wchar_t *ResourceName = MAKEINTRESOURCE(101); … … 52 31 DWORD lastOperation = 0; 53 32 { 54 Handle srcFile(CreateFileW(Application::Get().GetPath().c_str(), GENERIC_READ,33 Handle<HANDLE> srcFile(CreateFileW(Application::Get().GetPath().c_str(), GENERIC_READ, 55 34 FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)); 56 35 if (srcFile == INVALID_HANDLE_VALUE) … … 58 37 59 38 //Copy ourselves 60 Handle destFile(CreateFileW(destItem.c_str(), GENERIC_WRITE, 0, NULL,39 Handle<HANDLE> destFile(CreateFileW(destItem.c_str(), GENERIC_WRITE, 0, NULL, 61 40 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)); 62 41 if (destFile == INVALID_HANDLE_VALUE) … … 74 53 75 54 //Read the package into memory 76 Handle packageFile(CreateFileW(package.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL,55 Handle<HANDLE> packageFile(CreateFileW(package.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, 77 56 OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)); 78 57 if (packageFile == INVALID_HANDLE_VALUE) … … 271 250 sizeof(fileName) / sizeof(fileName[0]) - wcslen(baseFileName), fileExt); 272 251 273 Handle destFile(CreateFileW((pathToExtract + fileName).c_str(), GENERIC_WRITE, 0,274 NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL));252 Handle<HANDLE> destFile(CreateFileW((pathToExtract + fileName).c_str(), GENERIC_WRITE, 253 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)); 275 254 if (destFile == INVALID_HANDLE_VALUE) 276 255 throw GetErrorMessage(GetLastError()); … … 300 279 bool HasNetFramework() 301 280 { 302 HKEY key; 303 std::wstring highestVer; 304 std::wstring keys[] = { L"v3.5" }; 305 306 for (int i = 0, j = sizeof(keys) / sizeof(keys[0]); i != j; ++i) 307 { 308 //Open the key for reading 309 DWORD result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 310 (L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\" + keys[i]).c_str(), 311 0, KEY_READ, &key); 312 313 //Retry for 64-bit WoW 281 const std::wstring versionKey(L"v3.5"); 282 283 //Open the key for reading 284 Handle<HKEY> key; 285 DWORD result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 286 (L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\" + versionKey).c_str(), 287 0, KEY_READ, key); 288 289 //Retry for 64-bit WoW 290 if (result == ERROR_FILE_NOT_FOUND) 291 { 292 result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 293 (L"SOFTWARE\\Wow6432Node\\Microsoft\\NET Framework Setup\\NDP\\" + versionKey).c_str(), 294 0, KEY_READ, key); 295 314 296 if (result == ERROR_FILE_NOT_FOUND) 315 { 316 result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 317 (L"SOFTWARE\\Wow6432Node\\Microsoft\\NET Framework Setup\\NDP\\" + keys[i]).c_str(), 318 0, KEY_READ, &key); 319 320 if (result == ERROR_FILE_NOT_FOUND) 321 continue; 322 } 323 324 if (result != ERROR_SUCCESS) 325 throw GetErrorMessage(result); 326 327 //Query the Installed string 328 DWORD installedVal = 0; 329 DWORD bufferSize = sizeof(installedVal); 330 result = RegQueryValueExW(key, L"Install", NULL, NULL, (BYTE*)&installedVal, 331 &bufferSize); 332 if (result != ERROR_SUCCESS && result != ERROR_MORE_DATA) 333 throw GetErrorMessage(result); 334 if (installedVal == 1) 335 highestVer = keys[i].substr(1); 336 RegCloseKey(key); 337 } 338 339 return !highestVer.empty(); 297 return false; 298 } 299 300 if (result != ERROR_SUCCESS) 301 throw GetErrorMessage(result); 302 303 //Query the Install string 304 wchar_t buffer[32]; 305 DWORD bufferSize = sizeof(buffer); 306 ::ZeroMemory(buffer, sizeof(buffer)); 307 result = RegQueryValueExW(key, L"Install", NULL, NULL, reinterpret_cast<BYTE*>(buffer), 308 &bufferSize); 309 if (result != ERROR_SUCCESS && result != ERROR_MORE_DATA) 310 throw GetErrorMessage(result); 311 312 //If we got more data than we wanted or if the value is not zero, it's invalid. 313 if (bufferSize != sizeof(DWORD) || *reinterpret_cast<DWORD*>(buffer) == 0) 314 return false; 315 316 //Next get the exact version installed 317 bufferSize = sizeof(buffer); 318 ::ZeroMemory(buffer, sizeof(buffer)); 319 result = RegQueryValueExW(key, L"Version", NULL, NULL, reinterpret_cast<BYTE*>(buffer), 320 &bufferSize); 321 if ((result != ERROR_SUCCESS && result != ERROR_MORE_DATA) || bufferSize == sizeof(buffer)) 322 throw GetErrorMessage(result); 323 324 //Ensure that the version string is NULL terminated 325 buffer[bufferSize / sizeof(wchar_t)] = L'\0'; 326 327 //Split the version into its four components 328 int versionComponents[] = { 0, 0, 0, 0 }; 329 wchar_t* previousDot = buffer - 1; 330 wchar_t* nextDot = NULL; 331 for (unsigned i = 0; i < sizeof(versionComponents) / sizeof(versionComponents[0]); ++i) 332 { 333 nextDot = wcschr(previousDot + 1, L'.'); 334 versionComponents[i] = boost::lexical_cast<int>( 335 nextDot ? std::wstring(++previousDot, nextDot) : std::wstring(++previousDot)); 336 if (!nextDot) 337 break; 338 339 previousDot = nextDot; 340 } 341 342 return versionComponents[0] == 3 && versionComponents[1] == 5 && versionComponents[2] >= 30729; 340 343 } 341 344 -
branches/eraser6/6.0/Installer/Bootstrapper/Bootstrapper.vcproj
r1277 r1445 218 218 </File> 219 219 <File 220 RelativePath=".\Handle.h" 221 > 222 </File> 223 <File 220 224 RelativePath=".\Resource.h" 221 225 > -
branches/eraser6/6.0/Installer/Bootstrapper/stdafx.h
r1360 r1445 45 45 #include <C/Archive/7z/7zExtract.h> 46 46 } 47 48 //Boost 49 #include <boost/lexical_cast.hpp>
Note: See TracChangeset
for help on using the changeset viewer.
