0
votes

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.

1
Don't include windows if it is already included and make sure you aren't using variables and declarations in the global namespace as well.MiltoxBeyond
I'm only including windows onceGerwin
You are mixing ATL/MFC and plain Windows API includes. When using ATL/MFC you should not include Windows.h yourself, but rather include afx.h instead (it will include Windows.h at the right time). Also, those IntelliSense errors can be ignored. They are not compiler/linker errors (or warnings). Unrelated, but HWND("UploadVideo") doesn't make any sense.IInspectable
Your includes are a big mess. They are not in the original code that you link, which presumably works just fine on its own. Do yourself a favor and blow away the whole lot. Your code file should include only your precompiled header, "stdafx.h". That precompiled header would include <afx.h> and any specific Windows and C lib headers that you require. As already mentioned, if you're using ATL/MFC, you should include those headers, not the generic Win32 SDK headers. A blank, empty Win32 project from VS will get you going.Cody Gray
You have to link to wininet.lib library. See MSDN documentation for InternetOpenBarmak Shemirani

1 Answers

0
votes

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