Here is my code
#include <iostream>
#include <Windows.h>
#include <WinInet.h>
using namespace std;
int main()
{
HINTERNET hSession, hURL;
char* Buffer = new char[1024];
DWORD BufferLen, BytesWritten;
HANDLE FileHandle;
hSession = InternetOpenA(NULL, 0, NULL, NULL, 0);
hURL = InternetOpenUrlA(hSession, "http://www.google.co.uk", NULL, 0, 0, 0);
FileHandle = CreateFileA("C:\\temp.txt", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
BytesWritten = 0;
do
{
InternetReadFile(hURL, Buffer, 1024, &BufferLen);
WriteFile(FileHandle, Buffer, BufferLen, &BytesWritten, NULL);
} while (BufferLen != 0);
CloseHandle(FileHandle);
InternetCloseHandle(hURL);
InternetCloseHandle(hSession);
ShellExecuteA(0, "open", "C:\\temp.txt", NULL, NULL, 1);
cout << "Operation complete!";
system("PAUSE");
return 0;
}
Here are the errors I am encountering
error LNK2019: unresolved external symbol __imp__InternetOpenA@20 referenced in function _main
error LNK2019: unresolved external symbol __imp__InternetCloseHandle@4 referenced in function _main
error LNK2019: unresolved external symbol __imp__InternetOpenUrlA@24 referenced in function _main
error LNK2019: unresolved external symbol __imp__InternetReadFile@16 referenced in function _main
I don't understand where I am going wrong. I have imported Wininet.h and Windows.h. Why is it still having trouble locating these functions? Regards.