0

I am compiling the following code and get the below errors:

errors

This is really confusing me on how to fix it, because I don't see any errors highlighted in Visual Studio, and I have researched/followed the documentation.

I tried reading the linker documentation, but it just doesn't make sense in my context. I have also tried making sure all correct parameters are passed:

#include "stdafx.h"
#include <iostream>
#include <string>
#include <windows.h>
#include <WinHttp.h>

int main()
{
    HINTERNET hSession = NULL, hConnect = NULL, hRequest = NULL;
    hSession = WinHttpOpen(L"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36",
        WINHTTP_ACCESS_TYPE_NO_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);

    //make the connection request
    if (hSession) {
        hConnect = WinHttpConnect(hSession, L"http://api", 80, 0);
    }
    else {
        printf("error: %d", GetLastError());
    }

    // open the request - not connected at this point
    hRequest = WinHttpOpenRequest(hConnect, L"GET", NULL, NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, 0);

    //
    int x;
    std::cin >> x;

    return 0;
}
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
jimmy
  • 73
  • 1
  • 7
  • "I tried reading link documentation but it just doesn't make sense in my context." You are developing c++ app, *linking* is one of the most important things that *should* make sense. – raidensan May 25 '18 at 13:20
  • @raidensan thanks for the nonconstructive comment. are you able to assist?Or please change the motto on your profile from #Soreadtohelp – jimmy May 25 '18 at 13:36
  • It looks like you're probably not including the library. Look here: https://stackoverflow.com/questions/588420/c-compile-problem-with-winhttp-windows-sdk – gunnerone May 25 '18 at 16:26

0 Answers0