试试这样:
procedure TForm1.OkBtnClick(Sender: TObject);
var
hDLL : THandle;
aName : array[0..10] of char;
FoundDLL : Boolean;
begin
if EditDLLName.Text = ′′ then
begin
MessageDlg(′You must first enter the name of a DLL to
unload!′,mtInformation,[mbOk],0);
exit;
end;
StrPCopy(aName, EditDLLName.Text);
FoundDLL := false;
repeat
hDLL := GetModuleHandle(aName);
if hDLL = 0 then
break;
FoundDLL := true;
FreeLibrary(hDLL);
until false;
if FoundDLL then
MessageDlg(′Success!′,mtInformation,[mbOk],0)
else
MessageDlg(′DLL not found!′,mtInformation,[mbOk],0);
EditDLLName.Text := ′′;
end;