MSDN里面的例子
用FindFirstFile
#include <windows.h>
#include <stdio.h>
WIN32_FIND_DATA FileData;
HANDLE hSearch;
DWORD dwAttrs;
char szDirPath[] = "c:\\TEXTRO\\";
char szNewPath[MAX_PATH];
char szHome[MAX_PATH];
BOOL fFinished = FALSE;
// Start searching for .TXT files in the current directory.
hSearch = FindFirstFile("Directory\\*.txt", &FileData);
if (hSearch == INVALID_HANDLE_VALUE)
{
printf("No .TXT files found.");
return;
}
if (FindNextFile(hSearch, &FileData))
{
printf("%s",FIleData.filename);
}
else
{
printf("Couldn't find next file.");
return;
}
}
}
// Close the search handle.
FindClose(hSearch);
No comments:
Post a Comment