
Technical Information Database
TI1512D.txt Using FindFirst and the WIN_32_FIND_DATA structure
Category :Application Interop
Platform :All
Product :Delphi All
Description:
Here is how to access the WIN_32_FIND_DATA structure of a
TSearchRec using the FindFirst(), FindNext(), and FindClose()
functions.
In this example, we will show how to display both the long
and short filename for each file found. Notice in the example that
the unit name is fully qualified for the FindFirst(), FindNext(),
and FindClose() functions, since there is more than one
implementation for these function names. The implementations
that we are calling are the Delphi wrapper functions to the
WinApi functons.
var
sr : TSearchRec;
R : integer;
begin
R := Sysutils.FindFirst('C:\*.*', faAnyFile, sr);
while R = 0 do
begin
Memo1.Lines.Add(sr.FindData.cFileName);
if sr.FindData.cAlternateFileName <> '' then
Memo1.Lines.Add(sr.FindData.cAlternateFileName) else
Memo1.Lines.Add(sr.FindData.cFileName);
R := Sysutils.FindNext(sr);
end;
Sysutils.FindClose(sr);
end;
<end of ti>
Reference:
7/16/98 4:34:14 PM
|