Link to home
Start Free TrialLog in
Avatar of mohanad
mohanad

asked on

geting version number, compnay name of EXE files (not using API).

How can I read version number and company name of an EXE or DLL file.
I know there are API calls to do this but my program has to run in dos when windows is not running.
What is the structure of windows EXE header and where can I find books or source code to do what I want?
Avatar of mohanad
mohanad

ASKER

Edited text of question
Avatar of mohanad

ASKER

Edited text of question
Information about Windows EXE file you can find in Book:
Tom Swan "Inside Windows File Formats", 15 Chapter.
For get Version,exe file,and other parameter you must read RES_VERSION part of EXE file. In windows there are some API in VER.DLL, that returns this information:
you can see names in ver.h
But in Dos....
I am afraid, that you must write same functions and that is
not easy. Can be you can use Console Application.
Can you read BASIC code?  If so, you have to call GetFileVersionInfo() and VerQueryValue().

$RESOURCE "VERINFO.PBR"
$INCLUDE  "WIN32API.INC"

FUNCTION MakeVerStr(BYVAL VerNumMS AS LONG, BYVAL VerNumLS AS LONG) AS STRING

  LOCAL Major AS INTEGER
  LOCAL Minor AS INTEGER
  LOCAL temp  AS STRING

  Major = VerNumMS \ &H10000
  Minor = VerNumMS AND &HFFFF&

  temp  = FORMAT$(Major) & "."

  IF Minor < 10 THEN
    temp = temp & "0"
  END IF

  temp = temp & FORMAT$(Minor)

  IF VerNumLS THEN
    temp = temp & " Build" & STR$(VerNumLS)
  END IF

  FUNCTION = temp

END FUNCTION

FUNCTION PbMain() AS LONG

  LOCAL file AS ASCIIZ * 256
  LOCAL info AS ASCIIZ * 64
  LOCAL t    AS ASCIIZ PTR
  LOCAL ffi  AS VS_FIXEDFILEINFO PTR

  file = COMMAND$

  IF LEN(file) = 0 THEN
    STDOUT "VERINFO.EXE - Display version information"
    STDOUT "Copyright (c) 1998 PowerBASIC, Inc."
    STDOUT ""
    STDOUT "Usage: VERINFO filename"
    FUNCTION = 1
    EXIT FUNCTION
  END IF

  IF LEN(DIR$(file)) = 0 THEN
    STDOUT "Error! " & file & " not found."
    EXIT FUNCTION
  END IF

  STDOUT "Version info for " & file

' ** Allocate a buffer for the version info data
  size& = GetFileVersionInfoSize(file, z&)

  IF size& = 0 THEN
    STDOUT "No version resource available."
    EXIT FUNCTION
  END IF

  Buffer$ = SPACE$(size&)

' ** Get the version info data into the buffer
  GetFileVersionInfo file, z&, size&, BYVAL STRPTR(Buffer$)

' ** Read the company name from the buffer
  VerQueryValue BYVAL STRPTR(Buffer$), "\StringFileInfo\040904E4\CompanyName", t, z&

' ** Display it on the screen
  STDOUT "    Company name: " & @t

' ** Read the copyright from the buffer
  VerQueryValue BYVAL STRPTR(Buffer$), "\StringFileInfo\040904E4\LegalCopyright", t, z&

' ** Display it on the screen
  STDOUT " Legal Copyright: " & @t

' ** Read the VS_FIXEDFILEINFO info
  VerQueryValue BYVAL STRPTR(Buffer$), "\", ffi, z&

  ' Now build the output report
  STDOUT " Product version: " & MakeVerStr(@ffi.dwProductVersionMS, @ffi.dwProductVersionLS)

END FUNCTION

Avatar of mohanad

ASKER

Thanks for the reply, but I would like to be able to reas the version infomration of a Windows EXE fil, file from DOS, DOS, DOS, program not using API calls, all the replys I have been getting are using API calls.
Can any body out thier help me please?
Avatar of mohanad

ASKER

Thnaks for the reply, but my quastion still not answered.
I would like to able to read version information of a Windows EXE files from  a DOS, DOS, DOS program not using Windows and API.
All the replys been getting are Windows Code, can any one out there give the source code and to read exe version info from DOS.
This is VVVery important, thanks.
M.Shurrab
If you are needing the info from the PE format then you can find a thorough description at the following:

http://www.microsoft.com/win32dev/base/pefile.htm

Hope it helps.
Avatar of mohanad

ASKER

Thanks all for the replys, but may quastion is still not answered: I would like to run my progrm form DOS,DOS,DOS and not using any windows api calls.
The program should be able to read the verion information such as compnay name, verion, etc. (i.e read the windows header from a dos program).
Thanks

ASKER CERTIFIED SOLUTION
Avatar of Luis Alonso Ramos
Luis Alonso Ramos
Flag of Mexico image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Have you tested the code that I sent you? Did it work?