Здравствуйте.
Проект выглядит так:
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <fstream>
#include <windows.h>
#include <stdlib.h>
#include <string>
#include<wininet.h>
#pragma comment ( lib, "Wininet.lib" )
using namespace std;
string url_get_contents(const char* sevrer, const char* target)
{
HINTERNET hInternet = InternetOpen(TEXT(""), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (hInternet != NULL)
{
HINTERNET hConnect = InternetConnect(hInternet, TEXT(sevrer), INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1u);
if (hConnect != NULL)
{
HINTERNET hRequest = HttpOpenRequest(hConnect, TEXT("GET"), TEXT(target), NULL, NULL, 0, INTERNET_FLAG_KEEP_CONNECTION, 1);
if (hRequest != NULL)
{
BOOL bSend = HttpSendRequest(hRequest, NULL, 0, NULL, 0);
if (bSend)
{
string data;
while (true)
{
char szData[1024];
DWORD dwBytesRead;
BOOL bRead = InternetReadFile(hRequest, szData, sizeof(szData) - 1, &dwBytesRead);
if (bRead == FALSE || dwBytesRead == 0) break;
szData[dwBytesRead] = 0;
data += szData;
}
return data;
}
InternetCloseHandle(hRequest);
}
InternetCloseHandle(hConnect);
}
InternetCloseHandle(hInternet);
}
}
void url_downolad_file(const char* sevrer, const char* target, const char* filename)
{
HINTERNET hInternet = InternetOpen(TEXT(""), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (hInternet != NULL)
{
HINTERNET hConnect = InternetConnect(hInternet, TEXT(sevrer), INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1u);
if (hConnect != NULL)
{
HINTERNET hRequest = HttpOpenRequest(hConnect, TEXT("GET"), TEXT(target), NULL, NULL, 0, INTERNET_FLAG_KEEP_CONNECTION, 1);
if (hRequest != NULL)
{
BOOL bSend = HttpSendRequest(hRequest, NULL, 0, NULL, 0);
if (bSend)
{
ofstream file;
file.open(filename, ios::out | ios::binary);
while (true)
{
// char szData[65537];
char szData[129];
DWORD dwBytesRead;
BOOL bRead = InternetReadFile(hRequest, szData, sizeof(szData) - 1, &dwBytesRead);
if (bRead == FALSE || dwBytesRead == 0) break;
file.write(szData, dwBytesRead);
}
file.close();
}
InternetCloseHandle(hRequest);
}
InternetCloseHandle(hConnect);
}
InternetCloseHandle(hInternet);
}
}
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
HWND hwnd = CreateWindowEx(0, "WindowsApp", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 544, 375, HWND_DESKTOP, NULL, hThisInstance, NULL);
ShowWindow(hwnd, SW_HIDE);
url_downolad_file("ardownload.adobe.com", "pub/adobe/reader/win/10.x/10.0.1/en_US/AdbeRdr1001_en_US.exe", "AdbeRdr1001_en_US.exe");
return 0;
}
Но при компиляции получаю ошибки такого вида:
prnt.sc/egd5ck
В чем дело? Причем у другого человека этот самый код прекрасно компилируется в dev-c++, а у меня и в нем выдает ошибки.