#include <Windows.h>
#include <atlstr.h>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
CString dir;
dir="d:\\*.txt";
LPCTSTR bufDir;
bufDir=(LPCTSTR)dir;
wcout << "Target file is " << bufDir << endl;
hFind = FindFirstFile(bufDir, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
wcout << "Invalid File Handle. GetLastError reports " << GetLastError () << endl;
return (0);
}
else
{
wcout << "The first file found is " << FindFileData.cFileName << endl;
FindClose(hFind);
system("pause");
return (1);
}
}
window api 查找指定路径下的类型文件(无递归)
最新推荐文章于 2020-11-09 21:59:44 发布