MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / getWindowsVersion

Method getWindowsVersion

source/ui/data/boxedContainer.cpp:510–571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508}
509
510BString BoxedContainer::getWindowsVersion() {
511 BString userVer = getWindowsVersion2();
512 if (userVer.length()) {
513 for (auto& winVer : BoxedwineData::getWinVersions()) {
514 if (userVer == winVer.szVersion) {
515 return B(winVer.szDescription);
516 }
517 }
518 }
519 BoxedReg reg(this, true);
520 int platform = VER_PLATFORM_WIN32s, major = 0, minor = 0, build = 0;
521
522 BString ver;
523 BString type;
524 BString build_str;
525 BString best;
526
527 reg.readKey(szKeyNT, "CurrentVersion", ver);
528
529 if (ver.length()) {
530 reg.readKey(szKeyNT, "CurrentBuildNumber", build_str);
531 platform = VER_PLATFORM_WIN32_NT;
532 build = build_str.toInt();
533 reg.readKey(szKeyProdNT, "ProductType", type);
534 } else {
535 reg.readKey(szKey9x, "VersionNumber", ver);
536 if (ver.length()) {
537 platform = VER_PLATFORM_WIN32_WINDOWS;
538 }
539 }
540 if (ver.length()) {
541 if (!ver.contains('.')) {
542 major = ver.toInt();
543 } else {
544 std::vector<BString> parts;
545 ver.split('.', parts);
546 if (parts.size() >= 2) {
547 major = parts[0].toInt();
548 minor = parts[1].toInt();
549 } else {
550 return B("");
551 }
552 if (parts.size() >= 3) {
553 build = parts[2].toInt();
554 }
555 }
556 }
557 for (auto& winVer : BoxedwineData::getWinVersions()) {
558 if ((int)winVer.dwPlatformId != platform) continue;
559 if (winVer.szCurrentVersion && ver != winVer.szCurrentVersion) continue;
560 if (!winVer.szCurrentVersion && (int)winVer.dwMajorVersion != major) continue;
561 if (type.length() && type != winVer.szProductType) continue;
562 best = winVer.szDescription;
563 if (build && (int)winVer.dwBuildNumber == build) {
564 return B(winVer.szDescription);
565 }
566 if (platform == VER_PLATFORM_WIN32_WINDOWS && ((int)winVer.dwMinorVersion == minor)) {
567 return B(winVer.szDescription);

Callers 1

setCurrentContainerMethod · 0.80

Calls 7

BFunction · 0.85
readKeyMethod · 0.80
toIntMethod · 0.80
lengthMethod · 0.45
containsMethod · 0.45
splitMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected