1 | /* $Id: VBoxCommon.cpp 37289 2011-06-01 11:59:23Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxCommon - Misc helper routines for install helper.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2008-2010 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #include <windows.h>
|
---|
19 | #include <tchar.h>
|
---|
20 | #include <stdio.h>
|
---|
21 |
|
---|
22 | #include <msi.h>
|
---|
23 | #include <msiquery.h>
|
---|
24 |
|
---|
25 |
|
---|
26 | #if (_MSC_VER < 1400) /* Provide _stprintf_s to VC < 8.0. */
|
---|
27 | int _stprintf_s(TCHAR *buffer, size_t cbBuffer, const TCHAR *format, ...)
|
---|
28 | {
|
---|
29 | int ret;
|
---|
30 | va_list args;
|
---|
31 | va_start(args, format);
|
---|
32 | ret = _vsntprintf(buffer, cbBuffer, format, args);
|
---|
33 | va_end(args);
|
---|
34 | return ret;
|
---|
35 | }
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | UINT VBoxGetProperty(MSIHANDLE a_hModule, TCHAR* a_pszName, TCHAR* a_pValue, DWORD a_dwSize)
|
---|
39 | {
|
---|
40 | UINT uiRet = ERROR_SUCCESS;
|
---|
41 | DWORD dwBuffer = 0;
|
---|
42 |
|
---|
43 | uiRet = MsiGetProperty(a_hModule, a_pszName, TEXT(""), &dwBuffer);
|
---|
44 | if (ERROR_MORE_DATA == uiRet)
|
---|
45 | {
|
---|
46 | ++dwBuffer; /* On output does not include terminating null, so add 1. */
|
---|
47 |
|
---|
48 | if (dwBuffer > a_dwSize)
|
---|
49 | return ERROR_MORE_DATA;
|
---|
50 |
|
---|
51 | ZeroMemory(a_pValue, a_dwSize);
|
---|
52 | uiRet = MsiGetProperty(a_hModule, a_pszName, a_pValue, &dwBuffer);
|
---|
53 | }
|
---|
54 | return uiRet;
|
---|
55 | }
|
---|
56 |
|
---|
57 | UINT VBoxSetProperty(MSIHANDLE a_hModule, TCHAR* a_pszName, TCHAR* a_pValue)
|
---|
58 | {
|
---|
59 | return MsiSetProperty(a_hModule, a_pszName, a_pValue);
|
---|
60 | }
|
---|
61 |
|
---|