Gerwin
Gerwin

Reputation: 1612

Error's when adding code to c++ winAPI script

I have a code base that checks for a button press, and I want to connect to a server whenever I click on the button, but when I add the following code -

includes

#include <atlstr.h>
#include <stdafx.h>
#include <stdio.h>

#include "stdafx.h"
#include "P2GoVideoUploader2.0.h"
#include "libobs/obs.h"
#include "libobs/obs-module.h"

#include <WinInet.h>

defines

#define uploadName "Upload Window"
#define uploadWNDWidth 500
#define uploadWNDHeight 500
#define IDC_SELECT_VIDEO (100)
#define IDC_UPLOAD_VIDEO (99)

HWND  hBtnParent = HWND("UploadVideo");
HWND SelectVideoBTN, UploadBTN, hWnd, hBtn;

WPARAM wmId, wmEvent;

HINSTANCE hUpload;

WNDCLASSEX wcexUpload;

int nCmdShowUpload = 1;

using namespace std;

LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);

    HINTERNET hTest;
    HINTERNET hFTP;
    hTest = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);

to -

LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_COMMAND:
        if (wParam == IDC_SELECT_VIDEO) {
            //code goes here
            }

        else if (wParam == IDC_UPLOAD_VIDEO){
            MessageBox(hWnd, L"something", L"else", 0);
        }
        break;
    default:
        return DefWindowProc(hwnd, message, wParam, lParam);
    }
    return wParam;
}

I these errors -

Error   5   error LNK2019: unresolved external symbol __imp__InternetOpenW@20 referenced in function "long __stdcall WindowProcedure(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProcedure@@YGJPAUHWND__@@IIJ@Z)
Error   6   error LNK1120: 1 unresolved externals

The first error happens in -projfile.obj and the second error happens in projfile.dll

I've found the code on - http://www.rohitab.com/discuss/topic/29994-c-ftp-upload-help/ & i've tried multiple other upload examples, but they all result in similiar errors, why am I getting these error's?

My project is a Win32 Project, I'm using Visual Studio 2013.

Upvotes: 0

Views: 169

Answers (1)

Gerwin
Gerwin

Reputation: 1612

You have to link to wininet.lib library, in VS2013 do -

Project -> Project Properties -> Linker -> input -> add to additional dependencies

& since someone mentioned the first error, that it was something different, WinInet.h and winhttp.h were colliding, if I included both it wouldn't compile, so I removed winhttp.h

Upvotes: 0

Related Questions