473,509 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

invoke http within VC++

Hi, all,

Anyone know how to issue a http request from VC or have a sample?
Thanks!!

Regards,
Rudy
Nov 17 '05 #1
3 1744
Hi Rudy Ko,
Anyone know how to issue a http request from VC or have a sample?


MFC: CHttpConnection Class
http://msdn.microsoft.com/library/en...Connection.asp

WinInet: Using WinInet HTTP functions in Full Asynchronous Mode
http://www.codeproject.com/internet/asyncwininet.asp

WinInet: Simple HTTP Client using WININET
http://www.codeproject.com/internet/...httpclient.asp

Or you can use the native socket functions....

See: Winsock 2
http://msdn.microsoft.com/library/en-
us/winsock/winsock/windows_sockets_start_page_2.asp

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #2
Jochen Kalmbach wrote:
Hi Rudy Ko,
Anyone know how to issue a http request from VC or have a sample?


MFC: CHttpConnection Class
http://msdn.microsoft.com/library/en...Connection.asp

WinInet: Using WinInet HTTP functions in Full Asynchronous Mode
http://www.codeproject.com/internet/asyncwininet.asp

WinInet: Simple HTTP Client using WININET
http://www.codeproject.com/internet/...httpclient.asp

Or you can use the native socket functions....

See: Winsock 2
http://msdn.microsoft.com/library/en-
us/winsock/winsock/windows_sockets_start_page_2.asp


Or you can use WinHttp:

http://msdn.microsoft.com/library/de..._c_c___api.asp

Or you can use the URLMON library.

See

http://msdn.microsoft.com/library/de...w/overview.asp

Note: URL monikers are only usfulo for issuing a GET request. If you need
to do a POST or HEAD or anything else, you can't use URL monikers.

Below is a complete program to fetch and save a file from HTTP

-cd

#include <windows.h>
#include <tchar.h>
#include <urlmon.h>
#include <stdio.h>

int _tmain(int argc, TCHAR* argv[])
{

if (3 != argc)
{
_tprintf(_T("usage: %0 URL out-file-name"),argv[0]);
return 1;
}

::CoInitialize(0);
TCHAR szFullName[MAX_PATH];
::GetFullPathName(argv[2],MAX_PATH,szFullName,0);
HRESULT hr = ::URLDownloadToFile(
0,
argv[1],
szFullName,
0,
0
);
::CoUninitialize();

if (FAILED(hr))
{
_tprintf(_T("Failed, hr=0x%08x\n"),hr);
return 2;
}

return 0;
}


Nov 17 '05 #3
Actually you can use URL monikers for performing POST and HEAD requests.

See RegisterBindStatusCallback.

It's not simple, but it's certainly doable.

Carl Daniel [VC++ MVP] wrote:
Jochen Kalmbach wrote:
Hi Rudy Ko,

Anyone know how to issue a http request from VC or have a sample?


MFC: CHttpConnection Class
http://msdn.microsoft.com/library/en...Connection.asp

WinInet: Using WinInet HTTP functions in Full Asynchronous Mode
http://www.codeproject.com/internet/asyncwininet.asp

WinInet: Simple HTTP Client using WININET
http://www.codeproject.com/internet/...httpclient.asp

Or you can use the native socket functions....

See: Winsock 2
http://msdn.microsoft.com/library/en-
us/winsock/winsock/windows_sockets_start_page_2.asp

Or you can use WinHttp:

http://msdn.microsoft.com/library/de..._c_c___api.asp

Or you can use the URLMON library.

See

http://msdn.microsoft.com/library/de...w/overview.asp

Note: URL monikers are only usfulo for issuing a GET request. If you need
to do a POST or HEAD or anything else, you can't use URL monikers.

Below is a complete program to fetch and save a file from HTTP

-cd

#include <windows.h>
#include <tchar.h>
#include <urlmon.h>
#include <stdio.h>

int _tmain(int argc, TCHAR* argv[])
{

if (3 != argc)
{
_tprintf(_T("usage: %0 URL out-file-name"),argv[0]);
return 1;
}

::CoInitialize(0);
TCHAR szFullName[MAX_PATH];
::GetFullPathName(argv[2],MAX_PATH,szFullName,0);
HRESULT hr = ::URLDownloadToFile(
0,
argv[1],
szFullName,
0,
0
);
::CoUninitialize();

if (FAILED(hr))
{
_tprintf(_T("Failed, hr=0x%08x\n"),hr);
return 2;
}

return 0;
}

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2099
by: Momchil Velikov | last post by:
The following program produces error at the definition of ``b''. However it compiles fine the second (supposedly equivalent) form of the templated constructor. Why the two alternatives aren't...
3
5268
by: T | last post by:
I am attempting to create a menu using <div> and <span> tags within a table cell. When the page loads, some of the classes don't seem to be applied. If I hover over the menu everything is fine...
6
1435
by: Kevin Grigorenko | last post by:
Hello, I've been working on a little side project of mine in Visual Studio.NET for about the last month. Recently, I wanted a friend of mine to help me out with a problem and so I sent him my...
7
1282
by: wdewebserver | last post by:
Hi I would like to invoke a new instance of IE from within a page and pass it a URL. How can I do this in C#? I have tried using SHDOCVW.DLL to no avail. TIA
3
3263
by: FNZB | last post by:
Hi, Does anyone know how to do the equivalent of me.invoke from within a module? Cheers..
4
6028
by: many_years_after | last post by:
Hi, pythoners: My wxPython program includes a panel whose parent is a frame. The panel has a button. When I click the button , I want to let the frame destroy. How to implement it? Could the...
0
1036
by: =?Utf-8?B?RmFsZ3VuaSBWYWhvcmE=?= | last post by:
I have migrated the development environment for MFC single document application from VC 6 to VS 2005. I am not able to invoke the help file from the Menu – help . CMainFrame has the following...
2
6080
by: prakashpb | last post by:
Hello All, I am new to perl. I have to write some code in perl on windows. I have to invoke/run a shell file sample.sh from within perl file. When the perl while is executing, it should run to...
7
1999
by: Jeroen | last post by:
Hi all, On more than one occasion I stumbled upon an explanation here that talks about the 'P/Invoke layer'. Although I've got a general idea what it's about, I'm having trouble grasping what it...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7135
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.