Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get all Information from VersionBlock of Binary,...

32 views
Skip to first unread message

Kerem Gümrükcü

unread,
Feb 16, 2009, 6:51:51 PM2/16/09
to
Hi,

how do i get "All" Version Information, e.g. Enumerating
all Properties and the Values for the VersionInformationBlock
after getting MemoryPointer to File Version Information with
GetFileVersionInfo(...), its the fourth Parameter i am talking
about?

Can someone tell me what else of API Functions do i have to
call and "how" do i call them to get All, i mean everything inside
the VersionInformationBlock. Here is a Screenshot of what i am
talking about:

http://www.pro-it-education.de/staff/keremg/misc/fix_sc.png

Regards

Kerem


--
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

Christian ASTOR

unread,
Feb 17, 2009, 11:17:47 AM2/17/09
to
On 17 fév, 00:51, Kerem Gümrükcü <kareem...@hotmail.com> wrote:

> how do i get "All" Version Information, e.g. Enumerating
> all Properties and the Values for the VersionInformationBlock
> after getting MemoryPointer to File Version Information with
> GetFileVersionInfo(...), its the fourth Parameter i am talking
> about?
>
> Can someone tell me what else of API Functions do i have to
> call and "how" do i call them to get All, i mean everything inside
> the VersionInformationBlock. Here is a Screenshot of what i am
> talking about:
> http://www.pro-it-education.de/staff/keremg/misc/fix_sc.png


Read the language with VerQueryValue() and "\\VarFileInfo\
\Translation"
then loop on VerQueryValueIndex()

Kerem Gümrükcü

unread,
Feb 17, 2009, 6:10:40 PM2/17/09
to
Hi Christian,

can you please show me a short example how to
use VerQueryValueIndex(...) and what the signature
for it is,...

Regards

Kerem

--
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

"Christian ASTOR" <cast...@club-internet.fr> schrieb im Newsbeitrag
news:a1753752-4de4-4ead...@f3g2000yqf.googlegroups.com...

Christian ASTOR

unread,
Feb 18, 2009, 9:35:28 AM2/18/09
to
On 18 fév, 00:10, Kerem Gümrükcü <kareem...@hotmail.com> wrote:
> Hi Christian,
> can you please show me a short example how to
> use VerQueryValueIndex(...) and what the signature
> for it is,...

For example, a test in a Win32 Ansi console with wmp.dll =>

{
DWORD dwHandle;
DWORD dwVersionSize;
LPVOID pBuffer;
LPTSTR pInfo;
UINT nInfoSize;
struct TRANSARRAY
{
WORD wLanguageID;
WORD wCharacterSet;
};
TRANSARRAY *lpTransArray;
char sCharset[10];
char sQueryString[255];
char sFile[MAX_PATH] = "wmp.dll";

dwVersionSize = GetFileVersionInfoSize(sFile, &dwHandle);
pBuffer = GlobalAlloc(GPTR, dwVersionSize);
if (!GetFileVersionInfo(sFile, dwHandle, dwVersionSize, pBuffer))
return 1;
VerQueryValue(pBuffer,"\\VarFileInfo\\Translation",(LPVOID*)&pInfo,
(UINT*)&nInfoSize);
lpTransArray = (TRANSARRAY *) pInfo;
wsprintf(sCharset,"%04x%04x", lpTransArray[0].wLanguageID,
lpTransArray[0].wCharacterSet);
strcpy(sQueryString, "\\StringFileInfo\\");
strcat(sQueryString, sCharset);

typedef BOOL (CALLBACK* VERQUERYVALUEINDEX)
(LPVOID pBlock, LPSTR pSubBlock, DWORD dwIndex, LPVOID *pString,
LPVOID *pValue, PUINT pLength);
VERQUERYVALUEINDEX VerQueryValueIndex;

HMODULE hDll = LoadLibrary("Version.dll");
VerQueryValueIndex =(VERQUERYVALUEINDEX)GetProcAddress(hDll,
"VerQueryValueIndexA");
if (!hDll || !VerQueryValueIndex)
return 1;
if (hDll)
FreeLibrary(hDll);

LPTSTR pString;
LPTSTR pValue;
int i=0;
while(TRUE)
{
if (!VerQueryValueIndex(pBuffer, sQueryString, i, (LPVOID*)&pString,
(LPVOID*)&pValue, &nInfoSize))
break;
printf ("String = %-25s - Value = %s\r\n", pString, pValue);
i++;
}
}

Kerem Gümrükcü

unread,
Feb 18, 2009, 11:53:38 AM2/18/09
to
Hi Christian,

