views:

2249

answers:

4

I need to get the version info of a dll I created in VS2008 C++. How do I get it?

Thanks,

Adam

A: 

It should be there in the properties (version tab) when you open it in windows explorer

frankodwyer
He likely wants to do this programmatically...
Graeme Perrow
yes, wasn't clear from the q really
frankodwyer
+8  A: 

If you want programmatic access, see Version Information in MSDN for the APIs and data structures you need.

Paul Dixon
+3  A: 

Looks like you need to access the VS_VERSION_INFO resource; http://www.microsoft.com/msj/0498/c0498.aspx

Henrik Hartz
You phrased it like the ms paperclip :) +1
Ólafur Waage
Haha, I should change my icon..
Henrik Hartz
+6  A: 

Thanks for the answers.

This worked for me:

WCHAR fileName[_MAX_PATH];
DWORD size = GetModuleFileName(g_dllHandle, fileName, _MAX_PATH);
fileName[size] = NULL;
DWORD handle = 0;
size = GetFileVersionInfoSize(fileName, &handle);
BYTE* versionInfo = new BYTE[size];
if (!GetFileVersionInfo(fileName, handle, size, versionInfo))
{
    delete[] versionInfo;
    return;
}
// we have version information
UINT       len = 0;
VS_FIXEDFILEINFO*   vsfi = NULL;
VerQueryValue(versionInfo, L"\\", (void**)&vsfi, &len);
aVersion[0] = HIWORD(vsfi->dwFileVersionMS);
aVersion[1] = LOWORD(vsfi->dwFileVersionMS);
aVersion[2] = HIWORD(vsfi->dwFileVersionLS);
aVersion[3] = LOWORD(vsfi->dwFileVersionLS);
delete[] versionInfo;
Adam Oren