I'm following the case #1 to let TC know that the directory exists but empty:Return INVALID_HANDLE_VALUE (==-1, not zero!) if an error occurs...
When an error occurs, call SetLastError() to set the reason of the error. Total Commander checks for the following two errors:
1. ERROR_NO_MORE_FILES: The directory exists, but it's empty (Totalcmd can open it, e.g. to copy files to it)
2. Any other error: The directory does not exist, and Total Commander will not try to open it.
Code: Select all
function FsFindFirstW(Path: PWideChar; var FindData: tWIN32FINDDATAW): PDirectoryContents; stdcall;
...
begin
...
SetLastError(ERROR_NO_MORE_FILES);
Result := Pointer(INVALID_HANDLE_VALUE);
end;