the version.dll does not export that function nor
did i found something like that in its dependencies.
I also could not find the export on W2K, XP nor on
Vista,...did i miss something here?

Regards

Kerem

--
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

"Christian ASTOR" <cast...@club-internet.fr> schrieb im Newsbeitrag

news:892a8727-8af1-4927...@i38g2000yqd.googlegroups.com...

Domi

unread,
Feb 18, 2009, 6:45:09 PM2/18/09
to

"Kerem Gümrükcü" <kare...@hotmail.com> wrote in message
news:gnheee$j1v$01$1...@news.t-online.com...

> Hi Christian,
>
> the version.dll does not export that function nor
> did i found something like that in its dependencies.
> I also could not find the export on W2K, XP nor on
> Vista,...did i miss something here?

I checked my version (XP) and it's exported.
or
http://labo.kandcnet.com/winarekore/DllExportList/ExportList/VERSION.dll.htm
http://www.newsvoter.com/Binary/dll/version-dll-imports-exports-dependents.html


Kerem Gümrükcü

unread,
Feb 18, 2009, 7:39:56 PM2/18/09
to
Hi Domi,

thats what you get on Vista SP1 Up2Date:

File Version Info for:
"C:\Windows\system32\version.dll"

[FileName]
-- version.dll --
[Language]
-- Englisch (USA) --
[CompanyName]
-- Microsoft Corporation --
[FileDescription]
-- Version Checking and File Installation Libraries --
[FileVersion]
-- 6.0.6001.18000 (longhorn_rtm.080118-1840) --
[InternalName]
-- version --
[LegalCopyright]
-- ® Microsoft Corporation. All rights reserved. --
[OriginalFilename]
-- VERSION.DLL --
[ProductName]
-- Microsoft« Windows« Operating System --
[ProductVersion]
-- 6.0.6001.18000 --

GetFileVersionInfoA
GetFileVersionInfoExW
GetFileVersionInfoSizeA
GetFileVersionInfoSizeExW
GetFileVersionInfoSizeW
GetFileVersionInfoW
VerFindFileA
VerFindFileW
VerInstallFileA
VerInstallFileW
VerLanguageNameA
VerLanguageNameW
VerQueryValueA
VerQueryValueW


Windows 2000 SP4 Up2Date:

File Version Info for:
"C:\WINNT\system32\version.dll"

[FileName]
-- version.dll --
[Language]
-- Englisch (USA) --
[CompanyName]
-- Microsoft Corporation --
[FileDescription]
-- Version Checking and File Installation Libraries --
[FileVersion]
-- 5.00.2195.6623 --
[InternalName]
-- version --
[LegalCopyright]
-- Copyright (C) Microsoft Corp. 1981-1999 --
[OriginalFilename]
-- VERSION.DLL --
[ProductName]
-- Microsoft(R) Windows (R) 2000 Operating System --
[ProductVersion]
-- 5.00.2195.6623 --

GetFileVersionInfoA
GetFileVersionInfoSizeA
GetFileVersionInfoSizeW
GetFileVersionInfoW
VerFindFileA
VerFindFileW
VerInstallFileA
VerInstallFileW
VerLanguageNameA
VerLanguageNameW
VerQueryValueA
VerQueryValueIndexA
VerQueryValueIndexW
VerQueryValueW

Windows XP SP3 Up2Date

File Version Info for:
"C:\WINDOWS\system32\version.dll"

[FileName]
-- version.dll --
[Language]
-- Englisch (USA) --
[CompanyName]
-- Microsoft Corporation --
[FileDescription]
-- Version Checking and File Installation Libraries --
[FileVersion]
-- 5.1.2600.5512 (xpsp.080413-2105) --
[InternalName]
-- version --
[LegalCopyright]
-- ® Microsoft Corporation. All rights reserved. --
[OriginalFilename]
-- VERSION.DLL --
[ProductName]
-- Microsoft« Windows« Operating System --
[ProductVersion]
-- 5.1.2600.5512 --

GetFileVersionInfoA
GetFileVersionInfoSizeA
GetFileVersionInfoSizeW
GetFileVersionInfoW
VerFindFileA
VerFindFileW
VerInstallFileA
VerInstallFileW
VerLanguageNameA
VerLanguageNameW
VerQueryValueA
VerQueryValueIndexA
VerQueryValueIndexW
VerQueryValueW

Well, it was my mistake with XP. but as i see its no more
available in vista and possibly on Win7 neither,...

So, what to do then?

Regards

Kerem

--
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

"Domi" <do...@kl.com> schrieb im Newsbeitrag news:gni6hk$lqa$1...@aioe.org...

