By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,234 Members | 1,938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,234 IT Pros & Developers. It's quick & easy.

Need help with using VerQueryValue

P: n/a
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.DL L", 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!
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Return info" <Ja*************@cda.canon.com> wrote...
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
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.