Intel Fortran 调用Delphi编制的DLL

本文提供了一个IntelFortran调用Delphi编写的DLL的具体示例,展示了如何定义模块接口、使用标准模块、加载DLL以及调用DLL中的函数。此示例对于跨语言编程和集成不同编程环境下的组件具有一定的参考价值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

module link_cont
  interface
    subroutine I_FileOpenCont (ncase,ndata,lpool,xfiles)
      integer(kind=4) :: ncase
      integer(kind=4) :: ndata
      integer(kind=4) :: lpool
      character(len=40), dimension(10) :: xfiles
    endsubroutine I_FileOpenCont
  endinterface
endmodule link_cont

program s
  use link_cont
  use Kernel32
  use , intrinsic :: ISO_C_Binding !// 标准模块
  implicit none
  type(C_FUNPTR) :: C_FileOpenCont !// C 语言指向函数的指针
  procedure(I_FileOpenCont) , pointer :: FileOpenCont !// fortran 指向函数的指针
  !<-------------------------------------------------------------------------------------------------------------------------------
  integer(kind=4)                  :: add
  integer(kind=4)                  :: hwnd
  integer(kind=4)                  :: n_case
  integer(kind=4)                  :: n_data
  integer(kind=4)                  :: lpool
  character(len=40), dimension(10) :: c_files
  logical                          :: fail
  logical                          :: syslink
  !<-------------------------------------------------------------------------------------------------------------------------------
  hwnd = LoadLibrary('control.dll'//c_null_char)
  if (hwnd <= 0) then
    fail    = .true.
    syslink = .false.
    write(*,*) 'DLL Loading failure because control.dll was not found'
    read(*,*)
  else
    write(*,*) 'Succeed Contempt DLL (control.dll) Loading'
    add     = GetProcAddress(hWnd,'FILEOPENCONT'//c_null_char) !//获得地址(整数)
    C_FileOpenCont = transfer( add , C_FileOpenCont ) !//把整数的地址转换成 C 指针
    call C_F_PROCPOINTER( C_FileOpenCont , FileOpenCont ) !//把C指针转换成 fortran 指针
    call FileOpenCont(n_case,n_data,lpool,c_files)
syslink=FreeLibrary(hwnd) endif end program s

在delphi和intel fortran下实证过。

posted on 2018-09-15 21:07  向北方 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/China3S/p/9652237.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值