关于FindFirstFileEx中lpFileName参数的问题
下面是我的代码:
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <stdio.h>
int main(void)
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
char str[]="1.txt";
printf ("Target file is %s.\n", str);
hFind = FindFirstFileEx(str, FindExInfoStandard, &FindFileData,
FindExSearchNameMatch, NULL, 0 );
if (hFind == INVALID_HANDLE_VALUE)
{
printf ("Invalid File Handle. GetLastError reports %d\n",
GetLastError ());
return (0);
}
else
{
printf ("The first file found is %s\n",
FindFileData.cFileName);
FindClose(hFind);
return (1);
}
}
编译无问题,且运行前我已经在d盘的某个目录下面建了一个1.txt,但运行结果总是:
Target file is 1.txt.
Invalid File Handle. GetLastError reports 2
Press any key to continue
用Look up查看:系统找不到指定的文件。