📄 checknewversion.cpp
字号:
//////////////////////////////////////////////////////////////////////
// FileFury
// Copyright (c) 2000 Tenebril Incorporated
// All rights reserved.
//
// This source code is governed by the Tenebril open source
// license (http://www.tenebril.com/developers/opensource/license.html)
//
// For more information on this and other open source applications,
// visit the Tenebril OpenSource page:
// http://www.tenebril.com/developers/opensource
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <afxinet.h>
#include "CheckNewVersion.h"
CCheckNewVersion::CCheckNewVersion(CWnd *parent, LPCTSTR versionfile,
int currentversion, LPCTSTR url)
{
VersionFile = versionfile;
CurrentVersion = currentversion;
URL = url;
ParentWnd = parent;
}
CCheckNewVersion::~CCheckNewVersion()
{
}
void CCheckNewVersion::Run()
{
int Newest = WebVersion();
if(Newest > CurrentVersion)
{
CCheckNewVersionDlg CheckDlg(ParentWnd, URL);
CheckDlg.DoModal();
}
else
ParentWnd->MessageBox("You have the latest version of the software.",
"New version", MB_ICONEXCLAMATION | MB_OK);
return;
}
int CCheckNewVersion::WebVersion()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CHttpFile *HttpFile;
char FileData[2050];
DWORD StatusCode;
int numread;
CInternetSession InetSession("CheckNewVersion 1.0");
try
{
HttpFile = (CHttpFile *)InetSession.OpenURL(VersionFile, 1,
INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_RELOAD);
if(!HttpFile)
return -1;
if(!HttpFile->QueryInfoStatusCode(StatusCode))
{
delete HttpFile;
return -1;
}
if(StatusCode > 299)
{
delete HttpFile;
return -1;
}
}
catch(CInternetException *pInetExcept)
{
pInetExcept->m_dwError;
delete HttpFile;
return -1;
}
memset((void *)FileData, 0, sizeof(char) * 2050);
numread = HttpFile->Read(FileData, 2048);
FileData[numread] = '\0';
HttpFile->Close();
delete HttpFile;
return atoi(FileData);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -