tags:

views:

553

answers:

5

Is it possible to check what version of BPL (ie Rtl70.BPL, Indy70.bpl etc) are installed on a clients computer when the program starts?

I have had some programs crash because the BPL on there computer is different to the ones on the build machine.
If i have to add each BPL used into the installer on each update, i think it will defeat one of the points on using them.

Delphi 7, if it makes a difference


Just a follow up on the issue i had.
The rtl70.bpl file was only slightly different between the build computer and the clients.

Clients Computer: 7.0.4.453 760 KB (778,240 bytes) Tuesday, 20 August 2002, 4:40:26 PM
Build computer: 7.0.4.453 760 KB (778,240 bytes) ‎Friday, ‎9 ‎August ‎2002, ‏‎11:30:00 PM

The updater i was using ignored them as being the same (no change in build number), but when i manually deleted and copied the files every thing seemed to work.

+2  A: 

If your program crashes, it's probably because it can't load the library it's dynamically linked with. (As you where saying, this happens when the system can't find a copy of the needed libaries anywhere in the search path).

The problem is, that this happens at startup of an application, which the Windows OS does via an API called MapAndLoad (also read this). This API is called before your application is even started, so I see no way to intercept this.

One suggestion I could give, would be to use a launcher (which has to be statically linked, to prevent problems for when there are /no/ libraries at all). This launcher could inspect your actual application, see what imports it needs, checks your environment and display a nice failure/troubleshooting suggestion dialog to the user.

PatrickvL
+1  A: 

Is it possible to check what version of BPL (ie Rtl70.BPL, Indy70.bpl etc) are installed >on a clients computer when the program starts? I have had some programs crash because the BPL on there computer is different to the ones >on the build machine. If i have to add each BPL used into the installer on each update, i think it will defeat >one of the points on using them.

You must install your copy (develop) of BPL's (RTL70.bpl, INDY.BPL,...) into the same directory that you install the application. Your application search first the BPL's at the same directory and after search at directories inside the path. The negative point is that your system will can have several copies of the same BPL, the positive point is that you will not have problems with differents versions of the same file.

Regards.

P.D: Excuse-me for my bad english.

Neftalí
A: 

Sometimes Delphi adds of automatic form the line:
{$R ' *.res'}
to the files of project or packages.

Comment (//) that line and to compile again.

Neftalí
+2  A: 

Unfortunately, no. If the crash is due to missing imports from the .bpl files required by your application, there is no way (short of rewriting the Delphi RTL and linker themselves) to check for those packages from within the crashing executable itself. PatrickvL's solution is probably the best for your situation.

Neftalí's solution might be an option - of course, at the cost of packaging the RTL, duplicating a lot of files, and losing one of the points of having packages in the first place. However, if you're using private DLLs (i.e., if you copy the DLLs in your private binaries directory) then you should also create an empty file with the same name as your executable but appending the extension .local to it, i.e. for notepad.exe you'd create a notepad.exe.local. See Raymond Chen's article on DLL redirection for more details.

Mihai Limbășan
Thankyou, that is what i wanted to hear, kind of.. ;)
Christopher Chase
A: 

You cannot do that from an executable that uses these bpls, but you could have a small startup-program that checks the bpls and then calls the main executable.

Thomas Mueller