# Include <stdio. h> # Include <Urlmon. h> # Pragma Comment (Lib, "urlmon. lib ") Hresult (stdmethodcalltype QueryInterface) (ibindstatuscallback * This, /* [In] */ Refiid riid, /* [Iid_is] [out] */ Void ** Ppvobject ){ Return E_notimpl;} ulong (stdmethodcalltype addref) (ibindstatuscallback * This ){ Return E_notimpl;} ulong (stdmethodcalltype release) (ibindstatuscallback * This ){ Return E_notimpl;} hresult (stdmethodcalltype onstartbinding) (ibindstatuscallback * This, /* [In] */ DWORD dwreserved, /* [In] */ Ibinding * PIB ){ Return E_notimpl;} hresult (stdmethodcalltype getpriority) (ibindstatuscallback * This, /* [Out] */ Long * Pnpriority ){ Return E_notimpl;} hresult (stdmethodcalltype onlowresource) (ibindstatuscallback * This, /* [In] */ DWORD reserved ){ Return E_notimpl;} hresult (stdmethodcalltype onprogress) (ibindstatuscallback * This, /* [In] */ Ulong ulprogress, /* [In] */ Ulong ulprogressmax, /* [In] */ Ulong ulstatuscode, /* [In] */ Lpcwstr szstatustext ){ If (Ulprogress> 0 ) {Printf ( " Downloaded % d of % d bytes \ n " , Ulprogress, ulprogressmax); fflush (stdout );} Return S_ OK;} hresult (stdmethodcalltype onstopbinding) (ibindstatuscallback * This, /* [In] */ Hresult, /* [Unique] [in] */ Lpcwstr szerror ){ Return E_notimpl;} hresult (stdmethodcalltype getbindinfo) (ibindstatuscallback * This, /* [Out] */ DWORD * Grfbindf, /* [Unique] [out] [in] */ Bindinfo * Pbindinfo ){ Return E_notimpl;} hresult (stdmethodcalltype ondataavailable) (ibindstatuscallback *This, /* [In] */ DWORD grfbscf, /* [In] */ DWORD dwsize, /* [In] */ Formatetc * Pformatetc, /* [In] */ Stgmedium *Pstgmed ){ Return E_notimpl;} hresult (stdmethodcalltype onobjectavailable) (ibindstatuscallback * This, /* [In] */ Refiid riid, /* [Iid_is] [in] */ Iunknown * Punk ){ Return E_notimpl ;} Static Const Ibindstatuscallbackvtbl ibindstatuscallback_vtbl = {QueryInterface, addref, release, onstartbinding, getpriority, onlowresource, onprogress, onstopbinding, getbindinfo, ondataavailable, onobjectavailable }; Int Main ( Int Argc, Char * Argv []) {hresult hr; ibindstatuscallback mycallback; mycallback. lpvtbl = (Ibindstatuscallbackvtbl *)& Ibindstatuscallback_vtbl; HR = Urldownloadtofile (null, " Http://www.baidu.com/index.php " , " Index. php " , 0 ,& Mycallback ); If (HR! = S_ OK) {printf ( " Error: % x \ n " , HR );} Return 0 ;}
Girl don't cry (QQ: 191035066) @ 2012-05-02 16:05:03 @ http://www.cnblogs.com/nbsofer