What the difference between FindFirstFile Win32 API function and Dir Visual Basic function?
Both functions search a directory for a file whose name matches the specified pattern, but input parameters, results and using are quite different. The Dir Visual Basic function input parameters: • pathname optional parameter with the file name pattern • attributes optional parameter with the file attribute pattern The Dir function returns a String value representing the name of file or directory that matches file name and/or file attribute patterns. If you decide to list all files in the some directory and specify the file name pattern, then you need to call the Dir function without parameters until it will return empty string. The FindFirstFile Win32 API function input parameters: • lpFileName – the same as pathname parameter of the Dir function • lpFindFileData – pointer to the buffer that receives information about the found file or subdirectory. WIN32_FIND_DATA structure should be used as buffer. The FindFirstFile function returns a Long value representing a search handle, if the
Both functions search a directory for a file whose name matches the specified pattern, but input parameters, results and using are quite different. The Dir Visual Basic function input parameters: • pathname optional parameter with the file name pattern • attributes optional parameter with the file attribute pattern The Dir function returns a String value representing the name of file or directory that matches file name and/or file attribute patterns. If you decide to list all files in the some directory and specify the file name pattern, then you need to call the Dir function without parameters until it will return empty string. The FindFirstFile Win32 API function input parameters: • lpFileName – the same as pathname parameter of the Dir function • lpFindFileData – pointer to the buffer that receives information about the found file or subdirectory. WIN32_FIND_DATA structure should be used as buffer. The FindFirstFile function returns a Long value representing a search handle, if the