请问为什么每次我InternetFineNextFile以后都会产生ERROR_IO_PENDING错误?
代码很简单:
int main(int argc, char* argv[])
{
HINTERNET hintSession;
hintSession = InternetOpen("ABC", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
HINTERNET hintFtpSession = InternetConnect(hintSession, "127.0.0.1",
21, "abc", "abc", INTERNET_SERVICE_FTP,
0, 0);
WIN32_FIND_DATA wfd;
HINTERNET hintFind = FtpFindFirstFile(hintFtpSession,NULL, &wfd, 0, 0);
DWORD dwError;
while (1)
{
cout << wfd.cFileName << endl;
if (!InternetFindNextFile(hintFind, &wfd))
{
dwError = NO_ERROR;
dwError = GetLastError();
if (dwError == ERROR_NO_MORE_FILES)
{
cout << "Complete!";
break;
}
else
{
cout << "Error!Code:" << dwError << endl;
}
}
cin.get();
}
InternetCloseHandle(hintFind);
InternetCloseHandle(hintFtpSession);
InternetCloseHandle(hintSession);
return 0;
}
文件名可以正常显示,但是判断不到InternetFindNextFile的结束标志,也就是说它GetLastError产生不了ERROR_NO_MORE_FILES,总是产生ERROR_IO_PENDING