#include "stdafx.h"
#include <urlmon.h>
#pragma comment(lib, "urlmon.lib")
int main()
{
while(1)
{
char log[100];
HRESULT hr = URLDownloadToFile ( NULL, _T("http://localhost/task.log"), _T("C:/task.log"), 0, NULL );
FILE * pFile;
pFile = fopen ("C:/task.log","r");
if(pFile != NULL)
{
fscanf(pFile,"%s",log);
fclose (pFile);
printf("%s\n",log);
remove("C:/task.log");
}
}
return 0;
}
Đây là code của mình. Lần đầu tiên debug và file task.log ở localhost còn trống. Khi file task.log đã có nội dung thì vẫn ko hiển thị gì ra màn hình cả. Nhưng khi stop debug và làm trống file task.log, thực hiện lại từ đầu thì mới hiển thị kết quả. Mọi người giải thích dùm mình với
Bookmarks