HB_FUNC( GETFILEVERSIONINFO ) SOLVED!

HB_FUNC( GETFILEVERSIONINFO ) SOLVED!

Postby JC » Fri Aug 15, 2008 1:16 pm

Dear Antonio,

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
Last edited by JC on Fri Aug 15, 2008 2:37 pm, edited 1 time in total.
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby JC » Fri Aug 15, 2008 2:37 pm

Solved!!

I put a sublanguage for english into my .RC file!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Fri Aug 15, 2008 5:58 pm

very good :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 74 guests