- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


3199:Using FindFirst and the WIN_32_FIND_DATA structure

KEYWORDS: FindFirst, FindNect, FindClose, TSearchRec AREA: Application Interop


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>

        TI



* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile