Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3840474
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:32:02+00:00 2026-05-19T15:32:02+00:00

I have a big big problem. I’m trying to use WinHttp to download file

  • 0

I have a big big problem. I’m trying to use WinHttp to download file with C++ and I’m using Visual Studio 2010 in order to do this thing.

My problem is that the program is not compiling because are generated 307 errors, all refering to winhttp.h. I mention that I have included that file. What could be the problem? Thanks!

There are some:

------ Build started: Project: a, Configuration: Debug Win32 ------

  b. Cpp

  a. Cpp

c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(50): error C2146: 
Syntax error: missing ';' before identifier 'HINTERNET'

c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(50): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(50): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(51): error C2143: syntax error: missing ';' before '*'

c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(51): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(51): error C2378: 'HINTERNET': redefinition; symbol cannot be overloaded with a typedef

          c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(50): see declaration of 'HINTERNET'


c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(51): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(53): error C2146: syntax error: missing ';' before identifier 'INTERNET_PORT'

c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(53): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(53): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(54): error C2143: syntax error: missing ';' before '*'
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(54): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(54): error C2378: 'INTERNET_PORT': redefinition; symbol cannot be overloaded with a typedef
          c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(53): see declaration of 'INTERNET_PORT'
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(54): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(95): error C2146: syntax error: missing ';' before identifier 'dwResult'
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(95): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(95): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(96): error C2146: syntax error: missing ';' before identifier 'dwError'
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(96): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(96): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(107): error C2146: syntax error: missing ';' before identifier 'dwMajorVersion'
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(107): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(107): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(108): error C2146: syntax error: missing ';' before identifier 'dwMinorVersion'
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(108): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(108): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(144): error C2146: syntax error: missing ';' before identifier 'dwStructSize'
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(144): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(144): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. H(145): error C2146: syntax error: missing ';' before identifier 'lpszScheme'

Now I have another problem. This is my code:

#include <windows.h>
#include <winhttp.h>
#include <stdio.h>
#include <iostream>
using namespace std;
#include <string.h>

int main()
{
    DWORD dwSize = 0;
    DWORD dwDownloaded = 0;
    LPBYTE pszOutBuffer;
    BOOL bResults = FALSE;
    HINTERNET hSession = NULL, hConnect = NULL, hRequest = NULL;

// Use WinHttpOpen to obtain a session handle.
hSession = WinHttpOpen( L"Internet Explorer example", 
    WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
    WINHTTP_NO_PROXY_NAME, 
    WINHTTP_NO_PROXY_BYPASS, 0 );

// Specify an HTTP server.
if( hSession )
    hConnect = WinHttpConnect( hSession, L"www.my-new-gadget.com",
    INTERNET_DEFAULT_HTTPS_PORT, 0 );

// Create an HTTP request handle.
if( hConnect )
    hRequest = WinHttpOpenRequest( hConnect, L"GET", L"index.php",
    NULL, WINHTTP_NO_REFERER, 
    NULL, NULL);

// Send a request.
if( hRequest )
    bResults = WinHttpSendRequest( hRequest,
    WINHTTP_NO_ADDITIONAL_HEADERS, 0,
    WINHTTP_NO_REQUEST_DATA, 0, 
    0, 0 );

// End the request.
if( bResults )
    bResults = WinHttpReceiveResponse( hRequest, NULL );

HANDLE hFile = CreateFile("D:\\index.php", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

if (bResults)
{
    do     
    {        
        // Check for available data.        
        dwSize = 0;        
        if (!WinHttpQueryDataAvailable( hRequest, &dwSize))
            printf( "Error %u in WinHttpQueryDataAvailable.\n", GetLastError());        
        // Allocate space for the buffer.        
        pszOutBuffer = new byte[dwSize+1];        
        if (!pszOutBuffer)        
        {            
            printf("Out of memory\n");            
            dwSize=0;        
        }        
        else        
        {            
            // Read the Data.            
            ZeroMemory(pszOutBuffer, dwSize+1);            
            if (!WinHttpReadData( hRequest, (LPVOID)pszOutBuffer, dwSize, &dwDownloaded))                
            {                
                printf( "Error %u in WinHttpReadData.\n", GetLastError());                
            }            
            else                
            {                        
                //printf("%s", pszOutBuffer); 
                DWORD wmWritten;
                bool fr = WriteFile(hFile, pszOutBuffer, dwSize, &wmWritten, NULL);
                int n = GetLastError();              
            }            
            // Free the memory allocated to the buffer.            
            delete [] pszOutBuffer;        
        }    
    } while (dwSize>0);
}

CloseHandle(hFile);
// Report any errors.
if (!bResults)    
    printf("Error %d has occurred.\n",GetLastError());
// Close any open handles.
if (hRequest) WinHttpCloseHandle(hRequest);
if (hConnect) WinHttpCloseHandle(hConnect);
if (hSession) WinHttpCloseHandle(hSession);

return 0;
}

And the output is:

------ Build started: Project: a, Configuration: Debug Win32 ------
  a.cpp
c:\users\admin\documents\visual studio 2010\projects\a\a\a.cpp(73): warning C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
a.obj : error LNK2019: unresolved external symbol __imp__WinHttpCloseHandle@4 referenced in function _main
a.obj : error LNK2019: unresolved external symbol __imp__WinHttpReadData@16 referenced in function _main
a.obj : error LNK2019: unresolved external symbol __imp__WinHttpQueryDataAvailable@8 referenced in function _main
a.obj : error LNK2019: unresolved external symbol __imp__WinHttpReceiveResponse@8 referenced in function _main
a.obj : error LNK2019: unresolved external symbol __imp__WinHttpSendRequest@28 referenced in function _main
a.obj : error LNK2019: unresolved external symbol __imp__WinHttpOpenRequest@28 referenced in function _main
a.obj : error LNK2019: unresolved external symbol __imp__WinHttpConnect@16 referenced in function _main
a.obj : error LNK2019: unresolved external symbol __imp__WinHttpOpen@20 referenced in function _main
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
c:\users\admin\documents\visual studio 2010\Projects\a\Debug\a.exe : fatal error LNK1120: 9 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

What could now be the problem? I’m trying for 2 days to make a piece of program to download a file from a given URL. It’s driving me crazy! Please help me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:32:03+00:00Added an answer on May 19, 2026 at 3:32 pm

    Add #include <windows.h> before #include <winhttp.h>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big problem using highcharts, because I have been trying for hours
I have a big problem using TBXML . When I use: + (NSString*) textForElement:(TBXMLElement*)aXMLElement
I have big problem when I am trying to deploy my app over clickonce.
I have a big problem dealing with data I try to download in my
i have a big problem... i have this map HashMap<Long, String> examValues; It gets
I have a big problem. My program must save a Xml file with 3
i have a big problem here..i am using Microsoft charting controls in my asp.net
I use plugin Comments from CakeDC and have big problem in production mode (debug=0).
I have a big problem with an UITableView, I want to use a label
I have a big problem opening http://localhost/ on Windows 7 (beta). I installed this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.