R
Rudy Ko
Hi, all,
Anyone know how to issue a http request from VC or have a sample?
Thanks!!
Regards,
Rudy
Anyone know how to issue a http request from VC or have a sample?
Thanks!!
Regards,
Rudy
Anyone know how to issue a http request from VC or have a sample?
Jochen said:Hi Rudy Ko,
MFC: CHttpConnection Class
http://msdn.microsoft.com/library/en-us/vclib/html/_MFC_CHttpConnection.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/simplehttpclient.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
Jochen said:Hi Rudy Ko,
MFC: CHttpConnection Class
http://msdn.microsoft.com/library/en-us/vclib/html/_MFC_CHttpConnection.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/simplehttpclient.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/d.../winhttp/http/using_the_winhttp_c_c___api.asp
Or you can use the URLMON library.
See
http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/moniker/overview/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;
}