library DLLA;
uses
SysUtils,
Classes,
DLLF in 'DLLF.pas' {DLLFrm};
exports
ShowF1;
begin
end./////////////////////////////
unit DLLF;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TDLLFrm = class(TForm)
procedure ShowF1(AHandle:THandle):String;StdCall;
end;
implementation
procedure ShowF1(AHandle:THandle):String;StdCall;
var
DLLF: TDLLFrm;
begin
Application.Handle:=AHandle;
DLLF:=TDLLFrm.Create(Application);
try
DLLF.ShowModal;
finally
DLLF.Free;
end;
end;end.
uses
SysUtils,
Classes,
DLLF in 'DLLF.pas' {DLLFrm};
exports
ShowF1;
begin
end./////////////////////////////
unit DLLF;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TDLLFrm = class(TForm)
procedure ShowF1(AHandle:THandle):String;StdCall;
end;
implementation
procedure ShowF1(AHandle:THandle):String;StdCall;
var
DLLF: TDLLFrm;
begin
Application.Handle:=AHandle;
DLLF:=TDLLFrm.Create(Application);
try
DLLF.ShowModal;
finally
DLLF.Free;
end;
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TDLLFrm = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
dllFrm:tform;
function ShowF1(AHandle:THandle):String;StdCall;//位置错了
implementation
function ShowF1(AHandle:THandle):String;stdcall;//改
var
DLLF: TDLLFrm;
begin
//Application.Handle:=AHandle;
DLLF:=TDLLFrm.Create(Application);
try
if DLLF.ShowModal=mrok then//改
result:='dllopen';//改
finally
DLLF.Free;
end;
end;
//Application.Handle:=AHandle;
DLLF:=TDLLFrm.Create(Application);
调用dll不难,声明一下就可调用。
搜索一下这样的贴子不少。(这一贴就行)
http://www.csdn.net/expert/topic/629/629804.xml?temp=.5295374先将生成的dll文件拷贝到你的程序目录里。
程序
private
{ Private declarations }
public
{ Public declarations }
end;
function ShowF1(AHandle:THandle):string;stdcall;external 'project1.dll';//声明
var
Form1: TForm1;
implementation{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
if ShowF1(form1.handle)='dllopen' then
showmessage('dll access');//调用
end;
生命一个aaadll:THandle;
然后LoaddLibrary
以上的这个DLL如果 GetProcAddress的话前面是不是应该生命一个
Test:function;String;
然后
@Test:=GetProcAddress(aaadll,'ShowF1');
接下来怎么办?怎么调用ShowF1那个函数以便显示出From??
~非常感谢你的回答,待会我马上给你结帐
http://www.5xsoft.com/data/200112/1108454001.htm