File-information in exe-file

File-information in exe-file

Postby Marc Vanzegbroeck » 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
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Marco Turco » Tue May 06, 2008 1: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 && 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
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby Baxajaun » Tue May 06, 2008 2:29 pm

Hi Marc,

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

Best regards,

Felix
User avatar
Baxajaun
 
Posts: 962
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Postby Marc Vanzegbroeck » Tue May 06, 2008 4: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
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Baxajaun » Tue May 06, 2008 5: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
User avatar
Baxajaun
 
Posts: 962
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Postby Marco Turco » Tue May 06, 2008 5: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby Marc Vanzegbroeck » Tue May 06, 2008 8:50 pm

Thanks Marco and Felix,

I'm gone try it.

Regards,

Marc
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby James Bott » Wed May 07, 2008 9: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Marc Vanzegbroeck » Wed May 07, 2008 8: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
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 47 guests