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
Solved

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

Posted on 1999-01-13
10
225 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
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apparent collision of square brackets in jQuery and Classic ASP 12 29
Slow process to read Excel 15 134
SignTool Error with Windows 10 5 172
Where did System.Data.Objects go? 2 40
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 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