diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 03:01:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 03:01:46 +0000 |
commit | f8fe689a81f906d1b91bb3220acde2a4ecb14c5b (patch) | |
tree | 26484e9d7e2c67806c2d1760196ff01aaa858e8c /src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp | |
parent | Initial commit. (diff) | |
download | virtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.tar.xz virtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.zip |
Adding upstream version 6.0.4-dfsg.upstream/6.0.4-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp')
-rw-r--r-- | src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp b/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp new file mode 100644 index 00000000..8dd656c1 --- /dev/null +++ b/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp @@ -0,0 +1,63 @@ +/* $Id: VBoxCommon.cpp $ */ +/** @file + * VBoxCommon - Misc helper routines for install helper. + */ + +/* + * Copyright (C) 2008-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + + +/********************************************************************************************************************************* +* Header Files * +*********************************************************************************************************************************/ +#include <iprt/win/windows.h> +#include <tchar.h> +#include <stdio.h> + +#include <msi.h> +#include <msiquery.h> + + +#if (_MSC_VER < 1400) /* Provide swprintf_s to VC < 8.0. */ +int swprintf_s(WCHAR *buffer, size_t cbBuffer, const WCHAR *format, ...) +{ + int ret; + va_list va; + va_start(va, format); + ret = _vsnwprintf(buffer, cbBuffer, format, va); + va_end(va); + return ret; +} +#endif + +UINT VBoxGetProperty(MSIHANDLE a_hModule, WCHAR *a_pwszName, WCHAR *a_pwszValue, DWORD a_dwSize) +{ + DWORD dwBuffer = 0; + UINT uiRet = MsiGetPropertyW(a_hModule, a_pwszName, L"", &dwBuffer); + if (uiRet == ERROR_MORE_DATA) + { + ++dwBuffer; /* On output does not include terminating null, so add 1. */ + + if (dwBuffer > a_dwSize) + return ERROR_MORE_DATA; + + ZeroMemory(a_pwszValue, a_dwSize); + uiRet = MsiGetPropertyW(a_hModule, a_pwszName, a_pwszValue, &dwBuffer); + } + return uiRet; +} + +UINT VBoxSetProperty(MSIHANDLE a_hModule, WCHAR *a_pwszName, WCHAR *a_pwszValue) +{ + return MsiSetPropertyW(a_hModule, a_pwszName, a_pwszValue); +} + |