奇怪,下面的代码在Delphi7中不能调试通过,而在2006中却可以。代码很简单。怎么回事? ( 积分: 50 )

  • 主题发起人 主题发起人 此ID转让
  • 开始时间 开始时间

此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;LPCTSTR:PChar;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中编译能通过。
 
呵呵,空格引起的。以下是整理后的代码,在7下编译通过

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

type
TSHEmptyRecycleBin=function(Wnd:HWND;LPCTSTR:PChar;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.
 
中文空格 -_-!!!
2006里支持Unicode
Delphi7里不支持
 
啊哦~~~谢谢 '啊啊啊啊啊' 的确没注意到这个问题。
也谢谢楼上的兄台。
 
后退
顶部