VirtualBox

Changeset 108072 in vbox for trunk/src/VBox/Installer


Ignore:
Timestamp:
Feb 5, 2025 2:48:28 PM (3 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167365
Message:

Windows/InstallHelper: Replaced RegQueryValueExW() for querying DWORDs with VBoxMsiRegQueryDWORD(). bugref:10762

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxInstallHelper.cpp

    r108069 r108072  
    10531053UINT __stdcall IsMSCRTInstalled(MSIHANDLE hModule)
    10541054{
    1055     HKEY hKeyVS = NULL;
     1055    HKEY hKey;
    10561056    LSTATUS lrc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
    10571057                                L"SOFTWARE\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\X64",
    1058                                 0, KEY_READ, &hKeyVS);
     1058                                0, KEY_READ, &hKey);
    10591059    if (lrc == ERROR_SUCCESS)
    10601060    {
    1061         DWORD dwVal = 0;
    1062         DWORD cbVal = sizeof(dwVal);
    1063         lrc = RegQueryValueExW(hKeyVS, L"Installed", NULL /* lpReserved */, NULL /* lpType */, (LPBYTE)&dwVal, &cbVal);
    1064         if (lrc == ERROR_SUCCESS)
     1061        DWORD dwVal;
     1062        int rc = VBoxMsiRegQueryDWORD(hModule, hKey, "Installed", &dwVal);
     1063        if (RT_SUCCESS(rc))
    10651064        {
    10661065            if (dwVal >= 1)
    10671066            {
    10681067                DWORD dwMaj;
    1069                 lrc = RegQueryValueExW(hKeyVS, L"Major", NULL /* lpReserved */, NULL /* lpType */, (LPBYTE)&dwMaj, &cbVal);
    1070                 if (lrc == ERROR_SUCCESS)
     1068                rc = VBoxMsiRegQueryDWORD(hModule, hKey, "Major", &dwMaj);
     1069                if (RT_SUCCESS(rc))
    10711070                {
    10721071                    VBoxMsiSetPropDWORD(hModule, L"VBOX_MSCRT_VER_MAJ", dwMaj);
    10731072
    1074                     DWORD dwMin = 0;
    1075                     lrc = RegQueryValueExW(hKeyVS, L"Minor", NULL /* lpReserved */, NULL /* lpType */, (LPBYTE)&dwMin, &cbVal);
    1076                     if (lrc == ERROR_SUCCESS)
     1073                    DWORD dwMin;
     1074                    lrc = VBoxMsiRegQueryDWORD(hModule, hKey, "Minor", &dwMin);
     1075                    if (RT_SUCCESS(rc))
    10771076                    {
    10781077                        VBoxMsiSetPropDWORD(hModule, L"VBOX_MSCRT_VER_MIN", dwMin);
     
    10981097        else
    10991098            logStringF(hModule, "IsMSCRTInstalled: Found, but 'Installed' key not present (lrc=%d)", lrc);
     1099
     1100        RegCloseKey(hKey);
    11001101    }
    11011102
     
    11231124     *       number from the registry.
    11241125     */
    1125     HKEY hKeyCurVer = NULL;
    1126     LSTATUS lrc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKeyCurVer);
     1126    HKEY hKey;
     1127    LSTATUS lrc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey);
    11271128    if (lrc == ERROR_SUCCESS)
    11281129    {
    1129         DWORD dwVal = 0;
    1130         DWORD cbVal = sizeof(dwVal);
    1131         lrc = RegQueryValueExW(hKeyCurVer, L"CurrentMajorVersionNumber", NULL /* lpReserved */, NULL /* lpType */, (LPBYTE)&dwVal, &cbVal);
    1132         if (lrc == ERROR_SUCCESS)
    1133         {
    1134             logStringF(hModule, "IsWindows10/CurrentMajorVersionNumber: %u", dwVal);
    1135 
    1136             VBoxMsiSetProp(hModule, L"VBOX_IS_WINDOWS_10", dwVal >= 10 ? L"1" : L"");
     1130        DWORD dwMaj;
     1131        int rc = VBoxMsiRegQueryDWORD(hModule, hKey, "CurrentMajorVersionNumber", &dwMaj);
     1132        if (RT_SUCCESS(rc))
     1133        {
     1134            VBoxMsiSetProp(hModule, L"VBOX_IS_WINDOWS_10", dwMaj >= 10 ? L"1" : L"");
     1135
    11371136        }
    11381137        else
    1139             logStringF(hModule, "IsWindows10/RegOpenKeyExW: Error reading CurrentMajorVersionNumber (%ld)", lrc);
    1140 
    1141         RegCloseKey(hKeyCurVer);
     1138            logStringF(hModule, "IsWindows10: Error reading CurrentMajorVersionNumber (%Rrc)", rc);
     1139
     1140        RegCloseKey(hKey);
    11421141    }
    11431142    else
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette