2,507
社区成员
发帖
与我相关
我的任务
分享
library SerReger;
uses
ShareMem, //这个uses在你使用了这个.dll的所有项目的所有文件(包括.dpr)的uses第一句出现, 以及.dll工程所有文件中uses第一句出现
SysUtils,
Classes,
UCom in 'UCom.pas';
function Test2(tx:string):string;stdcall;export;
begin
Result:=tx+'b';
end;
{$R *.res}
exports
Test2;
begin
end.
function TfrmSysControl.test(Key:string):string;
var
ReStrx:function(Key:string):string;stdcall; //stdcall非常重要
DllHandle:hmodule;
DllName:pchar;
begin
DllName :=pchar(strPath+'SerReger.dll');
DllHandle:=LoadLibrary(dllName);
if DllHandle >0 then
try
@ReStrx:=GetProcAddress(DllHandle,'Test2');
if @ReStrx <>nil then
Result := ReStrx(Key);
finally
FreeLibrary(DllHandle);
end
else
ShowMessage('dll没有找到');
end;