InetConnected Example for C++ 5.0 and later

This is also the example for the InetGetHostName method.

Note: This is not a complete example for handling events, some steps have been omitted. For a complete example of how to handle events, refer to the example Initializing a Computer as a Server and Accepting Connections.

void CRasterInetSink::OnInetConnected(short iComputer)
{
   TCHAR szHostName[80];
   BSTR bstrText;
   CString strText;
   CString cs;

   //add this connection to our SendList
   m_pDlg->m_pRasterInet->put_SendList(m_pDlg->m_pRasterInet->SendListNum, iComputer);

   m_pDlg->m_pRasterInet->InetGetHostName(iComputer, HOST_NAME_DESCRP);
   bstrText = m_pDlg->m_pRasterInet->GetInetHostName();

   strText = bstrText;
   lstrcpy(szHostName, (LPCTSTR)strText);
   cs.Format(TEXT("Connected to:%s"), strText);
   AfxMessageBox(cs);
   ::SysFreeString(bstrText);
}