Menu

#6 Better DLL loading order for Delphi XE2 and FB Embedded

open
nobody
None
5
2011-11-09
2011-11-09
No

FB depends upon IBM Classes for Unicode (set of ICU****.DLL files)

When applicaion loads FBEmbed.dll, those DLLs should be located in the same folder, as exe and fbembed.dll are. That is - if they are in the same folder.
And if exe and fbembed.dll are in different ones ?

Default windows behaviour then would be to search for ICU***DLL in the same folder with EXE, despite the fact that it is FBEmbed.DLL that requires them, not the application. Obviously, that would fail, and FB would not be loaded.

Change needed: uiBase.pas, line 3811
[code]function TUIBaseLibrary.Load(const lib: string = GDS32DLL): Boolean;
......
{$IFDEF MSWINDOWS}
// FGDS32Lib := LoadLibrary(PChar(lib));
FGDS32Lib := LoadLibraryEx(PChar(ExpandUNCFileName(lib)), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
[/code]

This makes FB Embedded load correctly, even when located outside of application folder.

Backward compatibility:
* LoadLibraryEx was introduced in Win2000. UIB is not expected to run on NT4, is it ?
* ExpandUNCFileName was introduced at least in Delphi 6 and maybe even Delphi 5, i don't remeber already. It is mentioned in rather old article at http://blong.com/Conferences/DCon2001/VCLvsCLX/VCLvsCLX.htm

Links:
http://tracker.firebirdsql.org/browse/CORE-1814
http://msdn.microsoft.com/en-us/library/ms684179\(v=VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms682586\(v=VS.85).aspx#alternate_search_order_for_desktop_applications

Why place EXE and DLL in different folder?
Delphi XE2 introduced multiplatform cross-compiling. And it endorsed Microsoft VC++ style of placing EXEs into Win32\Debug and Win32\Release subfolders from the sources.

It is natural for client machine to have FB Embedded in the same folder as with installed application. However on developer machine it would better keep one recently released FB version in single place, rather than copy it into every of Release/Debug subfolders. If not for other reasons, then for mere comfort of deleting the folder with all its content and allowing Delphi to re-create all that required on build.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.