unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
pathstr:PChar;
fddata:TWin32FindData;
hd:THANDLE;
br:Bool;
EC:DWORD=0;
procedure TForm1.Button1Click(Sender: TObject);
begin
pathstr:='c:\windows\system32\*.dll';
hd:=FindFirstFile(pathstr,fddata);
while ( (hd<>INVALID_HANDLE_VALUE) and (EC<>ERROR_NO_MORE_FILES) ) do
begin
if ( fddata.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY )then
//if ((string(fddata.cFileName)<>'.') and (string(fddata.cFileName)<>'..')) then begin strcat() ...end;
begin
//never used
br:=FindNextFile(hd,fddata);
EC:=GetLastError();
end
else
begin
Listbox1.Items.Add(string(fddata.cFileName));
br:=FindNextFile(hd,fddata);
EC:=GetLastError();
end;
end;
windows.FindClose(hd);
end;
end.
-------------------------------------------------------------------------------------------------
运行如图:

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.050877809524536 seconds