Private Declare Sub Dll2 Lib "d:\Dll2.dll" (ByRef a As Single, ByRef b As Single, ByRef n As Long)
Private Sub Command1_Click()
Dim mya(1) As Single
Dim myb(1) As Single
Dim n As Long
mya(0) = 1.01
mya(1) = 1.1
myb(0) = 3.1
myb(1) = 4.1
n = 2
Call Dll2(mya(0), myb(0), n)
aa = myb(1)
End Sub
module testdll
IMPLICIT NONE
contains
subroutine Dll2(a,b,n)
! Expose subroutine Dll2 to users of this DLL
!DEC$ ATTRIBUTES :: Dll2
!DEC$ ATTRIBUTES DLLEXPORT,ALIAS: "Dll2":: Dll2
integer n
real a(n)
real b(n)
b(1)=a(1)
b(2)=a(2)
end subroutine Dll2
end module
QQ截图20140602133056.gif (34.6 KB, 下载次数: 379)
葫芦055 发表于 2015-12-15 00:07
楼主好,我跟你遇到了同样的问题,并且复制的代码也是运行不了
葫芦055 发表于 2015-12-15 00:07
复制了你的代码
葫芦055 发表于 2015-12-15 00:10
vb.net也不行
subroutine suba(a,b,c)
!DEC$ ATTRIBUTES stdcall,DLLEXPORT ::suba
!DEC$ ATTRIBUTES ALIAS:"suba"::suba
!DEC$ ATTRIBUTES reference :: a,b,c
implicit none
real::a
real::b
real::c
c=a+b
end subroutine
Private Declare Sub suba Lib "D:\try_for\try_vb\c_dll\Dll1\Dll1\Debug\Dll1.dll" (ByRef a As Single, ByRef b As Single, ByRef c As Single)
Private Sub Command1_Click()
Dim a As Single
Dim b As Single
Dim c As Single
a = 1#
b = 2#
Call suba(a, b, c)
Text1.Text = c
End Sub
0.jpg (10.24 KB, 下载次数: 399)
1.jpg (9.88 KB, 下载次数: 372)
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |