FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour File-information in exe-file
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
File-information in exe-file
Posted: Tue May 06, 2008 12:32 PM

Hi,

Does anyone knows how to include the File-description, produnt-version, product-name,...' that you can see if you show the properties of a file in the explorer.

Thanks,
Marc

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
File-information in exe-file
Posted: Tue May 06, 2008 01:07 PM

Here it is.

// Just for FWH 32 bits

include "FiveWin.ch"

//----------------------------------------------------------------------------//

function GetExeVersion(cFile)
return( ctod( GetFileVersionInfo( cFile, 13 ) ) )

return nil

//----------------------------------------------------------------------------//

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 &amp;&amp; GetFileVersionInfo( szFile, dwHandle, dwSize, pMem ) )
     {
        if( VerQueryValue( pMem, "\\VarFileInfo\\Translation", ( LPVOID * ) &amp;vsInfo, &amp;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;

              case 13:
                 sprintf( szSubBlock, "%s%s", szBlock, "DateOfRelease" );
                 break;
           }

           if( VerQueryValue( pMem, szSubBlock, ( LPVOID * ) &amp;szOut, &amp;nLen ) )
              bOk = TRUE;

           hb_xfree( szBlock );
           hb_xfree( szSubBlock );
        }

        GlobalUnlock( hMem );
        GlobalFree( hMem );
     }
  }

}

if( bOk )
hb_retc( szOut );
else
hb_retc( "" );
}

pragma ENDDUMP

//----------------------------------------------------------------------------//

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 990
Joined: Wed Oct 19, 2005 02:17 PM
File-information in exe-file
Posted: Tue May 06, 2008 02:29 PM

Hi Marc,

with you Resource Editor (PellesC, ResEdit) in your resource file.

Best regards,

Felix

Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
File-information in exe-file
Posted: Tue May 06, 2008 04:48 PM

Marco,

That's very nice. But I was wondering how to get the description into the exe-file. Your code is very useful once I get te text into the exe-file, thanks.

Felix,

I'm still using workshop. Can it also be done with workshop.
What is the code generated with PellesC or ResEdit to set the descriptor or version into the exe?

Thanks,
Marc

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 990
Joined: Wed Oct 19, 2005 02:17 PM
File-information in exe-file
Posted: Tue May 06, 2008 05:02 PM

Hi Marc,

in my resource file (.rc) i put the next code:

//
// Version Information resources
//
LANGUAGE LANG_SPANISH, 3
1 VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEOS VOS__WINDOWS32
FILETYPE VFT_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040a04b0"
BEGIN
VALUE "Comments", "Arranque de Viruta. Proyecto Txirbila\0"
VALUE "CompanyName", "Matrici S. Coop.\0"
VALUE "FileDescription", "Arranque de Viruta - Conexión Autómata\0"
VALUE "FileVersion", "1.0.0.0\0"
VALUE "InternalName", "Gypaetus Barbatus\0"
VALUE "LegalCopyright", "Matrici S. Coop.\0"
VALUE "OriginalFilename", "VirutaServer.exe\0"
VALUE "ProductName", "Txirbila Server\0"
VALUE "ProductVersion", "1.0.0.0\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 1034, 1200
END
END

I use ResEdit (Julien Ado) http://www.resedit.net/

Best regards,

Felix

Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
File-information in exe-file
Posted: Tue May 06, 2008 05:22 PM

Hi Mark,
you have only to create a productver.rc (or with the name you prefer) file with the following values to link to your app.


1 VERSIONINFO
FILEVERSION 2008, 0, 5, 6
PRODUCTVERSION 2008, 0, 5, 6
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "Author", "Software XP's Devl.Team\000"
VALUE "CompanyName", "Software XP LLP\000"
VALUE "FileDescription", "Building Administration Software\000"
VALUE "FileVersion", "2008\000"
VALUE "InternalName", "pigc.exe\000"
VALUE "LegalCopyright", "\251 Software XP LLP 2001-2008\000"
VALUE "ProductName", "Building Manager\000"
VALUE "ProductVersion", "2008\000"
VALUE "OriginalFilename", "pigc.exe\000"
VALUE "PrivateBuild","\000"
VALUE "SpecialBuild","\000"
VALUE "DateOfRelease","6/5/2008\000"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 1033, 1252
}
}

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
File-information in exe-file
Posted: Tue May 06, 2008 08:50 PM

Thanks Marco and Felix,

I'm gone try it.

Regards,

Marc

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
File-information in exe-file
Posted: Wed May 07, 2008 09:15 AM

Marc,

Using Workshop, just select Resource, New, then select Version Info. This will place the default Version info at the bottom of your resource list. Just edit the default info to whatever you wish.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
File-information in exe-file
Posted: Wed May 07, 2008 08:08 PM

Thanks James,

Workshop created the text. I only added some VALUE's like Felix and Marco's examples because Workshop did't create all of them.

Regards,
Marc

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite

Continue the discussion