Dll embedding in Delphi
First to say, I’m aware that dll purpose or libraries in general was/is to modularize programming, so you could move some, somewhat connected, stuff into one place and reuse the code in another projects/replacing just this bit without recompiling the main program, so the idea of embedding dll as a part of exe file itself seems ridiculous, but… yes… there’s but.
The case
What if you have to make sure you will be using some certain function, and that function is located in external library, for which you don’t have or simply don’t want to incorporate sources into your main program. Yes, then your option is either have such dll in resource or `sticked` to the end of your app (not recommended) extract, load, execute and delete after you’re done with it. Messy, isn’t it? First, you can’t be sure if OS will let you use hard drive for storing purposes on every machine, it may be ok in your pc, but that’s not the case in general.
The solution
I stumbled upon one handy library that allows you to load dll stored in memory as binary data, and what else delphi resources are as if not exactly such case?
The library BTMemoryModule is 4 years old already, so I’m not sure if it’ll work on newer compilers/OSes, but it still works for me. On the other hand, I’m still using delphi 9 so I’m not the one to judge ![]()
It’s always good idea to check if there’s any updated version…
Short code snippet that should help you do the job:
First, you need to put your dll into resource (*.res) file, you gotta to compile it as well, so…
- Create .rc file as text file put there:
and save as somename.rc
- compile resource:
that involves using command line, but I’m sure you can cope that ![]()
- include resource in your program
and unit BTMemoryModule in your `uses` line
- Finally you can use it, so let’s do:
var
dllmem: Pointer;
dllsize: Integer;
HResInfo: HRSRC;
HGlobal: THandle;
begin
result := nil;
HResInfo := FindResource(0, ResName, RT_RCDATA);
HGlobal := LoadResource(0, HResInfo);
if HGlobal = 0 then raise EResNotFound.Create(‘Can”t load resource.’);
dllmem := LockResource(HGlobal);
dllsize := SizeOfResource(0, HResInfo);
result := BTMemoryLoadLibary(dllmem,dllsize);
end;
So in our test case it’ll be
fun : pointer;
begin
dllhandle := LoadResDLL(‘RESOURCENAME’);
if (dllhandle = nil) then raise EResNotFound.Create(‘ResLibrary loading failed.’);
BTMemoryGetProcAddress(mp_MemoryModule, Name);
// and now we may get desred function address like this…
fun = BTMemoryGetProcAddress(dllhandle, ‘function_name_you_need’);
// do your stuff here
BTMemoryFreeLibrary(dllhandle); // and clean up…
end;
and that’s all… no hassle, no pain, no additional files to worry about…
And yes, I’m quite aware that’s nothing new, just everything gathered together
Filed under: Delphi, programming | Leave a Comment
Tags: Delphi, dll
Delhi 6
Anyone heard ’bout bollywood? Yes, many times I guess, me included. But that’s the first movie I got hooked on by just watching music videos from it… How weird is that? Haven’t see the movie yet, but that’s soon to change.
You can have my wallpaper meanwhile…
Filed under: Girls, Wallpapers | Leave a Comment
Clipping Point download links…
Anyone heard of clipping point? None? No surprise there. It’s (or should I say was) korean free racing game. It’s web page no longer exists and it’s files are hard to find nowadays… but recently I dug working links for that, go figure!
here’s a little teaser how it looks…
and links to files if you’d like to try it out. Enjoy!
http://rapidshare.com/files/193455399/clippingpoint.part1.rar
http://rapidshare.com/files/193489155/clippingpoint.part2.rar
http://rapidshare.com/files/193514330/clippingpoint.part3.rar
http://rapidshare.com/files/193548373/clippingpoint.part4.rar
http://rapidshare.com/files/193570306/clippingpoint.part5.rar
http://rapidshare.com/files/193594976/clippingpoint.part6.rar
http://rapidshare.com/files/193615050/clippingpoint.part7.rar
http://rapidshare.com/files/194302692/clippingpoint.part8.rar
Filed under: games | 2 Comments
Tags: clipping, game, korean, point, racing
Who Elisabeth Abbott is?
I spotted her first when I was browsing an Eve Adams cast list. And she’s lookin’ smookin’ hot in this picture. I hope she won’t be just a side dish to this serie… :/
Sadly the biggest picture i found was just a tiny on from imdb so these below are bit blurry, but looks way better than just stretched ones on my desktop…
Filed under: Girls, Wallpapers | Leave a Comment
Tags: desktop, Elisabeth Abbott, eve adams, hot, redhead, sexy

