FindFirst wraps the Win32 FindFirstFile API function, and the Unicode version of this function can search for paths up to 32,767 characters long if you add \\?\ To the path you are passing, for example \\?\C:\Folder\Folder\* .
Since Delphi 2009 and new call Unicode functions for you, you can just use FindFirst and collaborate there. For Delphi 2007 and earlier (ANSI versions) you need to directly call FindFirstFile/FindNextFile/FindClose from Windows.pas . For more information, check File Name in the platform SDK section.
Note that using \\?\ Disables the various bits of the path processing, so make sure that this is the full path without any ".". or '..'. You can use the same trick to open file streams, rename or copy files with longer paths.
The Explorer does not support this, so you still need to limit them to no more than MAX_PATH characters for things like SHFileOperation (to be deleted to the trash) or ShellExecute . In many cases, you can work around the problem by going to DOS 8.3 names instead of long ones. FindFirst TSearchRec does not expose short names, but the FindFirstFile TWin32FindData structure works like cAlternateFileName .
Zoë peterson
source share