Under File Management Functions:
FindFirstFile()
Under Path Functions:
PathFindFileName
PathFindOnPath()
Of course, you may have to use these functions recursively (or in a loop) to search subdirectories. Here is a code snippet from a simple find function I created:
Code:
/* calling routine */
...
/* call find on some directory */
find("C:\some\directory\to\start\from");
...
...
void find(const char *rootPath)
{
char searchTerm[strlen(rootPath)+3];
strcpy(searchTerm, rootPath);
strcat(searchTerm, "\*");
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(searchTerm, &fd);
if(hFind == INVALID_HANDLE_VALUE)
return;
do
{
/* if its a subdirectory, call find again */
if(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
strcmp(fd.cFileName , ".")!=0 && strcmp(fd.cFileName , "..")!=0)
{
char subPath[strlen(rootPath) + strlen(fd.cFileName) + 2];
strcpy(subPath, rootPath);
strcat(subPath, "\");
strcat(subPath, fd.cFileName);
find(subPath);
}
else
{
/* do some other stuff its a file */
}
}
while(FindNextFile(hFind, &fd));
FindClose(hFind);
}