CString GetRedirectedURL(CString p_URL) { CString szFinalUrl; CInternetSession _session; CStdioFile * pcsf; CHttpFile * pchf; try { pcsf = _session.OpenURL(p_URL, INTERNET_FLAG_TRANSFER_BINARY); CHttpFile * pchf = (CHttpFile*)pcsf; CHAR buf[2048] = {0}; DWORD dwOptionReaded = 0; pchf->QueryOption(INTERNET_OPTION_URL, buf, dwOptionReaded); szFinalUrl.Format(_T("%s"), buf); } catch(...) { _session.Close(); pcsf->Close(), delete pcsf, pcsf = 0, pchf = 0; } _session.Close(); pcsf->Close(), delete pcsf, pcsf = 0, pchf = 0; return szFinalUrl; }