• --:)欢迎访问锋网源码(:--
  • 首页
  • RSS订阅
  • 常用软件
  • 网页模板
  • 网站运作
  • 锋网学院
  • 时代互联
  • 中国红网
  • 中资源!
  • 繁體中文

  • 学院首页
  • 新闻资讯
  • 网站运营
  • 网站开发
  • 美工设计
  • 数据库类
  • 服务器类
  • 网络应用
  • 操作系统
  • 软件教学
编程开发   认证考试   网络安全   文章搜索: 高级搜索
会员登录/控制面版 您的位置: 学院首页 >> 编程开发 >> Delphi >> 文章内容
 

精彩推荐

 
 

本类推荐文章

 
 

本类阅读排行

  • 用Delphi编写DelTree程序
  • 远程控制篇:模拟按键
  • DELPHI中动态调用dll
  • 远程控制篇:通过IP地址得到..
  • 在delphi把字符串分割成一维..
  • 直接访问WebBrowser控件中的..
  • dbgrideh如何实现点击标题排..
  • INI文件的读写
  • 远程控制篇:服务端程序的隐..
  • Delphi字符串函数大全
  • 用Delphi制作中国式报表
  • 用DEPHI为应用软件建立注册机..
  • 一个四舍五入函数
  • 怎样让程序延时
  • 在delphi字符中包括单引号('..
  • 创建Borland风格的漂浮式窗口..
  • 压缩图像文件并转换成BMP格式..
  • fileStream
  • 从当前的浏览器取得当前URL
  • delphi多线程程序示例(与.ne..
 
 

DELPHI中动态调用dll

  • 日期:2007-10-21     人气:     出处:     作者:
  • 字体大小:
  • 小
  • 中
  • 大

 

显式例子:

 

unit Main;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, DBTables, DBCtrls;

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    Edit1: TEdit;

    Edit2: TEdit;

    Image1: TImage;

    DataSource1: TDataSource;

    Table1: TTable;

    Table1SpeciesNo: TFloatField;

    Table1Category: TStringField;

    Table1Common_Name: TStringField;

    Table1SpeciesName: TStringField;

    Table1Lengthcm: TFloatField;

    Table1Length_In: TFloatField;

    Table1Notes: TMemoField;

    Table1Graphic: TGraphicField;

    DBGrid1: TDBGrid;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

//  function GetInteger(I:Integer): Integer;stdcall;external 'DLLOne.dll';

//  function GetDouble(F:Double): Double;stdcall;external 'DLLOne.dll';

 

  TGetDouble = function (F:Double): Double; stdcall;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.dfm}

 

procedure TForm1.Button1Click(Sender: TObject);

var D: Double;

    DLLHandle: THandle;

    Func: TGetDouble;

begin

  Image1.Picture.Assign(Table1Graphic);

  Table1Graphic.Assign(Image1.Picture);

  Exit;

  DLLHandle := LoadLibrary('DLLOne.dll');

  try

  @Func := GetProcAddress(DLLHandle, 'GetDouble');

 

  //Edit1.Text := IntToStr(GetInteger(2));

  //D := GetDouble(2.2);

  if Assigned(@Func) then

  begin

    D := Func(2.2);

    Edit2.Text := FloatToStr(D);

  end;

 

  finally

  FreeLibrary(DLLHandle);

  end;

end;

 

end.

 

隐式例子:

 

library DLLOne;

 

uses

  SysUtils,

  Classes;

 

{$R *.res}

 

  function GetDoubleExt(F:Double): Double;stdcall;external 'DLLTwo.dll';

  function GetInt(I:Integer): Integer;stdcall;external 'DLLTwo.dll';

 

  function GetInteger(I:Integer): Integer;stdcall;

  begin

    Result := GetInt(I);

  end;

 

  function GetDouble(D:Double): Double;stdcall;

  begin

    Result := GetDoubleExt(D);

  end;

 

exports

  GetInteger,

  GetDouble;

 

begin

end.

 

 

 

 

 

 

 

library DLLTwo;

 

{ 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 GetDoubleExt(D:Double):Double ;stdcall;

  begin

    Result := D;

  end;

  function GetInt(I:Integer): Integer;stdcall;

  begin

    Result := I;

  end;

 

exports

  GetDoubleExt,

  GetInt;

 

begin

end.

相关文章
  • QQ帮你突破网吧硬盘访问限制
  • 局域网内盗用IP的安全问题
  • 邮件安全攻略:只要糖衣不要炮弹
  • 手机病毒的分类及其防范措施
  • 如何防止黒客远程盗取QQ密码
  • 始料未及,谁在控制电脑重新启动
  • 网络常见木马的手工清除方法
  • 魔高一尺 道高一丈
  • 防火墙日志记录让蠕虫病毒无处可逃
  • 提防他人动用电脑另有妙招
相关软件

  • 网友评论:
  • 查看所有评论
  • 我要发表评论
 

关于本站 | 广告联系 | 版权声明 | 网站地图 | 加入收藏 | 帮助中心 |

Copyright © 2006-2007 fwvv.net  程序支持:木翼  皖ICP备06004916号  

感谢:点击网络 联网科技 天盈信息 企联网 中国E速网  提供服务器及带宽赞助