Solved

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

Posted on 1999-01-13
10
215 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
10 Comments
 

Author Comment

by:mohanad
Comment Utility
Edited text of question
0
 

Author Comment

by:mohanad
Comment Utility
Edited text of question
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
Comment Utility
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
 
LVL 1

Expert Comment

by:dnavarro
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:mohanad
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Have you tested the code that I sent you? Did it work?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now