![]() |
Home |
|
RTTarget-32 Flag RT_CLOSE_FIND_HANDLESRTTarget-32 has a flag to work around a problem in some C/C++ run-time systems or older programs ported from DOS. The Win32 API functions to search for files are FindFirstFile, FindNextFile, and FindClose. FindFirstFile returns a handle which can be used in subsequent FindNextFile calls. This handle must be closed with FindClose to avoid a Win32 handle leak. However, under DOS, the corresponding DOS functions do not require closing such a handle. For this reason, some older programs never close find handles. RTTarget-32 allocates a Win32 handle in each FindFirstFile call and RTFiles-32 allocates a file handle in each call to RTFFindFirst (which is called by FindFirstFile). Thus, programs that do not close find handles will quickly exhaust all available Win32 and RTFiles-32 handles. To work around this problem, RTTarget-32 can be instructed to automatically close find handles once no more files are found in FindNextFile. To use this feature, call RTSetFlags(RT_CLOSE_FIND_HANDLES, 1); during the startup phase of the program. If this feature is used, programs which do close the find handle after no more files are found will receive an error from FindClose since the handle has been closed already. However, this should normally not cause any problems. You should use RT_CLOSE_FIND_HANDLES only to support software with this bug which cannot be modified. Well-behaved programs should always close find handles (either Win32 handles with FindClose or the RTFiles-32 handle with RTFFindClose, if RTFiles-32's native API is used).
|