1.联合使用LoadLibrary和GetProcAddress即可达到动态调用DLL的效果,例子:
Var
SHEmptyRecycleBin : TSHEmptyRecycleBin ;
LibHandle : THandle ;
begin
LibHandle:=LoadLibrary(PChar('Shell32.dll')) ;
If LibHandle<>0 then
@SHEmptyRecycleBin:=GetProcAddress(LibHandle, 'SHEmptyRecycleBinA')
Else Begin
MessageDlg('Failed to load Shell32.dll.', mtError, [mbOK], 0);
Exit ;
End ;
If @SHEmptyRecycleBin <> nil then
SHEmptyRecycleBin(Application.Handle ,
'' ,
SHERB_NOCONFIRMATION or
SHERB_NOPROGRESSUI or
SHERB_NOSOUND ) ;
FreeLibrary(LibHandle);
@SHEmptyRecycleBin := nil ;
End;