5 Star 12 Fork 3

safedebug / xcguihelper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
update.h 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
safedebug 提交于 2016-03-21 18:02 . 修改为更加友好的提示方式。
#ifndef update_h__
#define update_h__
#include <WinInet.h>
#pragma comment(lib,"Wininet.lib")
#include <string>
#include <shlwapi.h>
#pragma comment(lib,"shlwapi.lib")
class CNetFile
{
public:
CNetFile()
{
m_hOpen = NULL;
m_hUrl = NULL;
}
void Reset()
{
if (m_hOpen)
{
CloseHandle(m_hOpen);
m_hOpen = NULL;
}
if (m_hUrl)
{
CloseHandle(m_hUrl);
m_hUrl = NULL;
}
m_data = "";
}
void* Read(const wchar_t* pUrl)
{
Reset();
m_hOpen = InternetOpenW(L"Mozilla/4.0 (compatible; Indy Library)",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,NULL);
if (m_hOpen == NULL)
{
return NULL;
}
m_hUrl =InternetOpenUrlW(m_hOpen,pUrl,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE,NULL);
if (m_hUrl == NULL)
{
// wchar_t buffer[4096] = {0};
// DWORD dwCode = 0;
// DWORD dwSize = 0;
// InternetGetLastResponseInfoW(&dwCode,buffer,&dwSize);
// OutputDebugStringW(buffer);
return NULL;
}
char buffer[4096] = {0};
DWORD dwReadBytes = 0;
while (InternetReadFile(m_hUrl,buffer,4096,&dwReadBytes))
{
if (dwReadBytes == 0)
{
break;
}
m_data.append(buffer,buffer+dwReadBytes);
}
return (void*)m_data.data();
}
const char* GetStr()
{
return m_data.c_str();
}
size_t GetSize()
{
return m_data.size();
}
private:
HINTERNET m_hOpen;
HINTERNET m_hUrl;
std::string m_data;
};
bool HasNewVer();
#endif // update_h__
C++
1
https://gitee.com/safedebug/xcguihelper.git
git@gitee.com:safedebug/xcguihelper.git
safedebug
xcguihelper
xcguihelper
master

搜索帮助