I have this code – that is returning the file version (into a struct)
I’m using as example the shell32.dll
but there are some values that I don’t understand their meanings , and would love to get an explanation.
here is the code :
void GetFileVersion( PCHAR pFilePath ,PVERSION pRetVersion)
{
DWORD dwSize = 0;
BYTE *pVersionInfo = NULL;
VS_FIXEDFILEINFO *pFileInfo = NULL;
UINT pLenFileInfo = 0;
/*getting the file version info size */
dwSize = GetFileVersionInfoSize( pFilePath, NULL );
if ( dwSize == 0 )
{
printf( "Error in GetFileVersionInfoSize: %d\n", GetLastError() );
return;
}
pVersionInfo = new BYTE[ dwSize ]; /*allocation of space for the verison size */
if ( !GetFileVersionInfo( pFilePath, 0, dwSize, pVersionInfo ) ) /*entering all info data to pbVersionInfo*/
{
printf( "Error in GetFileVersionInfo: %d\n", GetLastError() );
delete[] pVersionInfo;
return;
}
if ( !VerQueryValue( pVersionInfo, TEXT("\\"), (LPVOID*) &pFileInfo, &pLenFileInfo ) )
{
printf( "Error in VerQueryValue: %d\n", GetLastError() );
delete[] pVersionInfo;
return;
}
/*checking if the allocation succeeded */
if (NULL == pRetVersion)
{
printf("Allocation failed! \n" , GetLastError());
return;
}
pRetVersion->major = ( pFileInfo->dwFileVersionMS >> 16 ) & 0xffff ;
pRetVersion->minor = ( pFileInfo->dwFileVersionMS) & 0xffff;
pRetVersion->hotfix = ( pFileInfo->dwFileVersionLS >> 16 ) & 0xffff;
pRetVersion->other = ( pFileInfo->dwFileVersionLS) & 0xffff;
}
-
what is the the meaning of dwSize ? is this only the file version size? where can I see it while clicking on the shell32.dll?
-
pLenFileinfo – what is this size ?
-
when I look at the struct of
VS_FIXEDFILEINFOthere is only the version info information , Is there a wae to get for example :File description,Date modified,Original filenameetc ? (all the other properties that are inside the “Details” )?
thanks !!!!!
The file version information is of variable length. It contains a number of different pieces of information. The total length of all these different pieces is given by the return value of
GetFileVersionInfoSize.When you call
VerQueryValueyou are asking for a specific individual piece of information within the overall version information. And the length of that specific part can never be larger that the overall size.The documentation for
VerQueryFilecontains sample code that extracts the file description.