Hey, I actually got it to work. Could you tell me how I can make it so that my program doesn't lock up while it is downloading though. The progress which is just a static text shows the size in bytes of the program when it is finished downloading so I know its working. Here is the code I am using for the IBindStatusCallback.
Code:
class CCallback : public IBindStatusCallback
{
public:
CCallback();
~CCallback();
// Pointer to the main dialog.
HWND hwnd;
STDMETHOD(OnStartBinding)(
/* [in] */ DWORD dwReserved,
/* [in] */ IBinding __RPC_FAR *pib)
{ return E_NOTIMPL; }
STDMETHOD(GetPriority)(
/* [out] */ LONG __RPC_FAR *pnPriority)
{ return E_NOTIMPL; }
STDMETHOD(OnLowResource)(
/* [in] */ DWORD reserved)
{ return E_NOTIMPL; }
STDMETHOD(OnProgress)(
/* [in] */ ULONG ulProgress,
/* [in] */ ULONG ulProgressMax,
/* [in] */ ULONG ulStatusCode,
/* [in] */ LPCWSTR wszStatusText);
STDMETHOD(OnStopBinding)(
/* [in] */ HRESULT hresult,
/* [unique][in] */ LPCWSTR szError)
{ return E_NOTIMPL; }
STDMETHOD(GetBindInfo)(
/* [out] */ DWORD __RPC_FAR *grfBINDF,
/* [unique][out][in] */ BINDINFO __RPC_FAR *pbindinfo)
{ return E_NOTIMPL; }
STDMETHOD(OnDataAvailable)(
/* [in] */ DWORD grfBSCF,
/* [in] */ DWORD dwSize,
/* [in] */ FORMATETC __RPC_FAR *pformatetc,
/* [in] */ STGMEDIUM __RPC_FAR *pstgmed)
{ return E_NOTIMPL; }
STDMETHOD(OnObjectAvailable)(
/* [in] */ REFIID riid,
/* [iid_is][in] */ IUnknown __RPC_FAR *punk)
{ return E_NOTIMPL; }
STDMETHOD_(ULONG,AddRef)()
{ return 0; }
STDMETHOD_(ULONG,Release)()
{ return 0; }
STDMETHOD(QueryInterface)(
/* [in] */ REFIID riid,
/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
{ return E_NOTIMPL; }
};
CCallback::CCallback()
{
}
CCallback::~CCallback()
{
}
HRESULT CCallback::OnProgress ( ULONG ulProgress, ULONG ulProgressMax,
ULONG ulStatusCode, LPCWSTR wszStatusText )
{
SetDlgItemInt(hwnd, IDC_HOWFAR, (UINT)ulProgress, FALSE);
return S_OK;
}
And then I make the object:
CCallback callback;
callback.hwnd = hwnd; // hwnd is the window handle to my main
And then I call the function:
URLDownloadToFile(NULL, buffer, szFileName, 0, &callback);
Now all I have to do is get tidy it up a little and make it not lock up while downloading.
PS. Sorry about all the messy code