Some time ago, caught this bit of code to retrieve information from the executable.
When I has been updated for the FWH 8.06/xHarbour 1.1.0, this code has been stopped working.
Is there any amendment to do?
Thanks!
PS.: The code is bellow:
- Code: Select all Expand view
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
HB_FUNC( GETFILEVERSIONINFO )
{
char * szFile = hb_parc( 1 );
UINT uAction = ISNUM( 2 ) ? hb_parni( 2 ) : 1;
DWORD dwHandle = 0;
DWORD dwSize = GetFileVersionInfoSize( szFile, &dwHandle );
char * szOut = NULL;
BOOL bOk = FALSE;
if( dwSize )
{
char * szBlock = ( char * ) hb_xgrab( 255 );
char * szSubBlock = ( char * ) hb_xgrab( 255 );
HGLOBAL hMem = GlobalAlloc( GMEM_MOVEABLE, dwSize );
VS_FIXEDFILEINFO * vsInfo;
UINT nLen = 0;
if( hMem )
{
LPVOID pMem = GlobalLock( hMem );
if( pMem && GetFileVersionInfo( szFile, dwHandle, dwSize, pMem ) )
{
if( VerQueryValue( pMem, "\\VarFileInfo\\Translation", ( LPVOID * ) &vsInfo, &nLen ) )
{
*( LPDWORD ) vsInfo = MAKELONG( HIWORD( *( LPDWORD ) vsInfo ), LOWORD( *( LPDWORD ) vsInfo ) );
sprintf( szBlock, "\\StringFileInfo\\%08lx\\", *( LPDWORD )( vsInfo ) );
switch( uAction ) {
case 1:
sprintf( szSubBlock, "%s%s", szBlock, "Comments" );
break;
case 2:
sprintf( szSubBlock, "%s%s", szBlock, "CompanyName" );
break;
case 3:
sprintf( szSubBlock, "%s%s", szBlock, "FileDescription" );
break;
case 4:
sprintf( szSubBlock, "%s%s", szBlock, "FileVersion" );
break;
case 5:
sprintf( szSubBlock, "%s%s", szBlock, "InternalName" );
break;
case 6:
sprintf( szSubBlock, "%s%s", szBlock, "LegalCopyright" );
break;
case 7:
sprintf( szSubBlock, "%s%s", szBlock, "LegalTrademarks" );
break;
case 8:
sprintf( szSubBlock, "%s%s", szBlock, "OriginalFilename" );
break;
case 9:
sprintf( szSubBlock, "%s%s", szBlock, "PrivateBuild" );
break;
case 10:
sprintf( szSubBlock, "%s%s", szBlock, "ProductName" );
break;
case 11:
sprintf( szSubBlock, "%s%s", szBlock, "ProductVersion" );
break;
case 12:
sprintf( szSubBlock, "%s%s", szBlock, "SpecialBuild" );
break;
}
if( VerQueryValue( pMem, szSubBlock, ( LPVOID * ) &szOut, &nLen ) )
bOk = TRUE;
hb_xfree( szBlock );
hb_xfree( szSubBlock );
}
GlobalUnlock( hMem );
GlobalFree( hMem );
}
}
}
if( bOk )
hb_retc( szOut );
else
hb_retc( "" );
}
#pragma ENDDUMP