VirtualBox

source: vbox/trunk/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp@ 84825

Last change on this file since 84825 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1/* $Id: VBoxCommon.cpp 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * VBoxCommon - Misc helper routines for install helper.
4 */
5
6/*
7 * Copyright (C) 2008-2020 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
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#include <iprt/win/windows.h>
23#include <tchar.h>
24#include <stdio.h>
25
26#include <msi.h>
27#include <msiquery.h>
28
29
30#if (_MSC_VER < 1400) /* Provide swprintf_s to VC < 8.0. */
31int swprintf_s(WCHAR *buffer, size_t cbBuffer, const WCHAR *format, ...)
32{
33 int ret;
34 va_list va;
35 va_start(va, format);
36 ret = _vsnwprintf(buffer, cbBuffer, format, va);
37 va_end(va);
38 return ret;
39}
40#endif
41
42UINT VBoxGetProperty(MSIHANDLE a_hModule, WCHAR *a_pwszName, WCHAR *a_pwszValue, DWORD a_dwSize)
43{
44 DWORD dwBuffer = 0;
45 UINT uiRet = MsiGetPropertyW(a_hModule, a_pwszName, L"", &dwBuffer);
46 if (uiRet == ERROR_MORE_DATA)
47 {
48 ++dwBuffer; /* On output does not include terminating null, so add 1. */
49
50 if (dwBuffer > a_dwSize)
51 return ERROR_MORE_DATA;
52
53 ZeroMemory(a_pwszValue, a_dwSize);
54 uiRet = MsiGetPropertyW(a_hModule, a_pwszName, a_pwszValue, &dwBuffer);
55 }
56 return uiRet;
57}
58
59UINT VBoxSetProperty(MSIHANDLE a_hModule, WCHAR *a_pwszName, WCHAR *a_pwszValue)
60{
61 return MsiSetPropertyW(a_hModule, a_pwszName, a_pwszValue);
62}
63
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette