1
/* $Id: VBoxCommon.cpp 37289 2011-06-01 11:59:23Z vboxsync $ */
1
/* $Id: VBoxCommon.cpp $ */
3
3
* VBoxCommon - Misc helper routines for install helper.
7
* Copyright (C) 2008-2010 Oracle Corporation
7
* Copyright (C) 2008-2011 Oracle Corporation
9
9
* This file is part of VirtualBox Open Source Edition (OSE), as
10
10
* available from http://www.virtualbox.org. This file is free software;
23
27
#include <msiquery.h>
26
#if (_MSC_VER < 1400) /* Provide _stprintf_s to VC < 8.0. */
27
int _stprintf_s(TCHAR *buffer, size_t cbBuffer, const TCHAR *format, ...)
30
#if (_MSC_VER < 1400) /* Provide swprintf_s to VC < 8.0. */
31
int swprintf_s(WCHAR *buffer, size_t cbBuffer, const WCHAR *format, ...)
31
va_start(args, format);
32
ret = _vsntprintf(buffer, cbBuffer, format, args);
36
ret = _vsnwprintf(buffer, cbBuffer, format, va);
38
UINT VBoxGetProperty(MSIHANDLE a_hModule, TCHAR* a_pszName, TCHAR* a_pValue, DWORD a_dwSize)
42
UINT VBoxGetProperty(MSIHANDLE a_hModule, WCHAR *a_pwszName, WCHAR *a_pwszValue, DWORD a_dwSize)
40
UINT uiRet = ERROR_SUCCESS;
41
44
DWORD dwBuffer = 0;
43
uiRet = MsiGetProperty(a_hModule, a_pszName, TEXT(""), &dwBuffer);
44
if (ERROR_MORE_DATA == uiRet)
45
UINT uiRet = MsiGetPropertyW(a_hModule, a_pwszName, L"", &dwBuffer);
46
if (uiRet == ERROR_MORE_DATA)
46
48
++dwBuffer; /* On output does not include terminating null, so add 1. */
48
50
if (dwBuffer > a_dwSize)
49
51
return ERROR_MORE_DATA;
51
ZeroMemory(a_pValue, a_dwSize);
52
uiRet = MsiGetProperty(a_hModule, a_pszName, a_pValue, &dwBuffer);
53
ZeroMemory(a_pwszValue, a_dwSize);
54
uiRet = MsiGetPropertyW(a_hModule, a_pwszName, a_pwszValue, &dwBuffer);
57
UINT VBoxSetProperty(MSIHANDLE a_hModule, TCHAR* a_pszName, TCHAR* a_pValue)
59
UINT VBoxSetProperty(MSIHANDLE a_hModule, WCHAR *a_pwszName, WCHAR *a_pwszValue)
59
return MsiSetProperty(a_hModule, a_pszName, a_pValue);
61
return MsiSetPropertyW(a_hModule, a_pwszName, a_pwszValue);