procedure TForm1.Button1Click(Sender: TObject);var SHEmptyRecycleBin:TSHEmptyRecycleBin; LibHandle:THandle;begin LibHandle := LoadLibrary(PChar(’Shell32.dll’)) ; if LibHandle <> 0 then begin @SHEmptyRecycleBin := GetProcAddress(LibHandle, ’SHEmptyRecycleBinA’); end else begin MessageDlg(’Failed to load Shell32.dll.’, mtError, [mbOK], 0); Exit ; end ; if @SHEmptyRecycleBin <> nil then begin SHEmptyRecycleBin(Application.Handle,’’,SHERB_NOCONFIRMATION orSHERB_NOPROGRESSUI or SHERB_NOSOUND) ; end; FreeLibrary(LibHandle); @SHEmptyRecycleBin := nil ;end; 程序代码如下:unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject);private { Private declarations }public { Public declarations }end;var Form1: TForm1; implementationconst SHERB_NOCONFIRMATION = $00000001 ; SHERB_NOPROGRESSUI = $00000002 ; SHERB_NOSOUND = $00000004 ;type TSHEmptyRecycleBin=function(Wnd:HWND;LPCTSTR
Char;DWORD:Word):Integer;stdcall; {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);var SHEmptyRecycleBin:TSHEmptyRecycleBin; LibHandle:THandle;begin LibHandle := LoadLibrary(PChar(’Shell32.dll’)) ; if LibHandle <> 0 then begin @SHEmptyRecycleBin := GetProcAddress(LibHandle, ’SHEmptyRecycleBinA’); end else begin MessageDlg(’Failed to load Shell32.dll.’, mtError, [mbOK], 0); Exit ; end ; if @SHEmptyRecycleBin <> nil then begin SHEmptyRecycleBin(Application.Handle,’’,SHERB_NOCONFIRMATION or SHERB_NOPROGRESSUI or SHERB_NOSOUND) ; end; FreeLibrary(LibHandle); @SHEmptyRecycleBin := nil ; end;end.