Linking Delphi DLL with Scilab

cbeckmann christianbeckman at web.de
Wed May 23 12:22:14 CEST 2012


Hi,

I have problems at calling procedures from a DLL compiled with Delphi
(actually Turbo Delphi). Linkage to the DLL obviously seems to work. 

Although tested at different Scilab versions, for example 5.3.3, Scilab
always shows the same warning:"Scilab has found a critical error
(EXCEPTION_ACCESS_VIOLATION) with "call" function."

The DLL and Scilab versions are 32bit. But I use Windows XP 64bit.

Maybe someone could help me with the code. I can't find any error.  I am
also a little bit wondering why I should use the stdcall calling convention
as the Scilab help recommends the cdecl calling convention for C-code.
Nonetheless, stdcall calling convention didn't work neither.

The Turbo Delphi Code is as follows:
/library Project4;

{$R *.res}
type PointerLongInt =  ^LongInt;    // LongInt should be 32bit in Turbo
Delphi
var
a_global, b_global: LongInt;


procedure AddIntegers(a, b: PointerLongInt); cdecl;
begin
  a_global:=a^;
  b_global:=b^;
end;

procedure GetResult(c: PointerLongInt); cdecl;
begin
  c^ := 9;
end;

exports
   AddIntegers, GetResult;
 
begin
end./

The scilab code is as follows:
/DLLpath='c:\Programmierung\Delphi_DLL_CouplingWithScilab\Project4.dll';
try
  x=link(DLLpath, ['AddIntegers', 'GetResult'], 'c');
catch
  mprintf('\n Error!!!!!!! Linkage to .dll failed' + ascii(10));
  abort;
end;

a=2;
b=2;
c=0;
d=0;

a=iconvert(a, 4);
b=iconvert(b, 4);
c=iconvert(c, 4);
d=iconvert(d, 4);

try
  mprintf('\n First Call\n');
  call("AddIntegers", a, 1, "i", b, 2, "i")
catch
  mprintf('\n Error in First Call');
end;
try
  mprintf('\n Second Call\n');
  c= call("GetResult", "out",[1,1],1,"i")
catch
  mprintf('\n Error in Second Call ');
end;
ulink(x);/

Surprisingly, the first call didn't work, but the second did. But I am not
that sure about the properties of the integer type in the call function, but
i guess it should be unsigned 32bit, or?

Is there also anybody who has successfully called functions inside a Delphi
DLL and could send me a short test code or similar?


--
View this message in context: http://mailinglists.scilab.org/Linking-Delphi-DLL-with-Scilab-tp3967008p4008362.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list