VBoxServiceUtils.cpp revision 019f39cc548f50d58cfdf91965f58eab1ded841b
/* $Id$ */
/** @file
* VBoxServiceUtils - Some utility functions.
*/
/*
* Copyright (C) 2009 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#ifdef RT_OS_WINDOWS
# include <Windows.h>
#endif
#include <VBox/VBoxGuestLib.h>
#include "VBoxServiceInternal.h"
#ifdef VBOX_WITH_GUEST_PROPS
/**
* Wrapper around VbglR3GuestPropWriteValue that does value formatting and
* logging.
*
* @returns VBox status code. Errors will be logged.
*
* @param u32ClientId The HGCM client ID for the guest property session.
* @param pszName The property name.
* @param pszValueFormat The property format string. If this is NULL then
* the property will be removed.
* @param ... Format arguments.
*/
int VBoxServiceWritePropF(uint32_t u32ClientId, const char *pszName, const char *pszValueFormat, ...)
{
int rc;
if (pszValueFormat != NULL)
{
/** @todo Log the value as well? just copy the guts of
* VbglR3GuestPropWriteValueV. */
if (RT_FAILURE(rc))
}
else
{
if (RT_FAILURE(rc))
}
return rc;
}
#endif /* VBOX_WITH_GUEST_PROPS */
#ifdef RT_OS_WINDOWS
char* pszBlock,
char* pszString,
{
UINT uiValueLen = 0;
/* The VS_FIXEDFILEINFO structure contains version information about a file.
This information is language and code page independent. */
if (!dwLen)
{
VBoxServiceError("No file information found! File = %s, Error: %ld\n", pszFileName, GetLastError());
return FALSE;
}
if (!lpData)
{
VBoxServiceError("Could not allocate temp buffer!\n");
return FALSE;
}
{
{
}
else VBoxServiceError("Could not query value!\n");
}
else VBoxServiceError("Could not get file version info!\n");
return bRet;
}
{
/* The VS_FIXEDFILEINFO structure contains version information about a file.
This information is language and code page independent. */
/* Try own fields defined in block "\\StringFileInfo\\040904b0\\FileVersion". */
int r = 0;
bRet = VBoxServiceGetFileString(pszFileName, "\\StringFileInfo\\040904b0\\FileVersion", szValue, &uiSize);
if (bRet)
{
}
else if (dwLen > 0)
{
/* Try regular fields - this maybe is not file provided by VBox! */
if (!lpData)
{
VBoxServiceError("Could not allocate temp buffer!\n");
return FALSE;
}
{
{
}
else VBoxServiceError("Could not query file information value!\n");
}
else VBoxServiceError("Could not get file version info!\n");
}
return bRet;
}
BOOL VBoxServiceGetFileVersionString(const char* pszPath, const char* pszFileName, char* pszVersion, UINT uiSize)
{
char szFullPath[_MAX_PATH] = {0};
int r = 0;
if (bRet)
else
return bRet;
}
#endif /* !RT_OS_WINDOWS */