/***********************************
Author : Demon
Website : http://demon.tw
E-mail : 380401911@qq.com
***********************************/
#include
#include
#pragmacomment (lib,"urlmon.lib")
HRESULT ( STDMETHODCALLTYPE QueryInterface )(
IBindStatusCallback * This,
/* [in] */REFIID riid,
/* [iid_is][out] */void**ppvObject)
{
returnE_NOTIMPL;
}
ULONG ( STDMETHODCALLTYPE AddRef )(
IBindStatusCallback * This)
{
returnE_NOTIMPL;
}
ULONG ( STDMETHODCALLTYPE Release )(
IBindStatusCallback * This)
{
returnE_NOTIMPL;
}
HRESULT ( STDMETHODCALLTYPE OnStartBinding )(
IBindStatusCallback * This,
/* [in] */DWORD dwReserved,
/* [in] */IBinding *pib)
{
returnE_NOTIMPL;
}
HRESULT ( STDMETHODCALLTYPE GetPriority )(
IBindStatusCallback * This,
/* [out] */LONG *pnPriority)
{
returnE_NOTIMPL;
}
HRESULT ( STDMETHODCALLTYPE OnLowResource )(
IBindStatusCallback * This,
/* [in] */DWORD reserved)
{
returnE_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);
}
returnS_OK;
}
HRESULT ( STDMETHODCALLTYPE OnStopBinding )(
IBindStatusCallback * This,
/* [in] */HRESULT hresult,
/* [unique][in] */LPCWSTR szError)
{
returnE_NOTIMPL;
}
HRESULT ( STDMETHODCALLTYPE GetBindInfo )(
IBindStatusCallback * This,
/* [out] */DWORD *grfBINDF,
/* [unique][out][in] */BINDINFO *pbindinfo)
{
returnE_NOTIMPL;
}
HRESULT ( STDMETHODCALLTYPE OnDataAvailable )(
IBindStatusCallback * This,
/* [in] */DWORD grfBSCF,
/* [in] */DWORD dwSize,
/* [in] */FORMATETC *pformatetc,
/* [in] */STGMEDIUM *pstgmed)
{
returnE_NOTIMPL;
}
HRESULT ( STDMETHODCALLTYPE OnObjectAvailable )(
IBindStatusCallback * This,
/* [in] */REFIID riid,
/* [iid_is][in] */IUnknown *punk)
{
returnE_NOTIMPL;
}
static constIBindStatusCallbackVtbl IBindStatusCallback_Vtbl =
{
QueryInterface,
AddRef,
Release,
OnStartBinding,
GetPriority,
OnLowResource,
OnProgress,
OnStopBinding,
GetBindInfo,
OnDataAvailable,
OnObjectAvailable
};
intmain(intargc,char*argv[])
{
HRESULT hr;
IBindStatusCallback MyCallback;
MyCallback.lpVtbl = (IBindStatusCallbackVtbl *)&IBindStatusCallback_Vtbl;
hr = URLDownloadToFile(NULL,
"http://demon.tw/download/VbsEdit.zip","VbsEdit.zip",0, &MyCallback);
if(FAILED(hr))
{
printf("Error: %X\n", hr);
}
return0;
}