VBoxServiceUtils.cpp revision 49315f87798ab9d5083295207bcf2b9ca391bd0e
/* $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/VBoxGuest.h>
#include "VBoxServiceInternal.h"
{
int rc = VINF_SUCCESS;
/* Not checking for a valid pszValue is intentional. */
char szKeyTemp [FILENAME_MAX] = {0};
char *pszValueTemp = NULL;
/* Append base path. */
RTStrPrintf(szKeyTemp, sizeof(szKeyTemp), "/VirtualBox/%s", pszKey); /** @todo r=bird: Why didn't you hardcode this into the strings before calling this function? */
{
if (!RT_SUCCESS(rc))
{
VBoxServiceError("vboxVMInfoThread: Failed to convert the value name \"%s\" to Utf8! Error: %Rrc\n", pszValue, rc);
goto cleanup;
}
}
rc = VbglR3GuestPropWriteValue(uiClientID, szKeyTemp, ((pszValue == NULL) || (0 == strlen(pszValue))) ? NULL : pszValueTemp);
if (!RT_SUCCESS(rc))
{
VBoxServiceError("Failed to store the property \"%s\"=\"%s\"! ClientID: %d, Error: %Rrc\n", szKeyTemp, pszValueTemp, uiClientID, rc);
goto cleanup;
}
else
return rc;
}
{
char szBuffer[32] = {0};
}
#ifdef RT_OS_WINDOWS
/** @todo Use TCHAR here instead of LPC*STR crap. */
{
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 = %ls, 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". */
char szValueUTF8[_MAX_PATH] = {0};
char *pszValueUTF8 = szValueUTF8;
int r = 0;
bRet = VboxServiceGetFileString(pszFileName, TEXT("\\StringFileInfo\\040904b0\\FileVersion"), szValueUTF16, &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(LPCWSTR pszPath, LPCWSTR pszFileName, char* pszVersion, UINT uiSize)
{
char szValueUTF8[_MAX_PATH] = {0};
int r = 0;
if (bRet)
else
return bRet;
}
#endif /* !RT_OS_WINDOWS */