betway官方电子书籍教程中心网文荟萃客户留言繁體中文
设为首页
加入收藏
联系我们
您当前的位置:betway官方 -> 教程中心 -> 编程经验 -> C++ Builder -> 教程内容 退出登录 betway官方,
栏目导航
· 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的源代码(六...

一段能够下载文件的源代码
betway官方,作者:佚名来源:本站整理发布时间: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 2021 betway官方. All Rights Reserved .
浙ICP备05047688号