惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

博客园 - Ja

[转]Moving Your Access 2002 Database to SQL Server 新浪Blog支持手机Wap浏览了 示例3:论坛主题搜索 AJAX是什么? [歌词]世界末日 无题 [JavaScript]给自己的网站添加简单文本日志 [HTML]标签的StyleSheet [ASP]Server.Execute 我的毕业设计(一)模型调度 怎么取得DLL文件中的函数名列表? 解决Navihelper.dll(女生宿舍)病毒的方法一则 过去的2004 Gmail invitations 硕泰克SL-67fv1支持PIII800EB吗? 再来一个Email Logo 我的Gmail邮箱 Who can invite me to Wallop?Thanks! 被SQL Server 2005郁闷了
在C++ Builder中调用FORTRAN生成的DLL
Ja · 2005-04-07 · via 博客园 - Ja

1.        Fortran中的函数定义形式

       subroutine add1[dllexport](p1,p2,p3)

       p3=p1+p2

       end subroutine add1

2.        DLL中函数名的检查

Tdump.exe检查*.dll文件,得到DLL文件中的函数名,例如:

       _ADD1@12

3.        Borland C++ Builder中调用DLL

两种方式:静态引入,动态引入,或者称为隐式连接(implicit linked),显示连接(explicit linked)

使用显示连接的方法是使用WindowsAPI(LoadLibrary函数)来载入DLL,用FreeLibrary函数来释放DLL,用GetProcAddress来取得函数的地址,再呼叫该函数,使用之后释放。使用显示连接的优点在于,你可以完全控制该DLL的载入和释放,最有效地利用系统资源。在调用失败时,程序可以继续运行,进行处理。

 隐式连接的方法是通过project/add to project Dll.LIB加入到工程文件中,这种方法需要代码少,但是占用系统资源多。

4.        显示连接的方法

首先,在C++ Builder中,如Lib.h文件中声明函数:

       void _stdcall(*Add1)(float*,float*,float*);

然后,在程序中调用DLL文件,例如Lib.DLL

HINSTANCE hInst;

hInst=LoadLibrary("TestFor1.Dll");

if(NULL==hInst) Output("Load Dll Error!");

else

{

Output("Load Dll Ok!");

(FARPROC&)Add1=GetProcAddress(hInst,"_ADD1@12");

if(Add1==NULL)

{

Output("Open Dll Function Failed!");

}

else

{

Output("Open Dll Function Ok!");

}

}

5.        调用函数的方法

例程如下:

float p1,p2,p3;

p1=1.0;

p2=2.0;

p3=0.0;

AnsiString s;

Add1(&p1,&p2,&p3);

s=FormatFloat("0.0",p3);

Output("计算结果:"+s);