summaryrefslogtreecommitdiffstats
path: root/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp')
-rw-r--r--src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp b/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp
index f02447bc..d76cb438 100644
--- a/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp
+++ b/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp
@@ -38,27 +38,28 @@
#include <iprt/string.h>
#include <iprt/utf16.h>
+#include "VBoxCommon.h"
+
+#ifndef TESTCASE
+/**
+ * Retrieves a MSI property (in UTF-16).
+ *
+ * Convenience function for VBoxGetMsiProp().
+ *
+ * @returns VBox status code.
+ * @param hMsi MSI handle to use.
+ * @param pwszName Name of property to retrieve.
+ * @param pwszValueBuf Where to store the allocated value on success.
+ * @param cwcValueBuf Size (in WCHARs) of \a pwszValueBuf.
+ */
UINT VBoxGetMsiProp(MSIHANDLE hMsi, const WCHAR *pwszName, WCHAR *pwszValueBuf, DWORD cwcValueBuf)
{
- RT_BZERO(pwszValueBuf, cwcValueBuf * sizeof(pwszValueBuf[0]));
-
- /** @todo r=bird: why do we need to query the size first and then the data.
- * The API should be perfectly capable of doing that without our help. */
- DWORD cwcNeeded = 0;
- UINT uiRet = MsiGetPropertyW(hMsi, pwszName, L"", &cwcNeeded);
- if (uiRet == ERROR_MORE_DATA)
- {
- ++cwcNeeded; /* On output does not include terminating null, so add 1. */
-
- if (cwcNeeded > cwcValueBuf)
- return ERROR_MORE_DATA;
- uiRet = MsiGetPropertyW(hMsi, pwszName, pwszValueBuf, &cwcNeeded);
- }
- return uiRet;
+ RT_BZERO(pwszValueBuf, cwcValueBuf * sizeof(WCHAR));
+ return MsiGetPropertyW(hMsi, pwszName, pwszValueBuf, &cwcValueBuf);
}
+#endif
-#if 0 /* unused */
/**
* Retrieves a MSI property (in UTF-8).
*
@@ -77,7 +78,7 @@ int VBoxGetMsiPropUtf8(MSIHANDLE hMsi, const char *pcszName, char **ppszValue)
if (RT_SUCCESS(rc))
{
WCHAR wszValue[1024]; /* 1024 should be enough for everybody (tm). */
- if (VBoxGetMsiProp(hMsi, pwszName, wszValue, sizeof(wszValue)) == ERROR_SUCCESS)
+ if (VBoxGetMsiProp(hMsi, pwszName, wszValue, RT_ELEMENTS(wszValue)) == ERROR_SUCCESS)
rc = RTUtf16ToUtf8(wszValue, ppszValue);
else
rc = VERR_NOT_FOUND;
@@ -87,12 +88,13 @@ int VBoxGetMsiPropUtf8(MSIHANDLE hMsi, const char *pcszName, char **ppszValue)
return rc;
}
-#endif
+#ifndef TESTCASE
UINT VBoxSetMsiProp(MSIHANDLE hMsi, const WCHAR *pwszName, const WCHAR *pwszValue)
{
return MsiSetPropertyW(hMsi, pwszName, pwszValue);
}
+#endif
UINT VBoxSetMsiPropDWORD(MSIHANDLE hMsi, const WCHAR *pwszName, DWORD dwVal)
{