views:

97

answers:

3

my application uses Bass.dll and i added it to the resource. I wanted it to be extracted before the application starts it chrash. how to void it?

+5  A: 

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.

RRUZ
If you use the new 'delayed' feature introduced in D2010, it handles LoadLibrary() and GetProcAddress() for you.
Remy Lebeau - TeamB
i tried it but some of the function will not work spcially the Bass_Init.
XBasic3000
+3  A: 

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().

Chris Thornton
@Chris Thornton, on the current path. I dont want to have setup etc. The idea is to make it instant, no installation requied to test the audio.
XBasic3000
Well if the "current path" is anywhere inside of \program files on Vista or Windows7 (or the x86 variant of the path on 64-bit systems), the file won't actually be there.
Chris Thornton
+3  A: 

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.

Jørn E. Angeltveit
+1 because this is actually what he's trying to accomplish.
Chris Thornton