如果是在delphi的程序内使用是可以的,
可以试试下面这个例子:
//主程序内容
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
procedure test(sender:tbutton);external 'e:/project1.dll';
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(inttostr(integer(button1)));
test(button1);
end;
end.
//dll内容
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
procedure test(sender:tbutton);
implementation
{$R *.DFM}
procedure test(sender:tbutton);
begin
showmessage(inttostr(integer(sender)));
(sender as tbutton).caption:='i am button!';
if (sender is tbutton) then
showmessage('button test');
end;
end.