Need help with using VerQueryValue

R

Return info

Hi,

I can't get the VerQueryValue function to work for the life of me
(it's returning 0, which means it failed, and I have NO IDEA why!) All
I'm trying to do is get (and print) the file version and product
version of a dll. I am using Visual Studio C++ .NET.

I think I've done all the appropriate things before calling
VerQueryVal, like calling GetFileVersionInfoSize and
GetFileVersionInfo. I want to be able to print out the actual file
version and product version of the dll - how do I do this? Please help
me fix my code, I am desperate!!

My code:

DWORD handle, size;
DWORD *lpTransArray;
LPDWORD word = 0;
char buf[256];
UINT uLen;

size = GetFileVersionInfoSize("c:\\dll\\CNP5E409_D0B81.DLL", word);
cout << "Size (in bytes) is: " << size << endl;

cout << "GetFileVersionInfo() returned: "
<< GetFileVersionInfo("c:\\dll\\CNP5E409_D0B81.DLL",
handle, size, buf)
<< endl;
cout << "GetLastError() returned: " << GetLastError() << endl;

cout << "VerQueryValue() returned: "
<< VerQueryValue(buf, _T("\\VarFileInfo\\Translation"),
(LPVOID*)&lpTransArray, &uLen)
<< endl;

TCHAR szSubblockHeader[25];
_stprintf(szSubblockHeader, _T("\\StringFileInfo\\%04X%04X"),
LOWORD(lpTransArray[0]), HIWORD(lpTransArray[0]));

TCHAR szSubblock[80];
_stprintf(szSubblock, _T("%s\\%s"), szSubblockHeader,
_T("FileVersion"));
LPTSTR lpszValue;
cout << "VerQueryValue() returned: " << VerQueryValue(buf,
szSubblock, (LPVOID *)&lpszValue, &uLen) << endl;
cout << "lpszValue is: " << &lpszValue << endl;

My output:

Size (in bytes) is: 1932
GetFileVersionInfo() returned: 1
GetLastError() returned: 0
VerQueryValue() returned: 0
VerQueryValue() returned: 0
lpszValue is: 0x0012FD6C

Thank you!
 
V

Victor Bazarov

Return info said:
I can't get the VerQueryValue function to work for the life of me
(it's returning 0, which means it failed, and I have NO IDEA why!) All
I'm trying to do is get (and print) the file version and product
version of a dll.

There is no VarQueryValue function in standard C++.
I am using Visual Studio C++ .NET.

Then you should consider asking in a newsgroup where this is
on topic, like one of microsoft.public.dotnet.* hierarchy of
public forums. If your server doesn't carry those, connect to
the public server msnews.microsoft.com.

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top