cyberfan's blog

正其谊不谋其利,明其道不计其功

  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  15 随笔 :: 489 文章 :: 44 评论 :: 0 Trackbacks
Forms,
   Unit1 in ‘Unit1.pas‘ {Form1};

  {$R *.RES}

  begin
   Application.Initialize;
   Application.CreateForm(TForm1, Form1);
   Application.Run;
  end.

  {---------- 调用者单元Unit1.PAS ----------}

  unit Unit1;

  interface

  uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
   StdCtrls, Db, ADODB;

  type
   TForm1 = class(TForm)
   Button1: TButton; { 按此按钮进行调用 }
   ADOConnection1: TADOConnection; { 本地数据库连接,将传递给 DLL }
   procedure Button1Click(Sender: TObject);{ 调用 DLL}
   private
   public
   end;

  var
   Form1: TForm1;

  implementation

  {$R *.DFM}

  { 外部声明必须和 DLL中的参数列表一致,否则会运行时错误 }
  procedure DoTest(H: THandle; { 传递句柄 }
   AConn: TADOConnection; { 传递数据库连接 }
   S: string; { 传递文本信息 }
   N: Integer); { 传递数值信息 }
   cdecl; { 指定调用协议 }
   external ‘Project2.dll‘;{ 指定过程来源 }

  { 调用过程 }
  procedure TForm1.Button1Click(Sender: TObject);
  begin
   DoTest(Application.Handle,
   ADOConnection1,
   ‘Call OK‘,
   256);
  end;

  end.
posted on 2005-08-12 15:59 cyberfan 阅读(179) 评论(0)  编辑 收藏 引用 所属分类: delphi
只有注册用户登录后才能发表评论。