FindFirstFile()

This is a discussion on FindFirstFile() within the Windows Programming forums, part of the Platform Specific Boards category; What would be the first parameter to this function if I want to find the first file in the directory ...

GetModuleFileName will get the complete path and filename to the current module. PathRemoveFileSpec will remove the filename and last trailing backslash. Finally we use PathIsRoot to check if it is a root directory. If it is, we must add "\\*" before passing the path to FindFirstFile.

Unresolved external symbol errors typically mean that you have to link with the correct library. Down the bottom of the documentation page for a Windows function is the library you need to link to. In this case it is shlwapi.lib. In MSVC, you can link to a library using a pragma (usually placed just below the includes):

You need to pass a search mask to FindFirstFile(), not just a directory. If you want all files you need to say *.*. FindFirstFile() returns the first file in the directory, you are discarding it, (although it is usually . and therefore doesn't matter).

Look at the examples in my tutorial starting here. They are C++ but if you change the headers and cout's to printf's they should work.