简单调用系统函数Shell32报错? ( 积分: 50 )

  • 主题发起人 主题发起人 cys805
  • 开始时间 开始时间
C

cys805

Unregistered / Unconfirmed
GUEST, unregistred user!
实现清空回收站,代码如下:<br>unit Unit1;<br>interface<br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br>private<br> { Private declarations }<br>public<br> { Public declarations }<br>end;<br>var<br> Form1: TForm1;<br> implementation<br>const<br> SHERB_NOCONFIRMATION = $00000001 ;<br> SHERB_NOPROGRESSUI = $00000002 ;<br> SHERB_NOSOUND = $00000004 ;<br>type<br> TSHEmptyRecycleBin=function(Wnd:HWND;LPCTSTR:PChar;DWORD:Word):Integer;stdcall;<br> {$R *.dfm}<br> procedure TForm1.Button1Click(Sender: TObject);<br>var<br> SHEmptyRecycleBin:TSHEmptyRecycleBin;<br> LibHandle:THandle;<br>begin<br> LibHandle := LoadLibrary(PChar('Shell32.dll')) ;<br> if LibHandle &lt;&gt; 0 then<br> begin<br>  @SHEmptyRecycleBin := GetProcAddress(LibHandle, 'SHEmptyRecycleBinA');<br> end<br> else<br> begin<br>  MessageDlg('Failed to load Shell32.dll.', mtError, [mbOK], 0);<br>  Exit ;<br> end ;<br> if @SHEmptyRecycleBin &lt;&gt; nil then<br> begin<br>  SHEmptyRecycleBin(Application.Handle,'',SHERB_NOCONFIRMATION or SHERB_NOPROGRESSUI or SHERB_NOSOUND) ;<br> end;<br> FreeLibrary(LibHandle);<br> @SHEmptyRecycleBin := nil ;<br>end;<br>end. <br>报错:Illegal character in input file: ' ' ($A1A1)常量定义错误。怎么改?为什么会有错误?
 
实现清空回收站,代码如下:<br>unit Unit1;<br>interface<br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br>private<br> { Private declarations }<br>public<br> { Public declarations }<br>end;<br>var<br> Form1: TForm1;<br> implementation<br>const<br> SHERB_NOCONFIRMATION = $00000001 ;<br> SHERB_NOPROGRESSUI = $00000002 ;<br> SHERB_NOSOUND = $00000004 ;<br>type<br> TSHEmptyRecycleBin=function(Wnd:HWND;LPCTSTR:PChar;DWORD:Word):Integer;stdcall;<br> {$R *.dfm}<br> procedure TForm1.Button1Click(Sender: TObject);<br>var<br> SHEmptyRecycleBin:TSHEmptyRecycleBin;<br> LibHandle:THandle;<br>begin<br> LibHandle := LoadLibrary(PChar('Shell32.dll')) ;<br> if LibHandle &lt;&gt; 0 then<br> begin<br>  @SHEmptyRecycleBin := GetProcAddress(LibHandle, 'SHEmptyRecycleBinA');<br> end<br> else<br> begin<br>  MessageDlg('Failed to load Shell32.dll.', mtError, [mbOK], 0);<br>  Exit ;<br> end ;<br> if @SHEmptyRecycleBin &lt;&gt; nil then<br> begin<br>  SHEmptyRecycleBin(Application.Handle,'',SHERB_NOCONFIRMATION or SHERB_NOPROGRESSUI or SHERB_NOSOUND) ;<br> end;<br> FreeLibrary(LibHandle);<br> @SHEmptyRecycleBin := nil ;<br>end;<br>end. <br>报错:Illegal character in input file: ' ' ($A1A1)常量定义错误。怎么改?为什么会有错误?
 
这是因为你在程序中使用了非法字符,,你这段代码可能是从网上直接考下来的,先粘贴到<br>记事本在考到编辑器中就可以了;或者是你在输入代码时输入了中文的字符
 
收到!。多谢。我搞定了。!
 
接受答案了.
 
后退
顶部