VirtualBox

Changeset 23866 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Oct 19, 2009 12:55:05 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53635
Message:

VbglR3: Guest Additions version lookup on non-Windows platforms.

Location:
trunk/src/VBox/Additions/common/VBoxGuestLib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk

    r23856 r23866  
    104104        VBoxGuestR3LibTime.cpp
    105105endif
    106 
     106#VBoxGuestR3LibMisc.cpp uses VBOX_SVN_REV.
     107VBoxGuestR3LibMisc.cpp_DEFS = VBOX_SVN_REV=$(VBOX_SVN_REV)
     108VBoxGuestR3LibMisc.cpp_DEPS = $(VBOX_SVN_REV_KMK)
    107109
    108110#
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp

    r23856 r23866  
    2525*******************************************************************************/
    2626#include <iprt/mem.h>
     27#include <iprt/string.h>
    2728#include <VBox/log.h>
     29#include <VBox/version.h>
    2830#include "VBGLR3Internal.h"
    2931
     
    194196
    195197
    196 /** @todo Docs */
     198/**
     199 * Retrieves the installed Guest Additions version/revision.
     200 *
     201 * @returns IPRT status value
     202 * @param   ppszVer    Receives pointer of allocated version string. NULL is accepted.
     203 *                     The returned pointer must be freed using RTStrFree().
     204 * @param   ppszRev    Receives pointer of allocated revision string. NULL is accepted.
     205 *                     The returned pointer must be freed using RTStrFree().
     206 */
    197207VBGLR3DECL(int) VbglR3GetAdditionsVersion(char **ppszVer, char **ppszRev)
    198208{
     
    231241        DWORD dwType;
    232242        DWORD dwSize = 32;
    233         char *pszVer = (char*)RTMemAlloc(dwSize);
    234         if (pszVer)
     243        if (ppszVer)
    235244        {
    236             if (ERROR_SUCCESS == RegQueryValueEx(hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)pszVer, &dwSize))
    237                 *ppszVer = pszVer;
     245            char *pszVer = (char*)RTMemAlloc(dwSize);
     246            if (pszVer)
     247            {
     248                if (ERROR_SUCCESS == RegQueryValueEx(hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)pszVer, &dwSize))
     249                    *ppszVer = pszVer;
     250            }
    238251        }
    239252        /* Revision. */
    240253        if (ppszRev)
    241254        {
    242             dwSize = 32;
     255            dwSize = 32; /* Reset */
    243256            char *pszRev = (char*)RTMemAlloc(dwSize);
    244             if (ERROR_SUCCESS == RegQueryValueEx(hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)pszRev, &dwSize))
    245                 *ppszRev = pszRev;
     257            if (pszRev)
     258            {
     259                if (ERROR_SUCCESS == RegQueryValueEx(hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)pszRev, &dwSize))
     260                    *ppszRev = pszRev;
     261            }
    246262        }
    247263    }
    248264    rc = RTErrConvertFromWin32(r);
    249 
    250265    if (NULL != hKey)
    251266        RegCloseKey(hKey);
    252267#else
     268    /* On non-Windows platforms just return the compile-time version string atm. */
     269    /* Version. */
     270    if (ppszVer)
     271        rc = RTStrAPrintf(ppszVer, "%s", VBOX_VERSION_STRING);
     272    /* Revision. */
     273    if (ppszRev)
     274        rc = RTStrAPrintf(ppszRev, "%s", VBOX_SVN_REV);
    253275#endif /* RT_OS_WINDOWS */
    254276    return rc;
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