1 #ifndef ASYNC_INET 2 #define ASYNC_INET 3 4 5 enum ASYNC_EVENT 6 { 7 ASYNCINET_DATA, // wParam is the Data retrieved from the internet, lParam is the length of Data 8 9 ASYNCINET_COMPLETE, // wParam and lParam are not used. 10 // when receiving this, AsyncInet will be free soon and should not used anymore 11 12 ASYNCINET_CANCELLED, // wParam and lParam are not used. 13 // when receiving this, AsyncInet will be free soon and should not used anymore 14 15 ASYNCINET_ERROR // wParam is not used. lParam specify the error code (if there is one). 16 // when receiving this, AsyncInet will be free soon and should not used anymore 17 }; 18 19 typedef struct __AsyncInet ASYNCINET, * pASYNCINET; 20 21 typedef int 22 (*ASYNCINET_CALLBACK)( 23 pASYNCINET AsyncInet, 24 ASYNC_EVENT Event, 25 WPARAM wParam, 26 LPARAM lParam, 27 VOID* Extension 28 ); 29 30 typedef struct __AsyncInet 31 { 32 HINTERNET hInternet; 33 HINTERNET hInetFile; 34 35 HANDLE hEventHandleCreated; 36 37 UINT ReferenceCnt; 38 CRITICAL_SECTION CriticalSection; 39 HANDLE hEventHandleClose; 40 41 BOOL bIsOpenUrlComplete; 42 43 BOOL bCancelled; 44 45 BYTE ReadBuffer[4096]; 46 DWORD BytesRead; 47 48 ASYNCINET_CALLBACK Callback; 49 VOID* Extension; 50 } ASYNCINET, * pASYNCINET; 51 52 pASYNCINET AsyncInetDownload(LPCWSTR lpszAgent, 53 DWORD dwAccessType, 54 LPCWSTR lpszProxy, 55 LPCWSTR lpszProxyBypass, 56 LPCWSTR lpszUrl, 57 BOOL bAllowCache, 58 ASYNCINET_CALLBACK Callback, 59 VOID* Extension 60 ); 61 62 BOOL AsyncInetCancel(pASYNCINET AsyncInet); 63 64 VOID AsyncInetRelease(pASYNCINET AsyncInet); 65 66 #endif 67