Solved

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

Posted on 1999-01-13
10
232 Views
Last Modified: 2013-12-03
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?
0
Comment
Question by:mohanad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 

Author Comment

by:mohanad
ID: 1418639
Edited text of question
0
 

Author Comment

by:mohanad
ID: 1418640
Edited text of question
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 1418641
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.
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 1

Expert Comment

by:dnavarro
ID: 1418642
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

0
 

Author Comment

by:mohanad
ID: 1418643
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?
0
 

Author Comment

by:mohanad
ID: 1418644
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
0
 

Expert Comment

by:ddgamer
ID: 1418645
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.
0
 

Author Comment

by:mohanad
ID: 1418646
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

0
 
LVL 3

Accepted Solution

by:
luisr earned 100 total points
ID: 1418647
Send me an e-mail and I'll give you some code that does it. Actually is Windows code, but it accesses the version resource by parsing the executable file, not through Windows API class.

My e-mail is luisr@iname.com
0
 
LVL 3

Expert Comment

by:luisr
ID: 1418648
Have you tested the code that I sent you? Did it work?
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question