I've done About.com guide to embedding dll's in Delphi EXE's which seems to work, so long as I don't actually use the DLL as an external function. Is there anyway to get the code I linked to to work earlier than an unit referenced in the uses clause.
I've tried:
And by external functions I'm referring to a function that looks like:
function MyFunction: Integer; stdcall; external 'fundll.dll';
The problem I'm getting is the usual 'fundll.dll' cannot be loaded (because it's not in the directory) . Zarko's code works (pretty sweet, it creates the dll in that folder) when the code gets that far. But it just crashes before the project even gets rolling when I'm using the external functions I need.
You can't do this with external functions - use LoadLibrary() and GetProcAddress() instead after extracting the DLL, and everything should work.
The reason is that any code will be executed only after all entry points have been resolved by the OS loader. Kind of a chicken and egg problem, if you will.
If you are going to use LoadLibrary() and GetProcAddress(), you might prefer to use BTMemoryModule, which would allow you to use the DLL embedded as a resource without saving it to the filesystem (which the user might not be able to do, depending on the machine's security).
http://www.jasontpenny.com/blog/2009/05/01/using-dlls-stored-as-resources-in-delphi-programs/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With