###这是FORTRAN编的动态链接库程序
subroutine zhu9(size,x1,x2,x3,x4)
! Expose subroutine zhu9 to users of this DLL
!DEC$ ATTRIBUTES DLLEXPORT::zhu9
!DEC$ ATTRIBUTES ALIAS:'zhu9'::zhu9
!DEC$ ATTRIBUTES REFERENCE::x3,x4
integer(4) size
Real(8) x1(size,size),x2(size,size)
Real(8) x3(size,size),x4(size,size)
x3=x1+x2;
x4=x1-x2;
end subroutine zhu9
####这是DELPHI调用该动态链接库程序。当输出变量只有1个,如x3或x4时运行正常。但是x3、x4同时作为输出量后, x4无结果或显示内存地址错,什么原因?望指教
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit3: TEdit;
Button1: TButton;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
Procedure zhu9(Const size,x1,x2:pointer;Var x3,x4:array of double);stdcall;external'DLL\zhu9.dll';
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
a1,a2: array of double;
a3,a4: array of double;
size:integer;
begin
SetLength(a1,4);
SetLength(a2,4);
SetLength(a3,4);
SetLength(a4,4);
a1[0] := 1; a1[1] := 2.00; a1[2] := 3.00; a1[3] := 4.00;
a2[0] :=10; a2[1] :=20.00; a2[2] :=30.00; a2[3] :=40.00;
size:=2;
zhu9(@size,@a1[0],@a2[0],a3,a4);
Edit3.Text:=floattostr(a3[0]);
Edit4.Text:=floattostr(a3[1]);
Edit5.Text:=floattostr(a4[0]);
Edit6.Text:=floattostr(a4[1]);
end;
end.