DLL 的静态调用实例代码
来源:互联网 发布:淘宝网有卖大的方巾 编辑:程序博客网 时间:2024/05/09 13:30
自己写了一MinMax.dll文件 里面定义了2个函数Min、Max
在测试中使用了静态调用的方法
完整代码如下:
----------------------------------------
unit unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Buttons;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses unit3;
function min(x,y:integer):integer;stdcall; external 'Minmax.dll' name 'Min';
function max(x,y:integer):integer;stdcall; external 'Minmax.dll' name 'Max';
procedure TForm1.Button1Click(Sender: TObject);
var
x,y,mi,ma:integer;
begin
if (edit1.Text ='') or (edit2.Text ='') then
showmessage('X或Y值为空!')
else
begin
x:=strtoint(trim(edit1.Text) );
y:=strtoint(trim(edit2.Text) );
mi:=min(x,y);
ma:=max(x,y);
Memo1.Lines.Clear ;
Memo1.Lines.Add ('最小值:'+inttostr(mi));
Memo1.Lines.Add ('最大值:'+inttostr(ma));
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Form3:=TForm3.Create(Form1);
Form3.ShowModal ;
end;
end.
-----------------------------------
MinMax.dll文件源码如下:
library Minmax;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes;
{$R *.res}
function Min(x,y:integer):integer;stdcall ;
begin
if (x<y) then
Min:=x
else
Min:=y;
end;
function Max(x,y:integer):integer;stdcall ;
begin
if (x>y) then
Max:=x
else
Max:=y;
end;
exports Min,Max;
begin
end.
------------------------------
2009-11-04
- DLL 的静态调用实例代码
- 静态调用的dll的一个实例
- DLL的静态调用
- dll的静态调用和动态调用使用说明及简单实例
- Unity3D教程:静态调用C#的dll
- C++类的DLL,C++静态调用。
- dll静态调用
- C++静态调用DLL
- MFC静态调用dll
- dll 调用,动态,静态
- vc调用matlab生成的dll实例
- c++调用c#的dll + 实例
- php调用dll的实例操作动画
- 动态调用、静态调用dll
- dll静态调用-修改lib中dll名称就能改变调用dll的名称
- VS 2015 DLL的创建、静态调用和动态调用
- C++生成dll和调用dll的方法实例
- C++生成dll和调用dll的方法实例
- PI小结之四,IR01--SWCV
- 关于SWT与AWT/Swing的关系
- 什么是java序列化,如何实现java序列化
- PS完美快速的去除照片中的水印
- wml页面跳转的几种方式
- DLL 的静态调用实例代码
- 利用IIS建立FTP遇到的问题
- 使用cout格式化输出字符串 (转)
- 一个新发现
- 多线程互斥
- td里面有一个text和img,怎么对齐啊?
- 声卡虚拟仪器
- 民间53个不传之密 ,看了不后悔
- 互联网用户类型的一点思考