Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading applications additional data

Status
Not open for further replies.

imagenetics

Programmer
Dec 8, 2003
66
PL
How to read an application's version info (company name, internal name, product name, original file name) to verify if the *.exe is valid when I want to launch only the specific executable with my program and avoid launching any other program with the same name.
 
ASAIK, there is no VCL component that comes with Buider to to this. You can buy/download a component or use MFC's methods.


James P. Cottingham

There's no place like 127.0.0.1.
There's no place like 127.0.0.1.
 
It sounds like you want to just verify that the file is valid. There are several options. One is to use a checksum. There are several available, maybe try to find a 32 bit CRC checksum routine which uses polynomials. For simplicity, you can just use a running sum checksum. I'll explain that one.

When you know that your executable is complete, go byte by byte through the file, and add up all of the bytes into an unsigned integer. This is your checksum. Hard code that checksum comparison into the OTHER program that you will be executing this one from.

When you want to execute Program B from Program A. Program A opens Program B's file, sums up all of the bytes, then checks if the checksums match. If so, execute Program B. If not, do whatever. Just remember, every time Program B is so much as touched and compiled differently, you will have to recode it's checksum into Program A...unless you have Program A update itself from the internet once in a while, and you just store the checksum in a data file that is downloadable.

You can still use this concept if you didn't write Program B, obviously, but if you are concerned with Program B being updated, you could do just what you suggested first. In this case, I tried to find further information on some MFC functions to grab file info with, but couldn't find any. I don't know if Borland supports those extended functions in C++ Builder yet *shrugs*. Let us know if you do find the function names and where they are located. They would be most useful.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top