VBoxUtils.cpp revision d65680efa46fa49e8bf14e67b29b782510ff934c
/* $Id: VBoxUtil.cpp 33909 2008-07-31 09:30:59Z andy $ */
/** @file
* VBoxUtil - Some tool functions.
*/
/*
* Copyright (C) 2006-2008 Sun Microsystems, Inc.
*
* Sun Microsystems, Inc. confidential
* All rights reserved
*/
#include "VBoxService.h"
#include "VBoxUtils.h"
{
/* 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 = vboxGetFileString(a_pszFileName, TEXT("\\StringFileInfo\\040904b0\\FileVersion"), szValueUTF16, &uiSize);
if (bRet)
{
sscanf(szValueUTF8, "%ld.%ld.%ld.%ld", a_pdwMajor, a_pdwMinor, a_pdwBuildNumber, a_pdwRevisionNumber);
}
else if (dwLen > 0)
{
/* Try regular fields - this maybe is not file provided by VBox! */
if (!lpData)
{
Log(("VBoxService: vboxGetFileVersion: Could not allocate temp buffer!\n"));
return FALSE;
}
{
{
}
else Log(("VBoxService: vboxGetFileVersion: Could not query value!\n"));
}
else Log(("VBoxService: vboxGetFileVersion: Could not get file version info!\n"));
}
return bRet;
}
BOOL vboxGetFileString (LPCWSTR a_pszFileName, LPWSTR a_pszBlock, LPWSTR a_pszString, PUINT a_puiSize)
{
UINT uiValueLen = 0;
/* The VS_FIXEDFILEINFO structure contains version information about a file.
This information is language and code page independent. */
if (!dwLen)
{
Log(("VBoxService: vboxGetFileString: No file information found! File = %ls, Error: %ld\n", a_pszFileName, GetLastError()));
return FALSE; /* No version information available. */
}
if (!lpData)
{
Log(("VBoxService: vboxGetFileString: Could not allocate temp buffer!\n"));
return FALSE;
}
{
{
Log(("VBoxService: vboxGetFileString: Block = %ls, Size = %d, Value = %ls\n", a_pszBlock, uiValueLen, a_pszString));
}
else Log(("VBoxService: vboxGetFileString: Could not query value!\n"));
}
else Log(("VBoxService: vboxGetFileString: Could not get file version info!\n"));
return bRet;
}
BOOL vboxGetFileVersionString (LPCWSTR a_pszPath, LPCWSTR a_pszFileName, char* a_pszVersion, UINT a_uiSize)
{
char szValueUTF8[_MAX_PATH] = {0};
int r = 0;
if (bRet)
else
return bRet;
}