File-information in exe-file

Post Reply
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

File-information in exe-file

Post 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
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

Post 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

//----------------------------------------------------------------------------//
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Baxajaun
Posts: 853
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Post by Baxajaun »

Hi Marc,

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

Best regards,

Felix
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post 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
User avatar
Baxajaun
Posts: 853
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Post 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
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

Post 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
}
}
Best Regards,

Marco Turco
SOFTWARE XP LLP
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post by Marc Vanzegbroeck »

Thanks Marco and Felix,

I'm gone try it.

Regards,

Marc
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post 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
Post Reply