참고 : http://support.microsoft.com/default.aspx?sd=msdn&scid=kb;en-us;176792

// URL을 추출합니다.
ASSERT(m_spSHWinds != NULL);
long nCount = m_spSHWinds->GetCount();

IDispatchPtr spDisp;
for (long i = 0; i < nCount; i++) { _variant_t va(i, VT_I4); spDisp = m_spSHWinds->Item(va);

SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);
if (spBrowser != NULL)
m_ctrlUrlList.AddString(spBrowser->GetLocationURL());
}

GET_IEs_URL.zip

Read More
BufferedReader br = null;
  
  try {
   URL url = new URL("http://www.empas.com");
   br = new BufferedReader(new InputStreamReader(url.openStream()));
   
   String line = null;
   while ((line = br.readLine()) != null) {
    System.out.println(line);
   }
  } catch (MalformedURLException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  } finally {
   try {
    br.close();
   } catch (IOException e) {
    e.printStackTrace();
   }
  }
 }
Read More
  1. 요약
    AfxParseURL()을 이용하여 URL을 파싱할 수 있다.
  2. 본문
    AfxParseURL()은 URL을 파싱하기위한 MFC 함수입니다. 사용법은 AfxParseURL의 인자로 URL의 문자열을 입력하면 서버와 프로토콜과 포트를 파싱해서 넘겨줍니다.
    BOOL AFXAPI AfxParseURL( LPCTSTR pstrURL, DWORD& dwServiceType, CString& strServer,
                             CString& strObject, INTERNET_PORT& nPort );

    여기까지만 하면 너무 허전하죠… 그래서 MFC를 쓰지않는 프로그램에서는 이런 기능을 구현하기 위해 MFC소스를 분석해 보겠습니다.

    BOOL AFXAPI AfxParseURL(LPCTSTR pstrURL, DWORD& dwServiceType, CString& strServer,
                            CString& strObject, INTERNET_PORT& nPort) 
    { 
        dwServiceType = AFX_INET_SERVICE_UNK;
        ASSERT(pstrURL != NULL); 
        if (pstrURL == NULL) 
            return FALSE;
    
        URL_COMPONENTS urlComponents; 
        memset(&urlComponents, 0, sizeof(URL_COMPONENTS)); 
        urlComponents.dwStructSize = sizeof(URL_COMPONENTS);
    
        urlComponents.dwHostNameLength = INTERNET_MAX_URL_LENGTH; 
        urlComponents.lpszHostName = strServer.GetBuffer(INTERNET_MAX_URL_LENGTH+1); /* ④ */ 
        urlComponents.dwUrlPathLength = INTERNET_MAX_URL_LENGTH; 
        urlComponents.lpszUrlPath = 
Read More