用FindFirstFile()函数为什么找不到文件?
FindFirstFile()返回的是INVALID_HANDLE_VALUE
用的是vs2008,不知问题出在哪。。
代码如下:
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
HANDLE hFind;
WIN32_FIND_DATA FindData;
cout << "A very basic FindFirst/Next demo.\n" << endl;
// Find the first file
hFind = FindFirstFile(reinterpret_cast<LPTSTR>("C:\\Windows\\*.exe"), &FindData);
cout << FindData.cFileName << endl;
// Look for more
while (FindNextFile(hFind, &FindData))
{
cout << FindData.cFileName << endl;
}
// Close the file handle
FindClose(hFind);
return 0;
}