変数urlに URLが入ってるとしての処理
szRedirectが!=""なら転送。ここに転送先URLが入ってる
// 転送URL先URL取得 CString Server_Host_Address; CString FileLocation; CString Referer; CString SaveDirectory; CString SaveName; CString tmpUrl = url; tmpUrl.Replace("http://", ""); tmpUrl.Replace("https://", ""); int pos = tmpUrl.Find("/"); Server_Host_Address = tmpUrl.Left(pos); FileLocation = tmpUrl.Mid(pos + 1); HINTERNET hInternet; HINTERNET hHttpSession; // WININET初期化 hInternet = InternetOpen( "Web_Downloader", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hInternet == NULL ) return 0; hHttpSession = InternetOpenUrl(hInternet, url, NULL, 0, INTERNET_FLAG_NO_AUTO_REDIRECT | INTERNET_FLAG_RELOAD, 0 ); if (hHttpSession == NULL) { InternetCloseHandle(hInternet); return 0; } TCHAR szRedirect[4096] = { 0 }; DWORD dwRedirect = sizeof(szRedirect); DWORD StatusCode, StatusCode_Size = sizeof(DWORD); BOOL bHttpQueryInfo_STATUS = HttpQueryInfo( //エラーコードを数値として返してくれる。 hHttpSession, HTTP_QUERY_LOCATION, (LPVOID)szRedirect, &dwRedirect, NULL); if ( szRedirect[0] != '\0' ) { // 転送! } InternetCloseHandle(hHttpSession); InternetCloseHandle(hInternet);