How to catch error while using external library ?

How to catch error while using external library?

this is what I am doing - on windows 2008 server

Soft Declare Function SomeFunction Lib “somelibrary.dll” alias “SomeFunction” (setting As CString, option As CString) As Boolean

on program launch this somelibrary.dll tries to check for bluetooth drivers in system, but could not find any on win 2008 server.

the program crashes.

is there a way to handle this error, as i cannot change code inside the dll

all help welcome…


C++ header for that function?
Maybe parameters are wrong.

sorry christian, can’t look inside the dll.
it gives name of driver file missing in msgbox and then program just hangs.

but if the bluetooth drivers are installed on - then all works fine?
the problem is to handle this error before it occurs.

how did you buy the declare without the C++ function declaration?

what do u mean by c++ function declaration ?

if i understand correct, the function is SomeFunction as mentioned in code above.

I think he meant how did you get the right declare if you don’t have a header file or some other way to know if the declare is right ?

the problem is not the having right declare or the dll, the problem is the dll calls another windows dll which if doesn’t exist then messagebox pops up saying it is missing and crashes.

Try using System.IsFunctionAvailable with a function name contained on the first dll.
This starts dll chain loading including all nested dlls.
If anyone of the nested dll does not exist IsFunctionAvailable returns false.

Here works fine.

Maurizio, have you the function prototype? The one in header files…
Perhaps you are using wrong parameters.