March 2000
Intermediate to advanced
576 pages
18h 13m
English
SetInOutRes Procedure
procedure SetInOutRes(Code: Integer);
The SetInOutRes procedure sets the I/O error code
to Code. Calling IOResult
returns this error code and then resets the code to
zero.
Each thread keeps its own I/O error code. Be sure to call
SetInOutRes in the context of the correct thread.
Delphi reserves error codes 100-106 for its own I/O errors. (See
IOResult for a description of these error codes.)
For all other errors, use the standard Windows error codes.
Calling SetInOutRes does not raise the runtime
error—it only stores the error code. If you want to report the
I/O error, you must do that separately. See
ErrorProc and RunError for
examples of how to do this.
// Implement Seek on a text file.
procedure TextSeek(var F: TextFile; Position: Integer);
var
Handle: Integer;
NewPosition: DWORD;
begin
// A TextFile is actually a record whose first value is a handle.
Handle := PInteger(@F)^;
NewPosition := SetFilePointer(Handle, Position, nil, File_Begin);
if NewPosition = $FFFFFFFF then
begin
SetInOutRes(GetLastError);
ReportError(0); // zero means I/O error
end;
end;| ErrorProc Variable, File Keyword, IOResult Function, RunError Procedure, TextFile Type |
Read now
Unlock full access