//Dll工程
library Static_function;
uses
SysUtils,
Classes,
windows,
winprocs,wintypes,
Function_Unit in 'Function_Unit.pas';
{$R *.res}
exports
Getregstr,
Setregstr,
Systemconvert,
Atext;
procedure Dllentrypoint(dw:dword);
begin
case dw of
DLL_PROCESS_ATTACH:Init;
DLL_PROCESS_DETACH :
begin
Desfree;
end;
end;
end;
begin
DllProc:=@dllentrypoint;
Dllentrypoint(DLL_PROCESS_ATTACH );
end.
////dll工程里的一个单元
//一个函数,其实还有黑多。。。
function Atext(text:string):string;
var i:integer;
str:string;
resstr:string;
begin
str:=text;
while length(str)>0 do
begin
i:=pos('''',str);
if i>0 then
begin
resstr:=resstr+ COPY(str,1,i-1)+'''''';
Delete(str,1,i);
end
else
begin
resstr:=resstr+str;
Delete(str,1,length(str));
end;
end;
result:=resstr;
end;
////////////////住程序的一个单元
public
getext:function (text:string):string;stdcall;
{ getconntext:function():widestring;stdcall;
Setconntext:function (context:widestring):boolean;stdcall;
Convert:function(str:string;oldsystem:integer):string;stdcall;
function initial(hd:THandle):boolean;//初始化}
.....//动态加载
@getext:=GetProcAddress(hand,'Atext');
////主程序的调用
showmessage(func.getext('www'));