Approved: Fortect
In this article, we will identify some potential causes that can cause Delphi Findfirst error codes, and then point out some ways to fix the problem.
> I need to know what error is returned if the file is not found, like
> and other errors that can occur when using findfirst and findnext functions.
> Helping with these two looks a lot like that too. Does anyone know related to any good
> examples of using these commands. Preferably things like viewing
> all files in a directory.
FindFirst to match In the FindFirstFile API function, FindNext with FindNextFile. Error
Returning the values you would expect from one of these functions (from Windows. Not):
The system cannot find the file specified.
ERROR_FILE_NOT_FOUND = 2;
The system cannot find the path specified.
ERROR_PATH_NOT_FOUND = 3;
Access denied.
ERROR_ACCESS_DENIED means 5;
Why does Delphi fileexists not work in Windows?
FileExists () Delphi takes additional action if GetFileAttributes () fails – to handle symbolic links, check for file access errors, perhaps resort to FindFirstFile () – to see if history * actually * exists or not. Hopefully FreePascal FileExists () will do something like this. It didn’t help with FileGetAttr either.
There are no more facts.
ERROR_NO_MORE_FILES 18;
= Device not ready.
ERROR_NOT_READY = 21;
Usually you only get 2 (if findfirst no
matches the mask) or even 18 (if FindNext if no more
info files are found that match the mask). 21 will most likely appear when trying to locate a floppy or CD-ROM drive that does not have a floppy disk.
Excerpt from an explanation of the form, has a list1 to support the results
, a function label1 to execute, a button2 to set up a scan,
any processing1 to call the search mask, a function button3 to display a complete scan stop
. private
private classifieds
FScanAborted: Boolean;
Approved: Fortect
Fortect is the world's most popular and effective PC repair tool. It is trusted by millions of people to keep their systems running fast, smooth, and error-free. With its simple user interface and powerful scanning engine, Fortect quickly finds and fixes a broad range of Windows problems - from system instability and security issues to memory management and performance bottlenecks.
public
public announcements
ScanDrive function (root, file mask: String; match list: TStrings): Boolean;
Funsection TForm1.ScanDrive (root, file mask: String; list of matches: TStrings): Boolean;
ScanDirectory function (path to variable: String): Boolean; Var
SRec: TSearchRec;
pathlen: integer;
ers: integer;
start label1.caption: = path;
pathlen: = length (path);
first give the files
ers: = FindFirst (path + file mask, faAnyfile, SRec);
If ers = 0 Then
try
While res = 0 Start
hitlist.Add (path + SRec.Name);
res: = FindNext (SRec);
end; final
FindClose (SRec)
end;
Application.ProcessMessages;
Result: = no or (fscanaborted Application.Terminated);
If there is no result, then exit;
second pass, directories
res: = FindFirst (path + ‘*. *’, faDirectory, SRec);
If res = 0 then
try
While (res = 0) and Result Do Begin
If ((Srec.Attr and faDirectory) implies faDirectory) and
(Srec.name [ 1] <> ‘.’)
Then start
path: = walk SRec +. name + ”;
Result: = ScanDirectory (path);
SetLength (path, path);
end;
res: means FindNext (SRec);
end;
final by findclose (srec) by end;
The End;
Start
FScanAborted: = False;
Screen.Cursor: = crSourglas;
try
Result: = ScanDirectory (root); Final
Screen.Cursor CrDefault
: = end;
The End;
What do attributes do in findfirst in Delphi?
Attributes define files to search in addition to a regular computer. If a match is found, some return value is 0, otherwise it is necessarily negative (and the result record is not actually populated). FileMask can contain the most recent path as well as a file function. A filename can be of great benefit:?
Procedure TForm1.Button2Click (Sender: TObject); Var
ch: Char;
root: String;
Start
root: = ‘C: ‘;
For ch: = ‘A’on the market before ‘Z’ Start
root [1]: = ch;
Case GetDriveType (Root pchar ())
DRIVE_FIXED, DRIVE_REMOTE:
If not ScanDrive (root, edit1.text, listbox1.items), then
Break;
The End;
The End;
end;
Peter Bowl (TeamB) 10011 … @ compuserve.com )
No email response unless specifically requested!