Показать сообщение отдельно

  #3  
Старый 14.05.2006, 13:59
Deem3n®
Постоянный
Регистрация: 19.09.2005
Сообщений: 408
Провел на форуме:
3730496

Репутация: 519
По умолчанию

Код:
#include <afxinet.h>
...
void SendGetRequest(CString szHostName, CString wts)
{
	CInternetSession session;
	CHttpConnection* pConnection = NULL;
	CHttpFile* pFile = NULL;
    
	UINT buff_size = 2048;
	char* buffer = new char[buff_size];
	UINT nBytesRead = 0;
	try
	{
		pConnection = session.GetHttpConnection(szHostName, (INTERNET_PORT)80);
		pFile = pConnection->OpenRequest(1, wts); // 1 = GET
		pFile->SendRequest();
		
		nBytesRead = pFile->Read(buffer, buff_size - 1);
		buffer[nBytesRead] = '\0';
		// запрошенная страница
		AfxMessageBox(buffer);
	}
	catch(CInternetException* e)
	{
		// Обрабатываешь исключение ...
		AfxMessageBox("Error!");
		e->Delete();
	}
	if(pFile) delete pFile;
	if(pConnection) delete pConnection;
	delete [] buffer;
}
...
http://192.168.50.2/2/1.php?id=1&test=1 вызывать вот так:
Код:
SendGetRequest("192.168.50.2", "/2/1.php?id=1&test=1");
 
Ответить с цитированием