| |
255 |
255 |
SetErrorCode(ERROR_SUCCESS); |
| |
256 |
256 |
if(m_hOpenUrl) |
| |
257 |
257 |
{ |
| |
258 |
258 |
m_dwExpectedState = INTERNET_STATUS_CLOSING_CONNECTION; |
| |
259 |
259 |
if(!::InternetCloseHandle(m_hOpenUrl)) |
| |
260 |
260 |
{ |
| |
261 |
261 |
SetErrorCode(::GetLastError()); |
| |
262 |
262 |
if(GetErrorCode() == ERROR_IO_PENDING) |
| |
263 |
263 |
return S_FALSE; |
| |
264 |
264 |
else |
| |
265 |
265 |
{ |
| |
266 |
266 |
SetErrorCode(ERROR_INTERNAL_ERROR); |
| |
267 |
267 |
return E_FAIL; |
| |
268 |
268 |
} |
| |
269 |
269 |
} |
| |
270 |
270 |
|
| |
271 |
271 |
|
| |
272 |
272 |
|
| |
273 |
273 |
m_dwExpectedState = 0; |
| |
274 |
274 |
SetUrlHandle(NULL); |
| |
|
275 |
if(m_hInternet != nullptr) |
| |
|
276 |
{ |
| |
275 |
277 |
::InternetCloseHandle(m_hInternet); |
| |
|
278 |
m_hInternet = nullptr; |
| |
276 |
279 |
} |
| |
|
280 |
} |
| |
277 |
281 |
|
| |
278 |
282 |
if(m_hFinishedEvent) |
| |
279 |
283 |
{ |
| |
280 |
284 |
::CloseHandle(m_hFinishedEvent); |
| |
281 |
|
m_hFinishedEvent = NULL; |
| |
|
285 |
m_hFinishedEvent = nullptr; |
| |
282 |
286 |
} |
| |
283 |
287 |
|
| |
284 |
288 |
return S_OK; |
| |
285 |
289 |
} |
| |
286 |
290 |
|
| |
287 |
291 |
|
| |
288 |
292 |
|
| |
289 |
293 |
|
| |
290 |
294 |
|
| |
291 |
295 |
|
| |
292 |
296 |
|
| |
293 |
297 |
|
| |
294 |
298 |
CAsyncHttpFile::EWaitResult CAsyncHttpFile::GetResult() |
| |
295 |
299 |
{ |
| |
296 |
300 |
HANDLE hHandles[] = { m_hFinishedEvent }; |
| |
297 |
301 |
DWORD dwEffect = WaitForMultipleObjects(1, hHandles, FALSE, 0); |
| |
298 |
302 |
if(dwEffect == WAIT_OBJECT_0 + 0 || dwEffect == WAIT_ABANDONED_0 + 0) |
| |
299 |
303 |
return GetErrorCode() == ERROR_SUCCESS ? CAsyncHttpFile::eFinished : CAsyncHttpFile::eError; |
| |
300 |
304 |
else |
| |
301 |
305 |
return CAsyncHttpFile::ePending; |