此
此ID转让
Unregistered / Unconfirmed
GUEST, unregistred user!
谢谢解答啊:代码如下。
unit Unit1;
interface
uses
Windows, 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;
implementation
{$R *.dfm}
const
SHERB_NOCONFIRMATION = $00000001 ;
SHERB_NOPROGRESSUI = $00000002 ;
SHERB_NOSOUND = $00000004 ;
type
TSHEmptyRecycleBin=function(Wnd:HWND;LPCTSTRChar;DWORD:
Word):Integer;stdcall;
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
Application.MessageBox('载入 shell32.Dll 失败。', '错误', MB_OK +
MB_ICONSTOP);
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.
在Delphi7中总是提示有非法字符,2006中编译能通过。
unit Unit1;
interface
uses
Windows, 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;
implementation
{$R *.dfm}
const
SHERB_NOCONFIRMATION = $00000001 ;
SHERB_NOPROGRESSUI = $00000002 ;
SHERB_NOSOUND = $00000004 ;
type
TSHEmptyRecycleBin=function(Wnd:HWND;LPCTSTRChar;DWORD:
Word):Integer;stdcall;
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
Application.MessageBox('载入 shell32.Dll 失败。', '错误', MB_OK +
MB_ICONSTOP);
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.
在Delphi7中总是提示有非法字符,2006中编译能通过。