1

Possible Duplicate:
How do I read from a version resource in Visual C++

I add a ressource "version" to my C++ Visual Studio project and now I want to read back this value in my code!

How is this possible?

Thx

Community
  • 1
  • 1
leon22
  • 4,757
  • 18
  • 59
  • 94

2 Answers2

0

You access the resource with the function FindResource and access it with the function LoadResource. At the second like you will also get a complete example to access and update the resource.

harper
  • 12,852
  • 6
  • 51
  • 99
0

Here's how I do it in Project: Merge:

std::wstring ReadProcessVersion( const std::wstring& filename )
{
    char        buffer[ 8192 ];
    wchar_t*    version;
    UINT        size;

    if( GetFileVersionInfo( filename.c_str(), NULL, sizeof( buffer ), buffer ))
    {
        if( VerQueryValue( buffer, L"\\StringFileInfo\\080904B0\\FileVersion", reinterpret_cast< void** >( &version ), &size ))
        {
            return version;
        }
    }
    return L"";
}

If I remember rightly, the resource identifier 080904B0 is locale dependent. (I only ever have English.)