// Just for FWH 32 bits
// Author: Anonimo
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
/*
function Main()
local n
for n = 1 to 12
MsgInfo( GetFileVersionInfo( "filever.exe", n ) )
next
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, "Author" );
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, "AppBuild" );
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
//----------------------------------------------------------------------------//
1 VERSIONINFO
FILEVERSION 2, 4, 0, 1
PRODUCTVERSION 4, 2, 0, 0
FILEOS VOS__WINDOWS16
FILETYPE VFT_DLL
{
BLOCK "StringFileInfo"
BOOL GetAppVersion( char *LibName, WORD *MajorVersion, WORD *MinorVersion, WORD *BuildNumber, WORD *RevisionNumber )
{
DWORD dwHandle, dwLen;
UINT BufLen;
LPTSTR lpData;
VS_FIXEDFILEINFO *pFileInfo;
dwLen = GetFileVersionInfoSize( LibName, &dwHandle );
if (!dwLen)
return FALSE;
lpData = (LPTSTR) malloc (dwLen);
if (!lpData)
return FALSE;
if( !GetFileVersionInfo( LibName, dwHandle, dwLen, lpData ) )
{
free (lpData);
return FALSE;
}
if( VerQueryValue( lpData, "\\", (LPVOID *) &pFileInfo, (PUINT)&BufLen ) )
{
*MajorVersion = HIWORD(pFileInfo->dwFileVersionMS);
*MinorVersion = LOWORD(pFileInfo->dwFileVersionMS);
*BuildNumber = HIWORD(pFileInfo->dwFileVersionLS);
*RevisionNumber = LOWORD(pFileInfo->dwFileVersionLS);
free (lpData);
return TRUE;
}
free (lpData);
return FALSE;
}
'------------------------------------------------------------------------------
' Averiguar la versión de un fichero (ejecutable o DLL) (24/Jun/08)
'
' ©Guillermo 'guille' Som, 2008
'------------------------------------------------------------------------------
Option Strict On
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows.Forms
Imports System.Diagnostics
Public Class Form1
Private Sub btnMostrar_Click(ByVal sender As Object, _
ByVal e As EventArgs) _
Handles btnMostrar.Click
txtInfo.Text = FileVersion(txtFichero.Text)
End Sub
Private Sub btnExaminar_Click(ByVal sender As Object, _
ByVal e As EventArgs) _
Handles btnExaminar.Click
Dim ofD As New OpenFileDialog
With ofD
.FileName = txtFichero.Text
.Filter = "Ejecutables (*.exe; *.dll)|*.exe;*.dll"
If .ShowDialog = Windows.Forms.DialogResult.OK Then
txtFichero.Text = .FileName
End If
End With
End Sub
Private Function FileVersion(ByVal elPath As String) As String
Dim fvi As System.Diagnostics.FileVersionInfo = _
System.Diagnostics.FileVersionInfo.GetVersionInfo(elPath)
'Return fvi.FileVersion
'Return fvi.ProductVersion
Dim sb As New System.Text.StringBuilder
sb.AppendLine("ProductName: " & fvi.ProductName)
sb.AppendLine("FileDescription: " & fvi.FileDescription)
sb.AppendLine("FileVersion: " & fvi.FileVersion)
sb.AppendLine("ProductVersion: " & fvi.ProductVersion)
sb.AppendLine("LegalCopyright: " & fvi.LegalCopyright)
Return sb.ToString
End Function
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As EventArgs) _
Handles MyBase.Load
Dim ensamblado As System.Reflection.Assembly = _
System.Reflection.Assembly.GetExecutingAssembly
txtFichero.Items.Add(ensamblado.Location)
txtFichero.Items.Add("E:\gsCodigo\Vb5_L\gsCalc\gsCalc.exe")
txtFichero.Items.Add("C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll")
txtFichero.Items.Add("C:\Windows\winhlp32.exe")
txtFichero.Items.Add("C:\Windows\Microsoft.NET\Framework\v3.5\vbc.exe")
txtFichero.Items.Add("C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe")
txtFichero.SelectedIndex = 0
End Sub
Private Sub Form1_DragEnter(ByVal sender As Object, _
ByVal e As DragEventArgs) _
Handles MyBase.DragEnter, txtFichero.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Private Sub Form1_DragDrop(ByVal sender As Object, _
ByVal e As DragEventArgs) _
Handles MyBase.DragDrop, txtFichero.DragDrop
If e.Data.GetDataPresent("FileDrop") Then
txtFichero.Text = CType(e.Data.GetData("FileDrop", True), String())(0)
End If
End Sub
End Class
1 VERSIONINFO LOADONCALL MOVEABLE DISCARDABLE IMPURE
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x0
FILEFLAGS 0x0
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "Comments", "Sistema Desenvolvido Pela Empresa TAL - http://www.empresatal.com.br \0"
VALUE "CompanyName", "Sistema Desenvolvido Pela Empresa TAL - http://www.empresatal.com.br \0"
VALUE "FileDescription", "NOMBRE DEL SISTEMA\0"
VALUE "FileVersion", "1.0000\0"
VALUE "InternalName", "Proyecto TAL\0"
VALUE "LegalCopyright", "Empresa Informática Ltda\0"
VALUE "LegalTrademarks", "NOMBRE SISTEMA / SISTEMA\0"
VALUE "OriginalFilename", "NOMBRE_EXE.EXE\0"
VALUE "ProductName", "NOMBRE DEL SISTEMA\0"
VALUE "ProductVersion", "1.0000\0"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x416, 0x4B0
}
}
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 55 guests