S
Sewim
Unregistered / Unconfirmed
GUEST, unregistred user!
我编写出的DLL,动态调用时,释放的时候出错,请大家帮忙看看,谢谢
这是调用部分:
procedure TForm1.Button1Click(Sender: TObject);
type
tGetmac = function: string;
var
Getmac: tGetmac;
LibHandle: tHandle;
begin
try
LibHandle := LoadLibrary('GetSystemIDM.dll');
if LibHandle = HINSTANCE_ERROR then exit;
@Getmac := GetProcAddress(LibHandle, 'Getmac');
if @Getmac <> nil then
showmessage(Getmac);
finally
FreeLibrary(LibHandle);
end;
end;
这是DLL源代码:
library GetSystemIDM;
uses
SysUtils,
Classes,
StrUtils,
nb30, windows;
{$R *.res}
function Getmac: string;
begin
Getmac := 'ok';
end;
exports
Getmac ;
begin
end.
这是调用部分:
procedure TForm1.Button1Click(Sender: TObject);
type
tGetmac = function: string;
var
Getmac: tGetmac;
LibHandle: tHandle;
begin
try
LibHandle := LoadLibrary('GetSystemIDM.dll');
if LibHandle = HINSTANCE_ERROR then exit;
@Getmac := GetProcAddress(LibHandle, 'Getmac');
if @Getmac <> nil then
showmessage(Getmac);
finally
FreeLibrary(LibHandle);
end;
end;
这是DLL源代码:
library GetSystemIDM;
uses
SysUtils,
Classes,
StrUtils,
nb30, windows;
{$R *.res}
function Getmac: string;
begin
Getmac := 'ok';
end;
exports
Getmac ;
begin
end.