2012-08-01

【Delphi】清除資源回收筒

Form 放一個 button,然後將 unit1 內程式碼改為如下 ----

 
unit Unit1;

interface

uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;

type
    TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject) ;
    end;

var 
    Form1: TForm1;

function SHEmptyRecycleBin(Wnd:HWnd; LPCTSTR:PChar; DWORD:Word):Integer; stdcall;

const
    SHERB_NOCONFIRMATION = $00000001;
    SHERB_NOPROGRESSUI = $00000002;
    SHERB_NOSOUND = $00000004;

implementation
{$R *.DFM}

function SHEmptyRecycleBin; external 'SHELL32.DLL' name 'SHEmptyRecycleBinA';

procedure TForm1.Button1Click(Sender: TObject) ;
begin
    SHEmptyRecycleBin(self.handle,'', SHERB_NOCONFIRMATION);
end;

end.
 


沒有留言:

張貼留言