开发者

How to extract dll from the resource

my application uses Bass.dll and i added it to the resourc开发者_开发问答e. I wanted it to be extracted before the application starts it chrash. how to void it?


XBasic3000, I think your problem is wich maybe you are using a external declaration like this

function Foo: integer; stdcall; external 'bass.dll';

so the OS cannot resolve the address of the function in the dll.

instead you must use the LoadLibrary() and GetProcAddress() functions after extracting the DLL, in this way you can avoid crashing by checking for the existance of the DLL.


I think that the solution to your problem is described by RPUZ or Chris Thornton (both up-voted). If extracting files to the hard drive causes you trouble, you should know that it is possible to load the DLL directly from memory instead.

Zarko Gajic explains at delphi.about.com.


If you extract the DLL, where do you put it? Your app isn't a setup app (setup.exe) which would have special privleges, so it cannot write to \windows\system32 or even \program files\yourapp under Vista/Windows7. Attempting to put it into the program directory will result in it being located elsewhere, via the VirtualStore. So you must verify FileExists('bass.dll') prior to attempting LoadLibrary().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