Skip to content

Instantly share code, notes, and snippets.

@JubbaSmail
Created November 13, 2014 10:53
Show Gist options
  • Select an option

  • Save JubbaSmail/ebaf2f1c6bc039fa5550 to your computer and use it in GitHub Desktop.

Select an option

Save JubbaSmail/ebaf2f1c6bc039fa5550 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <stdio.h>
#if define UNICODE
#define FindFirstFile FindFirstFileW
#define FindNextFile FindNextFileW
#else
#define FindFirstFile FindFirstFileA
#define FindNextFile FindNextFileA
#endif
int main(int argc, LPTSTR argv[])
{
HANDLE hFind;
WIN32_FIND_DATA FindData;
if (argc != 2) {
fprintf(stderr, "Usage: find pattern\n");
return 1;
}
// Find the first file
hFind = FindFirstFile(argv[1], &FindData);
printf(strcat(FindData.cFileName, "\n"));
// Look for more
while (FindNextFile(hFind, &FindData))
{
printf( strcat(FindData.cFileName,"\n") );
//printf("\n");
}
// Close the file handle
FindClose(hFind);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment