小说网 找小说 无限小说 烟雨红尘 幻想小说 酷文学 深夜书屋

delphi dll实例代码 持续影响

DLL

代码:

 

library project2;

uses
  SysUtils,
  Classes,
  Unit1 in 'Unit1.pas' {Form1};

function TestDll(i:string):string;stdcall;

begin

Result:=i;

end;

exports

TestDll;

begin

end.

 

 

 

窗体文件代码:

 

 

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics,

Controls, Forms, Dialogs, StdCtrls;

type

TForm1 = class(TForm)

Edit1: TEdit;

Button1: TButton;
    Edit2: TEdit;
    Button2: TButton;

procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.DFM}

//本行以下代码为我们真正动手写的代码

function TestDll(i:string):string;stdcall;

external 'Project2.dll';

procedure TForm1.Button1Click(Sender: TObject);

begin

Edit1.Text:=TestDll(edit2.text);

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
end;

end.

posted on 2009-04-27 12:39  王峰炬  阅读(115)  评论(0编辑  收藏  举报

导航