本文整理汇总了C++中VerQueryValue函数的典型用法代码示例。如果您正苦于以下问题:C++ VerQueryValue函数的具体用法?C++ VerQueryValue怎么用?C++ VerQueryValue使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VerQueryValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCurrentFileVersion
// 현재 실행파일의 파일 버전 얻어오기
BOOL GetCurrentFileVersion(LPTSTR tszFileVer)
{
BOOL bRet = FALSE;
DWORD dwInfoSize = 0;
TCHAR tszFilePath[MAX_PATH] = {'\0',};
char *pBuf = NULL;
tszFileVer[0] = '\0';
GetModuleFileName(NULL, tszFilePath, MAX_PATH);
dwInfoSize = GetFileVersionInfoSize(tszFilePath, 0);
pBuf = new char[dwInfoSize];
if( dwInfoSize == 0 )
{
bRet = FALSE;
}
if(GetFileVersionInfo(tszFilePath, 0, dwInfoSize, pBuf) !=0 )
{
VS_FIXEDFILEINFO* pFineInfo = NULL;
UINT bufLen = 0;
if(VerQueryValue(pBuf, _T("\\"),(LPVOID*)&pFineInfo, &bufLen) !=0)
{
bRet = TRUE;
wsprintf(tszFileVer, _T("v%d.%d.%d.%d"), HIWORD(pFineInfo->dwFileVersionMS), LOWORD(pFineInfo->dwFileVersionMS), HIWORD(pFineInfo->dwFileVersionLS), LOWORD(pFineInfo->dwFileVersionLS) );
}
}
delete pBuf;
return bRet;
}
示例2: getVersion
jobject getVersion(JNIEnv * env, char *driver)
{
DWORD var = 0;
DWORD dwInfoSize;
LPVOID lpInfoBuff;
BOOL bRetval;
jclass version_class;
jmethodID version_cons;
jobject ret = NULL;
version_class = (*env)->FindClass(env, "org/lwjgl/opengl/WindowsFileVersion");
if (version_class == NULL)
return NULL;
version_cons = (*env)->GetMethodID(env, version_class, "<init>", "(II)V");
if (version_cons == NULL)
return NULL;
dwInfoSize = GetFileVersionInfoSize(driver, &var);
lpInfoBuff = malloc(dwInfoSize);
if (lpInfoBuff == NULL) {
throwException(env, "Failed to allocate lpInfoBuff");
return NULL;
}
bRetval = GetFileVersionInfo(driver, 0, dwInfoSize, lpInfoBuff);
if (bRetval != 0) {
VS_FIXEDFILEINFO * fxdFileInfo;
UINT uiLen = 0;
bRetval = VerQueryValue(lpInfoBuff, TEXT("\\"), (void *)&fxdFileInfo, &uiLen);
if (bRetval != 0)
ret = (*env)->NewObject(env, version_class, version_cons, fxdFileInfo->dwProductVersionMS, fxdFileInfo->dwProductVersionLS);
}
free(lpInfoBuff);
return ret;
}
示例3: InitDlg
void InitDlg(HWND hDlg) {
// Get version information from the application
HINSTANCE hInst = AfxGetInstanceHandle();
TCHAR szFullPath[256];
GetModuleFileName(hInst, szFullPath, sizeof(szFullPath));
DWORD dwVerHnd;
DWORD dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);
if (dwVerInfoSize != 0) {
// If we were able to get the information, process it
HANDLE hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
LPVOID lpvMem = GlobalLock(hMem);
GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpvMem);
TCHAR szGetName[256];
lstrcpy(szGetName, _T("\\StringFileInfo\\040904b0\\"));
int cchRoot = lstrlen(szGetName);
// Walk through the dialog items that we want to replace
static WORD idcs[] = {IDC_COPYRIGHT, IDC_VERSION};
for (int i = 0; i < 2; i++) {
TCHAR szResult[256];
::GetDlgItemText(hDlg, idcs[i], szResult, sizeof(szResult));
lstrcpy(&szGetName[cchRoot], szResult);
LPTSTR lszVer = NULL;
UINT cchVer = 0;
BOOL fRet = VerQueryValue(lpvMem, szGetName, (void**)&lszVer, &cchVer);
if (fRet && cchVer != 0 && lszVer != NULL) {
// Replace dialog item text with version info
lstrcpy(szResult, lszVer);
::SetDlgItemText(hDlg, idcs[i], szResult);
}
}
GlobalUnlock(hMem);
GlobalFree(hMem);
}
}
示例4: GetVersion
const wchar_t* GetVersion(HMODULE hMod)
{
static wchar_t szVersion[32];
if (szVersion[0])
return szVersion;
WCHAR ModulePath[MAX_PATH*2];
if (GetModuleFileName(hMod,ModulePath,sizeof(ModulePath)/sizeof(ModulePath[0]))) {
DWORD dwRsrvd = 0;
DWORD dwSize = GetFileVersionInfoSize(ModulePath, &dwRsrvd);
if (dwSize>0) {
void *pVerData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
if (pVerData) {
VS_FIXEDFILEINFO *lvs = NULL;
UINT nLen = sizeof(lvs);
if (GetFileVersionInfo(ModulePath, 0, dwSize, pVerData)) {
TCHAR szSlash[3]; lstrcpyW(szSlash, L"\\");
if (VerQueryValue ((void*)pVerData, szSlash, (void**)&lvs, &nLen)) {
wsprintfW(szVersion, L"%i.%i",
HIWORD(lvs->dwFileVersionMS), LOWORD(lvs->dwFileVersionMS));
if (lvs->dwFileVersionLS)
wsprintfW(szVersion+lstrlen(szVersion), L".%i.%i",
HIWORD(lvs->dwFileVersionLS), LOWORD(lvs->dwFileVersionLS));
}
}
HeapFree(GetProcessHeap(), 0, pVerData);
}
}
}
if (!szVersion[0])
lstrcpy(szVersion, L"Unknown");
return szVersion;
}
示例5: GetModuleInformation
CString GetModuleInformation()
{
CString info;
TCHAR szApp[MAX_PATH];
if(!GetModuleFileName(NULL, szApp, MAX_PATH))
return info;
info = szApp;
DWORD dwDummy;
DWORD dwInfoSize;
dwInfoSize = GetFileVersionInfoSize(szApp, &dwDummy);
if(dwInfoSize)
{
LPVOID pInfoBuffer = _alloca(dwInfoSize);
if(GetFileVersionInfo(szApp, 0, dwInfoSize, pInfoBuffer))
{
VS_FIXEDFILEINFO *pInfo = NULL;
UINT InfoSize = 0;
if(VerQueryValue (pInfoBuffer, _T("\\"), (LPVOID *)&pInfo, &InfoSize) && InfoSize == sizeof(VS_FIXEDFILEINFO))
{
CString strVersion;
strVersion.Format(_T(" (%d.%d.%d.%d)"),
HIWORD(pInfo->dwFileVersionMS),
LOWORD(pInfo->dwFileVersionMS),
HIWORD(pInfo->dwFileVersionLS),
LOWORD(pInfo->dwFileVersionLS)
);
info += strVersion;
}
}
}
return info;
}
示例6: GetFileVersionInfoSize
int32 FDesktopPlatformWindows::GetShellIntegrationVersion(const FString &FileName)
{
::DWORD VersionInfoSize = GetFileVersionInfoSize(*FileName, NULL);
if (VersionInfoSize != 0)
{
TArray<uint8> VersionInfo;
VersionInfo.AddUninitialized(VersionInfoSize);
if (GetFileVersionInfo(*FileName, NULL, VersionInfoSize, VersionInfo.GetData()))
{
TCHAR *ShellVersion;
::UINT ShellVersionLen;
if (VerQueryValue(VersionInfo.GetData(), TEXT("\\StringFileInfo\\040904b0\\ShellIntegrationVersion"), (LPVOID*)&ShellVersion, &ShellVersionLen))
{
TCHAR *ShellVersionEnd;
int32 Version = FCString::Strtoi(ShellVersion, &ShellVersionEnd, 10);
if(*ShellVersionEnd == 0)
{
return Version;
}
}
}
}
return 0;
}
示例7: populateVersions
// populateVersions
//
// This function reads the DLL's Product Version, and stores the MS and LS
// DWORDs into global variables for use in the getCUIAppLanguageModuleVersion
// function. It also sets the versionsPopulated variable to true so that it
// will only load the information once.
void populateVersions(void)
{
if (!versionsPopulated)
{
char moduleFilename[1024];
if (GetModuleFileName(g_hModule, moduleFilename,
sizeof(moduleFilename)) > 0)
{
DWORD zero;
DWORD versionInfoSize = GetFileVersionInfoSize(moduleFilename,
&zero);
if (versionInfoSize > 0)
{
BYTE *versionInfo = new BYTE[versionInfoSize];
if (GetFileVersionInfo(moduleFilename, NULL, versionInfoSize,
versionInfo))
{
VS_FIXEDFILEINFO *fixedVersionInfo;
UINT versionLength;
if (VerQueryValue(versionInfo, "\\",
(void**)&fixedVersionInfo, &versionLength))
{
versionMS = fixedVersionInfo->dwProductVersionMS;
versionLS = fixedVersionInfo->dwProductVersionLS;
versionsPopulated = true;
}
}
delete versionInfo;
}
}
}
}
示例8: wsprintf
//////////////////
// Get string file info.
// Key name is something like "CompanyName".
// returns the value in szValue.
//
BOOL CModuleVersion::GetValue(LPCTSTR lpKeyName, CString & strVal)
{
BOOL bRet = FALSE ;
TCHAR szTemp [ MAX_PATH ] ;
if ( m_pVersionInfo )
{
// To get a string value must pass query in the form
//
// "\StringFileInfo\<langID><codepage>\keyname"
//
// where <langID><codepage> is the languageID concatenated with the
// code page, in hex. Wow.
//
wsprintf ( szTemp ,
_T("\\StringFileInfo\\%04x%04x\\%s"),
m_translation.langID,
m_translation.charset,
lpKeyName);
LPCTSTR pVal;
UINT iLenVal;
if ( VerQueryValue(m_pVersionInfo, szTemp,
(LPVOID*)&pVal, &iLenVal) )
{
LPTSTR szValue = strVal.GetBuffer (iLenVal);
_tcsncpy ( szValue, pVal, iLenVal);
strVal.ReleaseBuffer();
bRet = TRUE ;
}
}
return ( bRet );
}
示例9: GetModuleVersion
/**
* Get the 4 element version number of the module
*/
static void GetModuleVersion( TCHAR* ModuleName, TCHAR* StringBuffer, DWORD MaxSize )
{
StringCchCopy( StringBuffer, MaxSize, TEXT( "0.0.0.0" ) );
DWORD Handle = 0;
DWORD InfoSize = GetFileVersionInfoSize( ModuleName, &Handle );
if( InfoSize > 0 )
{
char* VersionInfo = new char[InfoSize];
if( GetFileVersionInfo( ModuleName, 0, InfoSize, VersionInfo ) )
{
VS_FIXEDFILEINFO* FixedFileInfo;
UINT InfoLength = 0;
if( VerQueryValue( VersionInfo, TEXT( "\\" ), ( void** )&FixedFileInfo, &InfoLength ) )
{
StringCchPrintf( StringBuffer, MaxSize, TEXT( "%d.%d.%d.%d" ),
HIWORD( FixedFileInfo->dwProductVersionMS ), LOWORD( FixedFileInfo->dwProductVersionMS ), HIWORD( FixedFileInfo->dwProductVersionLS ), LOWORD( FixedFileInfo->dwProductVersionLS ) );
}
}
delete VersionInfo;
}
}
示例10: GetFileVersion
//=============================================================================
// 函数名称: 获得文件版本信息
// 作者说明: mushuai
// 修改时间: 2010-03-08
//=============================================================================
CString GetFileVersion(LPCTSTR FileName)
{
int iVerInfoSize;
char *pBuf=0;
CString asVer;
VS_FIXEDFILEINFO *pVsInfo=0;
unsigned int iFileInfoSize = sizeof(VS_FIXEDFILEINFO);
iVerInfoSize = GetFileVersionInfoSize(FileName,NULL);
if(iVerInfoSize!= 0)
{
pBuf = new char[iVerInfoSize];
if(GetFileVersionInfo(FileName,0,iVerInfoSize, pBuf))
{
if(VerQueryValue(pBuf, _T("\\"),(void**)&pVsInfo,&iFileInfoSize))
{
asVer.Format(_T("%d.%d.%d.%d"),HIWORD(pVsInfo->dwFileVersionMS),
LOWORD(pVsInfo->dwFileVersionMS),HIWORD(pVsInfo->dwFileVersionLS),
LOWORD(pVsInfo->dwFileVersionLS));
}
}
delete pBuf;
}
return asVer;
}
示例11: UINT
int CCrashHandler::Init(
LPCTSTR lpcszAppName,
LPCTSTR lpcszAppVersion,
LPCTSTR lpcszCrashSenderPath,
LPGETLOGFILE lpfnCallback,
LPCTSTR lpcszTo,
LPCTSTR lpcszSubject,
LPCTSTR lpcszUrl,
UINT (*puPriorities)[5],
DWORD dwFlags,
LPCTSTR lpcszPrivacyPolicyURL)
{
crSetErrorMsg(_T("Unspecified error."));
// save user supplied callback
if (lpfnCallback)
m_lpfnCallback = lpfnCallback;
// Get handle to the EXE module used to create this process
HMODULE hExeModule = GetModuleHandle(NULL);
if(hExeModule==NULL)
{
ATLASSERT(hExeModule!=NULL);
crSetErrorMsg(_T("Couldn't get module handle for the executable."));
return 1;
}
TCHAR szExeName[_MAX_PATH];
DWORD dwLength = GetModuleFileName(hExeModule, szExeName, _MAX_PATH);
if(dwLength==0)
{
// Couldn't get the name of EXE that was used to create current process
ATLASSERT(0);
crSetErrorMsg(_T("Couldn't get the name of EXE that was used to create current process."));
return 1;
}
// Save EXE image name
m_sImageName = CString(szExeName, dwLength);
// Save application name
m_sAppName = lpcszAppName;
// If no app name provided, use the default (EXE name)
if(m_sAppName.IsEmpty())
m_sAppName = CUtility::getAppName();
// Save app version
m_sAppVersion = lpcszAppVersion;
// If no app version provided, use the default (EXE product version)
if(m_sAppVersion.IsEmpty())
{
DWORD dwBuffSize = GetFileVersionInfoSize(szExeName, 0);
LPBYTE pBuff = new BYTE[dwBuffSize];
if(0!=GetFileVersionInfo(szExeName, 0, dwBuffSize, pBuff))
{
VS_FIXEDFILEINFO* fi = NULL;
UINT uLen = 0;
VerQueryValue(pBuff, _T("\\"), (LPVOID*)&fi, &uLen);
WORD dwVerMajor = (WORD)(fi->dwProductVersionMS>>16);
WORD dwVerMinor = (WORD)(fi->dwProductVersionMS&0xFF);
WORD dwPatchLevel = (WORD)(fi->dwProductVersionLS>>16);
WORD dwVerBuild = (WORD)(fi->dwProductVersionLS&0xFF);
m_sAppVersion.Format(_T("%u.%u.%u.%u"),
dwVerMajor, dwVerMinor, dwPatchLevel, dwVerBuild);
}
示例12: LoadLangDll
void LoadLangDll()
{
if ((g_langid != g_ShellCache.GetLangID())&&((g_langTimeout == 0)||(g_langTimeout < GetTickCount())))
{
g_langid = g_ShellCache.GetLangID();
DWORD langId = g_langid;
TCHAR langDll[MAX_PATH*4];
HINSTANCE hInst = NULL;
TCHAR langdir[MAX_PATH] = {0};
char langdirA[MAX_PATH] = {0};
if (GetModuleFileName(g_hmodThisDll, langdir, _countof(langdir))==0)
return;
if (GetModuleFileNameA(g_hmodThisDll, langdirA, _countof(langdirA))==0)
return;
TCHAR * dirpoint = _tcsrchr(langdir, '\\');
char * dirpointA = strrchr(langdirA, '\\');
if (dirpoint)
*dirpoint = 0;
if (dirpointA)
*dirpointA = 0;
dirpoint = _tcsrchr(langdir, '\\');
dirpointA = strrchr(langdirA, '\\');
if (dirpoint)
*dirpoint = 0;
if (dirpointA)
*dirpointA = 0;
strcat_s(langdirA, "\\Languages");
// bindtextdomain ("subversion", langdirA);
BOOL bIsWow = FALSE;
IsWow64Process(GetCurrentProcess(), &bIsWow);
do
{
if (bIsWow)
_stprintf_s(langDll, _T("%s\\Languages\\TortoiseProc32%lu.dll"), langdir, langId);
else
_stprintf_s(langDll, _T("%s\\Languages\\TortoiseProc%lu.dll"), langdir, langId);
BOOL versionmatch = TRUE;
struct TRANSARRAY
{
WORD wLanguageID;
WORD wCharacterSet;
};
DWORD dwReserved,dwBufferSize;
dwBufferSize = GetFileVersionInfoSize((LPTSTR)langDll,&dwReserved);
if (dwBufferSize > 0)
{
LPVOID pBuffer = (void*) malloc(dwBufferSize);
if (pBuffer != (void*) NULL)
{
UINT nInfoSize = 0;
UINT nFixedLength = 0;
LPSTR lpVersion = NULL;
VOID* lpFixedPointer;
TRANSARRAY* lpTransArray;
TCHAR strLangProductVersion[MAX_PATH];
if (GetFileVersionInfo((LPTSTR)langDll,
dwReserved,
dwBufferSize,
pBuffer))
{
// Query the current language
if (VerQueryValue( pBuffer,
_T("\\VarFileInfo\\Translation"),
&lpFixedPointer,
&nFixedLength))
{
lpTransArray = (TRANSARRAY*) lpFixedPointer;
_stprintf_s(strLangProductVersion, _T("\\StringFileInfo\\%04x%04x\\ProductVersion"),
lpTransArray[0].wLanguageID, lpTransArray[0].wCharacterSet);
if (VerQueryValue(pBuffer,
(LPTSTR)strLangProductVersion,
(LPVOID *)&lpVersion,
&nInfoSize))
{
versionmatch = (_tcscmp((LPCTSTR)lpVersion, _T(STRPRODUCTVER)) == 0);
}
}
}
free(pBuffer);
} // if (pBuffer != (void*) NULL)
} // if (dwBufferSize > 0)
else
versionmatch = FALSE;
if (versionmatch)
hInst = LoadLibrary(langDll);
if (hInst != NULL)
{
if (g_hResInst != g_hmodThisDll)
FreeLibrary(g_hResInst);
//.........这里部分代码省略.........
示例13: SetVersion
void SetVersion(LPCTSTR lpszFile)
{
VS_VERSIONINFO *pVerInfo;
LPBYTE pOffsetBytes;
VS_FIXEDFILEINFO *pFixedInfo;
DWORD dwHandle, dwSize, dwResult = 0;
// determine the size of the resource information
dwSize = GetFileVersionInfoSize((LPTSTR)lpszFile, &dwHandle);
if (0 < dwSize)
{
LPBYTE lpBuffer = new BYTE[dwSize];
if (GetFileVersionInfo((LPTSTR)lpszFile, 0, dwSize, lpBuffer) != FALSE)
{
// these macros help to align on r-byte boundaries (thanks Ted Peck)
// 'point to' the start of the version information block
pVerInfo = (VS_VERSIONINFO *) lpBuffer;
// the fixed section starts right after the 'VS_VERSION_INFO' string
pOffsetBytes = (BYTE *) &pVerInfo->szKey[wcslen(pVerInfo->szKey) + 1];
pFixedInfo = (VS_FIXEDFILEINFO *) roundpos(pVerInfo, pOffsetBytes, 4);
// increment the numbers!
pFixedInfo->dwFileVersionMS = pFixedInfo->dwFileVersionMS + 0x00010001;
pFixedInfo->dwFileVersionLS = pFixedInfo->dwFileVersionLS + 0x00010001;
pFixedInfo->dwProductVersionMS = pFixedInfo->dwProductVersionMS + 0x00010001;
pFixedInfo->dwProductVersionLS = pFixedInfo->dwProductVersionLS + 0x00010001;
HANDLE hResource = BeginUpdateResource(lpszFile, FALSE);
if (NULL != hResource)
{
UINT uTemp;
// get the language information
if (VerQueryValue(lpBuffer, _T("\\VarFileInfo\\Translation"), (LPVOID *) &lpTranslate, &uTemp) != FALSE)
{
// could probably just use LANG_NEUTRAL/SUBLANG_NEUTRAL
if (UpdateResource(hResource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO), lpTranslate->wLanguage, lpBuffer, dwSize) != FALSE)
{
if (EndUpdateResource(hResource, FALSE) == FALSE)
dwResult = GetLastError();
}
else
dwResult = GetLastError();
}
}
else
dwResult = GetLastError();
}
else
dwResult = GetLastError();
delete [] lpBuffer;
}
else
dwResult = GetLastError();
//if (0 != dwResult)
// wprintf(_T("Operation was not successful. Result = %lu\n"), dwResult);
}
示例14: switch
// Message handler for about box.
LRESULT CALLBACK VirtualDimension::About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static IPicture * picture;
switch (message)
{
case WM_INITDIALOG:
SetFocus(GetDlgItem(hDlg, IDOK));
picture = PlatformHelper::OpenImage(MAKEINTRESOURCE(IDI_VIRTUALDIMENSION));
TCHAR text[MAX_PATH];
DWORD dwHandle;
DWORD vinfSize;
LPVOID lpVersionInfo;
TCHAR * lpVal;
UINT dwValSize;
TCHAR * context;
GetModuleFileName(NULL, text, MAX_PATH);
vinfSize = GetFileVersionInfoSize(text, &dwHandle);
lpVersionInfo = malloc(vinfSize);
GetFileVersionInfo(text, dwHandle, vinfSize, lpVersionInfo);
VerQueryValue(lpVersionInfo, TEXT("\\StringFileInfo\\040904b0\\ProductName"), (LPVOID*)&lpVal, &dwValSize);
_tcsncpy_s(text, lpVal, dwValSize);
_tcscat_s(text, TEXT(" v"));
VerQueryValue(lpVersionInfo, TEXT("\\StringFileInfo\\040904b0\\ProductVersion"), (LPVOID*)&lpVal, &dwValSize);
lpVal = _tcstok_s(lpVal, TEXT(", \t"), &context);
_tcscat_s(text, lpVal);
_tcscat_s(text, TEXT("."));
lpVal = _tcstok_s(NULL, TEXT(", \t"), &context);
_tcscat_s(text, lpVal);
lpVal = _tcstok_s(NULL, TEXT(", \t"), &context);
if (*lpVal != TEXT('0'))
{
*lpVal += TEXT('a') - TEXT('0');
_tcscat_s(text, lpVal);
}
SetDlgItemText(hDlg, IDC_PRODUCT, text);
VerQueryValue(lpVersionInfo, TEXT("\\StringFileInfo\\040904b0\\LegalCopyright"), (LPVOID*)&lpVal, &dwValSize);
_tcsncpy_s(text, lpVal, dwValSize);
SetDlgItemText(hDlg, IDC_COPYRIGHT, text);
free(lpVersionInfo);
return FALSE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
EndDialog(hDlg, LOWORD(wParam));
if (picture)
{
picture->Release();
picture = NULL;
}
return TRUE;
case IDC_HOMEPAGE_LINK:
if (HIWORD(wParam) == STN_CLICKED)
{
ShellExecute(hDlg, TEXT("open"), TEXT("http://virt-dimension.sourceforge.net"),
NULL, NULL, SW_SHOWNORMAL);
}
break;
case IDC_GPL_LINK:
if (HIWORD(wParam) == STN_CLICKED)
{
ShellExecute(hDlg, TEXT("open"), TEXT("LICENSE.html"),
NULL, NULL, SW_SHOWNORMAL);
}
break;
}
break;
case WM_DRAWITEM:
if (picture)
PlatformHelper::CustomDrawIPicture(picture, (LPDRAWITEMSTRUCT)lParam, false);
return TRUE;
}
return FALSE;
}
示例15: VBoxServiceGetFileVersion
/**
* Worker for VBoxServiceGetFileVersionString.
*
* @returns VBox status code.
* @param pszFilename ASCII & ANSI & UTF-8 compliant name.
*/
static int VBoxServiceGetFileVersion(const char *pszFilename,
PDWORD pdwMajor,
PDWORD pdwMinor,
PDWORD pdwBuildNumber,
PDWORD pdwRevisionNumber)
{
int rc;
*pdwMajor = *pdwMinor = *pdwBuildNumber = *pdwRevisionNumber = 0;
/*
* Get the file version info.
*/
DWORD dwHandleIgnored;
DWORD cbVerData = GetFileVersionInfoSizeA(pszFilename, &dwHandleIgnored);
if (cbVerData)
{
LPTSTR pVerData = (LPTSTR)RTMemTmpAllocZ(cbVerData);
if (pVerData)
{
if (GetFileVersionInfoA(pszFilename, dwHandleIgnored, cbVerData, pVerData))
{
/*
* Try query and parse the FileVersion string our selves first
* since this will give us the correct revision number when
* it goes beyond the range of an uint16_t / WORD.
*/
if (VBoxServiceGetFileVersionOwn(pVerData, pdwMajor, pdwMinor, pdwBuildNumber, pdwRevisionNumber))
rc = VINF_SUCCESS;
else
{
/* Fall back on VS_FIXEDFILEINFO */
UINT cbFileInfoIgnored = 0;
VS_FIXEDFILEINFO *pFileInfo = NULL;
if (VerQueryValue(pVerData, "\\", (LPVOID *)&pFileInfo, &cbFileInfoIgnored))
{
*pdwMajor = HIWORD(pFileInfo->dwFileVersionMS);
*pdwMinor = LOWORD(pFileInfo->dwFileVersionMS);
*pdwBuildNumber = HIWORD(pFileInfo->dwFileVersionLS);
*pdwRevisionNumber = LOWORD(pFileInfo->dwFileVersionLS);
rc = VINF_SUCCESS;
}
else
{
rc = RTErrConvertFromWin32(GetLastError());
VBoxServiceVerbose(3, "No file version value for file \"%s\" available! (%d / rc=%Rrc)\n",
pszFilename, GetLastError(), rc);
}
}
}
else
{
rc = RTErrConvertFromWin32(GetLastError());
VBoxServiceVerbose(0, "GetFileVersionInfo(%s) -> %u / %Rrc\n", pszFilename, GetLastError(), rc);
}
RTMemTmpFree(pVerData);
}
else
{
VBoxServiceVerbose(0, "Failed to allocate %u byte for file version info for '%s'\n", cbVerData, pszFilename);
rc = VERR_NO_TMP_MEMORY;
}
}
else
{
rc = RTErrConvertFromWin32(GetLastError());
VBoxServiceVerbose(3, "GetFileVersionInfoSize(%s) -> %u / %Rrc\n", pszFilename, GetLastError(), rc);
}
return rc;
}