<----------SNIP........
WIN32_FIND_DATA wfd, dfd;
#define MAX_PATHSIZE 1000
#define MAX_NO_SUBDIRS 50
#define MAX_DIRNAME_SIZE 500
char directories[MAX_NO_SUBDIRS][MAX_DIRNAME_SIZE];
..
...
....
.....
void find_directories(int *nodirs)
// Locate any subdirectories under the current directory.
// We use FindFirstFile and FindNextFile testing the dwFileAttributes flag
// of the WIN32_FIND_DATA struct and store the directory names.
{ HANDLE dhdl = FindFirstFile ("*.*",&dfd);
int stop = FALSE, i = *nodirs;
if (dhdl != INVALID_HANDLE_VALUE)
if (dfd.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
{ if (strcmp(dfd.cFileName,".") && strcmp(dfd.cFileName,".."))
{ //Don't load the link directories.
strcpy(directories[i++],dfd.cFileName);
}
}
else
stop = TRUE;
while (!stop)
{ if (!FindNextFile(dhdl, &dfd))
{ if (GetLastError() != ERROR_NO_MORE_FILES)
{ printf("Doh!...\n");
}
stop = TRUE;
}
else if (dfd.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
{ if (strcmp(dfd.cFileName,".") && strcmp(dfd.cFileName,".."))
{ //Don't load the link directories.
strcpy(directories[i++],dfd.cFileName);
}
}
}
*nodirs = i;
}
<--------- END SNIP...............