OK, I understand FindClose is required for succeeded FindFirst/FindNext.
But what about if FindFirst <> 0 ?
Some code calls it, some other doesn't.
I've read somewhere that FindClose might hang the system but that was for
Win95/NT and I don't really need compatibility for anything older than Win
XP.
So should I call FindClose or not if FindFirst returns 0?
Just for the record - I am talking about Delphi version of FindClose that
takes TSearchRec as input, not the WinAPI version that wants handle as
input.
From Findfirst source:
if F.FindHandle <> INVALID_HANDLE_VALUE then
begin
Result := FindMatchingFile(F);
if Result <> 0 then FindClose(F);
end
else
Result := GetLastError;
...
From FindClose source:
if F.FindHandle <> INVALID_HANDLE_VALUE then
...
Even if you were to use FindCLose on an invalidhandle, it would
ignore it anyway.
The Delphi implementation of it stores the system handle in the search
record, so in this case, you call FindCLose in all cases to be sure when
doing the local layer function, over the API call.
In either case, calling the FindCLose will just insure proper closing
of the handle, if it happens to be valid.
Jamie