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!
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!