必威注册电子书籍教程中心网文荟萃客户留言繁體中文
设为首页
加入收藏
联系必威注册
您当前的位置:92动力网 -> 教程中心 -> 编程经验 -> C++ Builder -> 教程内容 退出登录 用户管理
栏目导航
· Visual Basic· Delphi
· Visual C++· C++ Builder
· JAVA DotNet· 其他相关
热门教程
· 如何在Visual Basic...
· 使用Visual Basic操...
· 使用VB6.0设计Activ...
· VB动态调用外部函数...
· 建立一个程序员自己...
· 如何编写高质量的VB...
· [图文] 为更新到Visual Bas...
· 再谈在VB中调用VC++...
· 用VB语言编程实现JP...
· 用DTS实现SQL数据库...
相关教程
· ★★★敬请留意★★...
· ★★★敬请留意★★...
· ★★★敬请留意★★...
· ★★★敬请留意★★...
· ★★★敬请留意★★...
· 思科透露800MB的源代...
· 获取cookie的源代码...
· Funlove.4608的源代...
· [图文] 一个简单计数器的源...
· 一个BBS的源代码(六...

一段能够下载文件的源代码
作者:佚名聽聽来源:本站整理聽聽发布时间:2005-12-29 17:39:48聽聽发布人:admin

减小字体 增大字体




聽聽// 在工程中加入 Urlmon.lib

//---------------------------------------------------------------------------

#include
#include
#include
#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:tempicon.zip",dwResv,objImpCallback.lpfnCB);

聽聽if(hRet==S_OK)
聽聽聽聽MessageBox(NULL,"成功下载文件","",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 娄娄 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* pstgmed);
聽聽聽聽聽聽聽聽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;
};聽

[] [返回上一页] [打 印] [收 藏]
∷相关教程评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 网站地图 - 管理登录
Copyright 2019 必威注册. All Rights Reserved .
浙ICP备05047688号