我是编程的初学者。我运行程序时一直收到此错误。我已经在网上查了一下,很多人建议在所有包含之后添加/ * #pragma comment(lib,“wininet.lib”)* /或更改属性设置。
到目前为止我改变了两个,但信息仍在那里。
我正在使用2010 Microsoft Visual Studio,整个错误消息如下:
1> MSVCRTD.lib(crtexew.obj):错误LNK2019:函数_ _tmainCRTStartup中未解析的外部符号 WinMain @ 16引用> 1> C:\ Users \ Username \ Desktop \ Winlnet test \ Debug \ Winlnet test.exe:致命错误LNK1120:1>未解析的外部因素
1 GT;
1> Build FAILED。
1个GT;
任何帮助都非常感谢!!以下是该计划。
#include <string>
#include <iostream>
#include <fstream>
#include <windows.h>
#include <wininet.h>
#include <winsock.h>
#include <stdio.h>
#include <stdarg.h>
#pragma comment(lib, "wininet.lib")
using namespace std;
int main()
{
HINTERNET hOpen, hURL;
LPCWSTR NameProgram = L"Webreader"; // LPCWSTR == Long Pointer to Const Wide String
LPCWSTR Website;
char file[101];
unsigned long read;
//Always need to establish the internet connection with this funcion.
if ( !(hOpen = InternetOpen(NameProgram, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 )))
{
cerr << "Error in opening internet" << endl;
return 0;
}
Website = L"http://www.google.com";
hURL = InternetOpenUrl( hOpen, Website, NULL, 0, 0, 0 ); //Need to open the URL
InternetReadFile(hURL, file, 100, &read);
while (read == 100)
{
InternetReadFile(hURL, file, 100, &read);
file[read] = '\0';
cout << file;
}
cout << endl;
InternetCloseHandle(hURL);
return 0;
}