Finds bitness of .exe

HMG Samples and Enhancements

Moderator: Rathinagiri

Post Reply
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Finds bitness of .exe

Post by bpd2000 »

Get-BinaryType function Finds bitness of .exe

Code: Select all

// bpd2000
//Get-BinaryType function Finds bitness of .exe
/*
The following program is a sample use of GetBinaryType for determining
the type of executable a file is. Evidently GetBinaryType does not 
differentiate between console and GUI programs but otherwise it does
provide useful information.
*/

#include "hmg.ch"

Function Main
  Local aNewFile := {}, aTypes, cBaseFolder
  cBaseFolder := GetStartupFolder()
  aTypes     := { {'Executable files (*.exe)', '*.exe'} }
  aNewFile   := GetFile( aTypes, 'Select executable files', cBaseFolder, .T. )

 IF !Empty(aNewFile)
    Get_Exe_type(aNewFile[1])
  Else
   Msginfo("No file selected")
Endif
  
return nil

Function Get_Exe_type(cExe_File)
  Local cFileName := cExe_File
  Local nExe_Type_Code := 0
  nExe_Type_Code := GetBinaryType( cFileName )

  If nExe_Type_Code >= 0 .and. nExe_Type_Code <= 6
    Do case
     Case nExe_Type_Code == 0
       MsgInfo( "A 32-bit Windows-based application", "Executable file type" + space(10) )
     Case nExe_Type_Code == 1
       MsgInfo( "An MS-DOS – based application", "Executable file type" + space(10) )
     Case nExe_Type_Code == 2
       MsgInfo( "A 16-bit Windows-based application", "Executable file type" + space(10) )
     Case nExe_Type_Code == 3
       MsgInfo( "A PIF file that executes an MS-DOS – based application", "Executable file type" + space(10) )
     Case nExe_Type_Code == 4
       MsgInfo( "A POSIX – based application", "Executable file type" + space(10) )
     Case nExe_Type_Code == 5
       MsgInfo( "A 16-bit OS/2-based application", "Executable file type" + space(10) )
     Case nExe_Type_Code == 6
       MsgInfo( "A 64-bit Windows-based application.", "Executable file type" + space(10) )
     Endcase  
    ELSE
      MsgInfo( "Not executable", "Executable file type" + space(10) )
   ENDIF
Return nil

#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"

HB_FUNC( GETBINARYTYPE )
{
 DWORD lpBinaryType ;
  GetBinaryType(( LPCTSTR ) hb_parc( 1 ),&lpBinaryType) ;
 hb_retni(lpBinaryType) ;
 }
#pragma ENDDUMP

/*
More info at
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364819%28v=vs.85%29.aspx
https://gist.github.com/MattUebel/2292484
*/
BPD
Convert Dream into Reality through HMG
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Finds bitness of .exe

Post by Rathinagiri »

Thank a lot.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Finds bitness of .exe

Post by serge_girard »

Thanks for sharing!

Serge
There's nothing you can do that can't be done...
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Finds bitness of .exe

Post by srvet_claudio »

Very nice, I will include in the next release
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Finds bitness of .exe

Post by danielmaximiliano »

Gracias por compartir !!!!!!
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Finds bitness of .exe

Post by mustafa »

Very useful
Thank you
Mustafa
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Finds bitness of .exe

Post by esgici »

Thanks Mr. Dave
Viva INTERNATIONAL HMG :D
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Finds bitness of .exe

Post by bpd2000 »

Thank you to all
BPD
Convert Dream into Reality through HMG
Post Reply