ashishjain
27th February 2011, 18:13
Hi,

I am getting fatal error while calling a dll through function exec_dll_function.
The error is "can not read session or object..."
I do also suffix "o" with dll name while passing the dll but result is same.

I am getting this error only if dll does not exist in the system. But if dll exists in the system, there is no error.

My scenario is like that...
1. User is passing the dll name through input field present on the form.
2. DLL may be present or dll may not be present...
2.1) If dll exists then it should execute
2.2) if dll does not exist function "exec_dll_function" should return -1

but currently in case of 2.2 system is giving the fatal error.

Is there any other way (or function) to handle it.

quick reply will be appreciated.

Thanks.

vahdani
27th February 2011, 19:32
Hi,

use load_dll, get_function and exec_function functions instead. This makes sure, that the DLL and the funtion exists before executing. I'd use something like this:


long dll_id, func_id, ret
string dll_name(20)

dll_name = "o"& trim$(some.dll.name)
dll_id = load_dll(dll_name, true) |overlad
if dll_id then
func_id = get_function( dll_id, "some.function.name" )
if func_id then
ret = exec_function( dll_id, func_id)
endif
endif

ashishjain
27th February 2011, 20:16
Hi Vadhani,

Thanks for replying but m getting the same error while loading dll using function load_dll(...) but result is same. Please find attached the screen shot of the error message.

ashishjain
27th February 2011, 21:32
Hi All,

Finally i have got the solution for query raised by me. Here we go...

Step-1: include library <bic_tt> in the program script.
Step-2: write below code..

dll_id = tt.library(lib.name, dll.desc)

|* lib.name is a program variable which holds dll name. Please ensure that
|* it should not suffix "o". Example: tdslsdllimport

if dll_id = 1 then
ret.value = exec_dll_function(dll.name,func.name, dll.ret)

|* dll.name is a program variable which holds dll name. Please ensure that
|* it should suffix "o". Example: otdslsdllimport
|* func.name is a program variable which holds function name present in dll.
|* Please ensure function should be of extern type in dll

if ret.value = -2 then
message("Function is not found")
choice.again()
endif
else
mess("DLL does not exist")
choice.again()
endif