- 积分
- 47
- 注册时间
- 2003-9-12
- 仿真币
-
- 最后登录
- 1970-1-1
|
发表于 2004-4-29 22:09:06
|
显示全部楼层
来自 美国
回复: 【求助】如何在VF中调用动态链接库
调用方式参考如下示例,testsub.dll中有函数SUBA,接口用rtn_suba(a,b)别名来调用SUBA函数。
-
- ! Sample Fortran program that finds a dll library and calls
- ! a routine in it.
- use kernel32
- ! Declare an interface block to the routine to be called.
- interface
- subroutine rtn_suba(a, b)
- real*8 a, b
- end subroutine
- end interface
-
- real *8 arg1, arg2
- integer p
- pointer (q,rtn_suba)
- logical status
-
- ! First, locate the dll and load it into memory
- p = loadlibrary("testsub.dll"C)
- if (p == 0) then
- type *, "Error occurred opening testsub.dll"
- type *, "Program aborting"
- goto 1000
- endif
-
- ! Set up a pointer to the routine of interest
- q = getprocaddress(p, "SUBA"C)
- if (q == 0) then
- type *, "Error occurred finding SUBA in testsub.dll"
- type *, "Program aborting"
- goto 1000
- endif
-
- ! Now, the routine can simply be called
- call rtn_suba(arg1, arg2)
- write(*,*)arg1, arg2
- status = freelibrary(p)
- type *, "freelibrary status was: ", status
-
- 1000 continue
- end
-
复制代码
对NIX我不熟,不知道.a与.DLL的区别。 |
|