Page 1 of 1

File-information in exe-file

Posted: Tue May 06, 2008 12:32 pm
by Marc Vanzegbroeck
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

Posted: Tue May 06, 2008 1:07 pm
by Marco Turco
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 && 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;

case 13:
sprintf( szSubBlock, "%s%s", szBlock, "DateOfRelease" );
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

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

Posted: Tue May 06, 2008 2:29 pm
by Baxajaun
Hi Marc,

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

Best regards,

Felix

Posted: Tue May 06, 2008 4:48 pm
by Marc Vanzegbroeck
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

Posted: Tue May 06, 2008 5:02 pm
by Baxajaun
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

Posted: Tue May 06, 2008 5:22 pm
by Marco Turco
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
}
}

Posted: Tue May 06, 2008 8:50 pm
by Marc Vanzegbroeck
Thanks Marco and Felix,

I'm gone try it.

Regards,

Marc

Posted: Wed May 07, 2008 9:15 am
by James Bott
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

Posted: Wed May 07, 2008 8:08 pm
by Marc Vanzegbroeck
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