Adding Urlmon.lib
to the project
//---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#include <Urlmon.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
Cimpmonikercallback Objimpcallback;
//---------------------------------------------------------------------------
#pragma argsused
WINAPI WinMain (hinstance hinstance, hinstance hprevinstance, LPSTR lpcmdline, int ncmdshow)
{
Lpunknown Pcaller;
Pcaller = NULL;
DWORD DWRESV = 0;
OBJIMPCALLBACK.LPFNCB = (IBindStatusCallback *) &objImpCallback;
HRESULT Hret=urldownloadtofile (Pcaller, "Http://127.0.0.1:30000/download/icon.zip", "D:\\temp\\icon.zip", DWRESV, OBJIMPCALLBACK.LPFNCB);
if (HRET==S_OK)
MessageBox (NULL, "Successful download File", "", MB_OK);
return 0;
}
//---------------------------------------------------------------------------
Cimpmonikercallback::cimpmonikercallback ()
{
m_cref = 1;
m_pbinding = NULL;
};
//---------------------------------------------------------------------------
Cimpmonikercallback::~cimpmonikercallback ()
{
if (m_pbinding)
m_pbinding->release ();
};
//---------------------------------------------------------------------------
stdmethodimp Cimpmonikercallback::queryinterface (refiid riid,void * PPV)
{
*PPV = NULL;
if (riid==iid_iunknown &brvbar;&brvbar; riid==iid_ibindstatuscallback)
{
*PPV = this;
AddRef ();
return S_OK;
}
return e_nointerface;
};
//---------------------------------------------------------------------------
Stdmethodimp_ (ULONG) cimpmonikercallback::addref ()
{
return m_cref++;
}
//---------------------------------------------------------------------------
Stdmethodimp_ (ULONG) cimpmonikercallback::release ()
{
if (--m_cref==0)
{
Delete this;
return 0;
}
return m_cref;
}
//---------------------------------------------------------------------------
stdmethodimp Cimpmonikercallback::getbindinfo (dword* pgrfbindf, bindinfo* pbindinfo)
{
return (NOERROR);
}
//---------------------------------------------------------------------------
stdmethodimp cimpmonikercallback::onstartbinding (DWORD grfbscoption, ibinding* pbinding)
{
return (NOERROR);
}
//---------------------------------------------------------------------------
stdmethodimp cimpmonikercallback::getpriority (long* pnpriority)
{
return (NOERROR);
}
//---------------------------------------------------------------------------
stdmethodimp cimpmonikercallback::onprogress (ULONG ulprogress, ULONG ulprogressmax,ulong UlStatusCode, LPCWSTR szStatusText)
{
return (NOERROR);
};
//---------------------------------------------------------------------------
Stdmethodimp Cimpmonikercallback::ondataavailable (DWORD grfBSCF, DWORD dwsize, FORMATETC *pfmtetc,stgmedium* pstgmed)
{
return (NOERROR);
}
//---------------------------------------------------------------------------
stdmethodimp cimpmonikercallback::onobjectavailable (REFIID riid, iunknown* punk)
{
return (NOERROR);
}
//---------------------------------------------------------------------------
stdmethodimp Cimpmonikercallback::onlowresource (DWORD dwreserved)
{
return (NOERROR);
}
//---------------------------------------------------------------------------
STDMETHODIMP cimpmonikercallback::onstopbinding (HRESULT hrstatus, lpcwstr sztext)
{
return (NOERROR);
}
//---------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
class Cimpmonikercallback:public IBindStatusCallback
{
DWORD M_cref;
ibinding* m_pbinding;
Public:
Cimpmonikercallback ();
~cimpmonikercallback ();
stdmethodimp QueryInterface (REFIID riid,void * PPV);
Stdmethodimp_ (ULONG) AddRef ();/{return m_cref++;}
Stdmethodimp_ (ULONG) release ();
stdmethodimp Getbindinfo (dword* pgrfbindf, bindinfo* pbindinfo);
STDMETHODIMP onstartbinding (DWORD grfbscoption, ibinding* pbinding);
stdmethodimp getpriority (long* pnpriority);
stdmethodimp OnProgress (ULONG ulprogress, ULONG ulprogressmax,ulong ulstatuscode, lpcwstr szStatusText);
Stdmethodimp ondataavailable (DWORD grfBSCF, DWORD dwsize, FORMATETC *pfmtetc,stgmedium*);
stdmethodimp onobjectavailable (REFIID riid, iunknown* punk);
stdmethodimp Onlowresource (DWORD dwreserved);
stdmethodimp onstopbinding (HRESULT hrstatus, lpcwstr Sztext);
Lpbindstatuscallback LPFNCB;
pstr sURL;
Pstr sfile;
Char Csysdir[max_path];
DWORD Dwplatform;
};