本文整理汇总了C++中CInternet::DownloadEntireFileToDisk方法的典型用法代码示例。如果您正苦于以下问题:C++ CInternet::DownloadEntireFileToDisk方法的具体用法?C++ CInternet::DownloadEntireFileToDisk怎么用?C++ CInternet::DownloadEntireFileToDisk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CInternet
的用法示例。
在下文中一共展示了CInternet::DownloadEntireFileToDisk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Initialize
BOOL Initialize(WCHAR* u16_Url, WCHAR* u16_LocalFile, DWORD u32_Blocksize)
{
mu32_BlockSize = u32_Blocksize;
mu32_Cache = 0;
if (!mi_Internet.LoadWininet())
{
mi_Error.Set(FDIERROR_LOAD_WININET_DLL,0,0);
return FALSE;
}
// Sets Username, Password, Server, UrlPath, Port, ServiceType
DWORD u32_ApiErr;
if (u32_ApiErr = mi_Internet.SetUrl(u16_Url))
{
mi_Error.Set(FDIERROR_INTERNET, u32_ApiErr,0);
return FALSE;
}
BOOL b_Offline;
if (u32_ApiErr = mi_Internet.ConnectServer(&b_Offline))
{
if (b_Offline) mi_Error.Set(FDIERROR_MSIE_OFFLINE, u32_ApiErr, 0);
else mi_Error.Set(FDIERROR_INTERNET, u32_ApiErr, 0);
return FALSE;
}
if (u32_Blocksize > 0) // Extract via memory blocks
{
#if _TraceInternet
CTrace::TraceW(L"*** Starting URL extraction. Loading blocks of %d Bytes to memory", u32_Blocksize);
#endif
// Minimum 50 kB
// WARNING: Blocks smaller than 250 kB result in a very bad performance (see above)
mu32_BlockSize = max(mu32_BlockSize, 50000);
mi_FirstBlock.Init(mu32_BlockSize, CacheCallback, 'F','i'); // Block "Fi"
mi_Cache[0]. Init(mu32_BlockSize, CacheCallback, '1'); // Block "1A" and "1B"
mi_Cache[1]. Init(mu32_BlockSize, CacheCallback, '2'); // Block "2A" and "2B"
}
else // Extract via a file which is entirely saved to disk, then extracted
{
u32_ApiErr = mi_Internet.CreateDownloadFileW(u16_LocalFile);
if (u32_ApiErr)
{
mi_Error.Set(FDIERROR_TARGET_FILE, u32_ApiErr,0);
return FALSE;
}
DWORD u32_Status;
if (u32_ApiErr = mi_Internet.DownloadEntireFileToDisk(&u32_Status))
{
mi_Error.Set(FDIERROR_INTERNET, u32_ApiErr, u32_Status);
return FALSE;
}
}
return TRUE;
}