Christian ASTOR

unread,
Feb 19, 2009, 9:52:14 AM2/19/09
to
On 19 fév, 01:39, Kerem Gümrükcü <kareem...@hotmail.com> wrote:

> Well, it was my mistake with XP. but as i see its no more
> available in vista and possibly on Win7 neither,...

If it's not defined, you can loop on Version Block :

A test (Unicode...) on XP SP2 =>

typedef struct tagVERSION_BLOCK {
WORD wTotalLength;
WORD wValueLength;
WORD wType;
WCHAR szKey[1];
} VERSION_BLOCK ;

#define DWORD_ALIGN(x) (((x)+3)&~3)

{
DWORD dwHandle;
DWORD dwVersionSize;
LPVOID pBuffer;
LPTSTR pInfo;
UINT nInfoSize;
struct TRANSARRAY
{
WORD wLanguageID;
WORD wCharacterSet;
};
TRANSARRAY *lpTransArray;

WCHAR sCharset[10];
WCHAR sQueryString[255];
WCHAR sFile[MAX_PATH] = L"wmp.dll";
BOOL bFunct = 1;

dwVersionSize = GetFileVersionInfoSize(sFile, &dwHandle);
pBuffer = GlobalAlloc(GPTR, dwVersionSize);
if (!GetFileVersionInfo(sFile, dwHandle, dwVersionSize, pBuffer))
return 1;

VerQueryValue(pBuffer,L"\\VarFileInfo\\Translation",(LPVOID*)&pInfo,


(UINT*)&nInfoSize);
lpTransArray = (TRANSARRAY *) pInfo;

wsprintf(sCharset,L"%04x%04x", lpTransArray[0].wLanguageID,
lpTransArray[0].wCharacterSet);
lstrcpy(sQueryString, L"\\StringFileInfo\\");
lstrcat(sQueryString, sCharset);

typedef BOOL (CALLBACK* VERQUERYVALUEINDEX)
(LPVOID pBlock, LPTSTR pSubBlock, DWORD dwIndex, LPVOID *pString,


LPVOID *pValue, PUINT pLength);
VERQUERYVALUEINDEX VerQueryValueIndex;

HMODULE hDll = LoadLibrary(L"Version.dll");
VerQueryValueIndex =(VERQUERYVALUEINDEX)GetProcAddress(hDll,
"VerQueryValueIndexW");
if (!hDll || !VerQueryValueIndex)
bFunct = 0;
if (hDll)
FreeLibrary(hDll);

VERSION_BLOCK *pBlock, *pBlockEnd;
if (!VerQueryValue(pBuffer, sQueryString, (void **)&pBlock,
&nInfoSize))
{
return 1;
}

LPTSTR pString;
LPTSTR pValue;

if (!bFunct)
{
pBlock = (VERSION_BLOCK*)((LPSTR)pBlock - (DWORD_ALIGN((wcslen
(sCharset))*sizeof(WCHAR)) + sizeof(VERSION_BLOCK)));
pBlockEnd = (VERSION_BLOCK*)((LPSTR)pBlock + pBlock->wTotalLength);
pBlock = (VERSION_BLOCK*)((LPSTR)pBlock + DWORD_ALIGN((wcslen
(sCharset))* sizeof(WCHAR)) + sizeof(VERSION_BLOCK) + DWORD_ALIGN
(pBlock->wValueLength));
}

int i=0;
while(TRUE)
{
if (bFunct)
{
if (!VerQueryValueIndex(pBuffer, sQueryString, i, (LPVOID*)
&pString, (LPVOID*)&pValue, &nInfoSize))
break;
}
else
{
if (pBlock >= pBlockEnd)
break;
pString = (LPTSTR)pBlock->szKey;
pValue = (LPWSTR)((LPSTR)pBlock + DWORD_ALIGN((sizeof
(VERSION_BLOCK)-sizeof(WCHAR))+
(wcslen(pBlock->szKey)+1)
*sizeof(WCHAR)));
pBlock = (VERSION_BLOCK*)((LPSTR)pBlock + DWORD_ALIGN(pBlock-
>wTotalLength));

}
wprintf (L"String = %-25s - Value = %s\r\n", pString, pValue);
i++;
}

}

Kerem Gümrükcü

unread,
Feb 19, 2009, 10:11:29 AM2/19/09
to
Hi Christian,

thanks, thats cool,...thanks a mllion!

Regards

Kerem

--
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

"Christian ASTOR" <cast...@club-internet.fr> schrieb im Newsbeitrag
news:0b6a8818-0d2b-4f77...@v39g2000yqm.googlegroups.com...

0 new messages