⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stockrefer.cpp

📁 本程序是VC为平台开发的股票资讯系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		return TRUE;
	
	return CWinApp::PreTranslateMessage(pMsg);
}

void CStockReferApp::BeginDownload(int flag, CString m_sURL, 
		CString m_sFile, int sver/* = 0*/)
{
	CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd();
	ASSERT(pFrame);
	CDlgDownload *m_pDlg;
	m_pDlg = new CDlgDownload;
	m_pDlg->m_sURLToDownload = m_sURL;
	m_pDlg->m_sFileToDownloadInto = m_sFile;
	m_pDlg->m_sProxy = pFrame->m_Proxy;
	m_pDlg->m_sPort = pFrame->m_Port;
	
	if (m_pDlg->DoModal() == IDOK)
	{
		if(flag)
			AfxMessageBox(IDS_DWONLOAD_OVER);
		else
		{
			CString strfilen;
			int ki;
			strfilen = m_sFile;
			ki = strfilen.ReverseFind('\\');
			if(ki == -1)
				AfxMessageBox(IDS_DATAOPT_ERROR,MB_ICONSTOP);
			else
			{
				strfilen = strfilen.Left(ki + 1);
				strfilen += _T("newsdat.sch");
				CFile::Remove(strfilen);
				CFile::Rename(m_sFile,strfilen);
				searchver = sver;
				AfxMessageBox(IDS_UPDATE_OVER);
			}
		}
	}
	delete m_pDlg;
}

CString CStockReferApp::GetAppPath()
{
	CString strPath;
	HKEY hkRoot;
	unsigned char szValue[_MAX_PATH];
	LPCTSTR strValueName = _T("AppPath");
	CString strSubKey;
	strSubKey.Format(_T("Software\\%s"),REG_KEY);
	DWORD cb = sizeof(szValue);
	
	if (RegOpenKey(HKEY_LOCAL_MACHINE,strSubKey,&hkRoot) == ERROR_SUCCESS)
	{
		if (RegQueryValueEx(hkRoot,	(LPTSTR)strValueName, NULL, NULL,
				szValue, &cb) == ERROR_SUCCESS){
			strPath = szValue;
		}
	}
    RegCloseKey(hkRoot);

	return strPath;
}

CString CStockReferApp::GetMainVer()
{
	CDaoDatabase data;
	CSerialNum ser;
	try
	{
		data.Open(STOCKDAT_DATABASE,TRUE,FALSE,_T(";PWD=新_NS_???_dat!30讯"));
	}
	catch(CDaoException *ex)
	{
		ex->Delete();
	}
	if(data.IsOpen())
	{
		CVerinfo item(&data);
		try
		{
			CString sql;
			sql.Format(_T("SELECT * FROM list2"));
			item.Open(dbOpenDynaset,sql,0);
			if(!item.IsEOF())
			{
				mainver = ser.Decode(item.m_mainver);
				searchver = ser.Decode(item.m_searchver);
			}
			item.Close();
			data.Close();

			return mainver;
		}
		catch(CDaoException *ex)
		{
			if(item.IsOpen())
				item.Close();
			if(data.IsOpen())
				data.Close();
			ex->Delete();

			return _T("");
		}
	}
	else
		return _T("");
}

BOOL CStockReferApp::RegisterCheck()
{
	long lser;
	CSerialNum num;
	CString gser,sdate,sday,stip,snum,strtip,msgtip;
	int inum;
	lser = num.GetDiskSerialNo();
	m_strSer = num.Encrypt(lser);
	gser = num.GetReg();
	strtip.LoadString(IDS_INPUTREG_NOW);
	CRegDlg m_RegDlg;
	if(m_strSer != gser)
	{
		sdate = num.GetDate();
		if(sdate.GetLength() == 9)
		{
			sday = sdate.Left(4);
			snum = sdate.Mid(6);
		}
		else if(sday != _T("2001") || snum != _T("196"))
		{
			msgtip.Format(IDS_UNREG_ERROR,strtip);
			if(AfxMessageBox(msgtip,MB_ICONSTOP+MB_YESNO+MB_DEFBUTTON2) == IDYES)
			{
				if(m_RegDlg.DoModal() != IDOK)
					return FALSE;
			}
			return FALSE;
		}
		snum = sdate.Mid(4,2);
		inum = atoi(snum);
		inum--;
		if(inum < 0 || inum >= 30 || num.GetReg(0) == _T("1.0.0.1"))
		{
			num.SetReg(_T("1.0.0.1"),0);
			msgtip.Format(IDS_BETAVER_OVER,strtip);
			if(AfxMessageBox(msgtip,MB_ICONSTOP+MB_YESNO+MB_DEFBUTTON2) == IDYES)
			{
				if(m_RegDlg.DoModal() != IDOK)
					return FALSE;
			}
			return FALSE;
		}
		if(inum<10)
			sdate.Format(_T("20010%d196"),inum);
		else
			sdate.Format(_T("2001%d196"),inum);
		lser = atol(sdate);
		sdate = num.Encrypt(lser);
		num.SetReg(sdate);
		stip.Format(IDS_WELCOME_USE,inum);
		sdate.LoadString(AFX_IDS_APP_TITLE);
		sdate = sdate + _T(" ") + stip;
		AfxGetMainWnd()->SetWindowText(sdate);
		strtip.LoadString(IDS_INPUTREG_NOW);
		stip = stip + strtip;
		if(AfxMessageBox(stip,MB_YESNO+MB_ICONINFORMATION) == IDYES)
			m_RegDlg.DoModal();
	}
	else
		HAS_REG = TRUE;
	if(!HAS_REG && TEST_VER != searchver)
	{
		AfxMessageBox(IDS_PLEASE_REG,MB_ICONSTOP);
		return FALSE;
	}

	return TRUE;
}

void CStockReferApp::OldVerCheck()
{
	CString strTotal,strtime,m_UpdateTime,struptime;
	CTime m_today = CTime::GetCurrentTime();
	strtime = m_today.Format(_T("%Y-%m-%d"));
	CString cont;
	m_UpdateTime = GetProfileString(_T("Base"),_T("UpdateTime"));
	if(m_UpdateTime.IsEmpty())
		WriteProfileString(_T("Base"),_T("UpdateTime"),strtime);
	else
	{
		m_today = m_today - CTimeSpan(14,0,0,0);
		struptime = m_today.Format(_T("%Y-%m-%d"));
		if(m_UpdateTime < struptime)
		{
			WriteProfileString(_T("Base"),_T("UpdateTime"),strtime);
			if(AfxMessageBox(IDS_UPDATE_CHECK,MB_YESNO+MB_ICONQUESTION) == IDYES)
			{
				if(!HAS_REG)
				{
					AfxMessageBox(IDS_UNREG_VER);
					return;
				}
				CHttpDown news;

				CWaitDialog waitdlg;
				waitdlg.Show();
				cont = news.GetHttpFileGet(m_strUpdateUrl);

				waitdlg.Close();

				RunUpdate(cont);
			}
		}
	}
}

void CStockReferApp::ShowTipAtStartup()
{
	// CG: This function added by 'Tip of the Day' component.
	CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
	ASSERT(pFrame);
	BOOL m_bTip = pFrame->m_bShowTip;

	CTipDlg dlg;
	if(m_bTip) dlg.DoModal();
}

void CStockReferApp::RunUpdate(LPCTSTR lpszCont)
{
	int ki,i = 0;
	CString cont,vru[4];
	cont = lpszCont;
	if(cont.IsEmpty())
	{
		AfxMessageBox(IDS_CONNECT_ERROR,MB_ICONSTOP);
		return;
	}
	else if(cont == _T("0\n"))
	{
		AfxMessageBox(IDS_NOFIND_NEWVER);
		return;
	}
	else if(cont == _T("-1\n"))
	{
		CSerialNum num;
		CString strDate = num.Encrypt(200100196);
		num.SetReg(strDate);
		num.SetReg(_T("1.0.0.1"),0);
		HAS_REG = FALSE;
		AfxMessageBox(IDS_UNREG_RINGT,MB_ICONSTOP);
		return;
	}

	ki = cont.Find(_T("\n"));
	while(ki != -1 && i < 4)
	{
		vru[i] = cont.Left(ki);
		if(vru[i].IsEmpty())
			break;		
		cont = cont.Mid(ki + 1);
		ki = cont.Find('\n');
		i++;
	}
	if(i == 4)
	{
		CUpdateDlg updatedlg;
		if(SOFT_VER < vru[0])
			updatedlg.soft = 1;
		if(searchver < vru[2])
			updatedlg.searchver = 1;
		if(!updatedlg.soft && !updatedlg.searchver)
		{
			AfxMessageBox(IDS_NOFIND_NEWVER);
			return;
		}

		if(updatedlg.DoModal()==IDOK)
		{
			if(!HAS_REG)
			{
				AfxMessageBox(IDS_NOREG_ERROR);
				return;
			}
			if(updatedlg.usoft)
			{
				CString m_sdown;
				m_sdown.Format(IDS_DOWNLOAD_URL,vru[1]);
				if(AfxMessageBox(m_sdown,MB_YESNO+MB_ICONQUESTION) == IDYES)
				{
					CCJShell sfi;
					CString m_filename;
					sfi.m_strTitle.LoadString(IDS_TOSAVE_FOLDER);
					if(sfi.BrowseForFolder(NULL) == IDOK)
					{
						m_filename.Format(_T("%s\\setup.exe"),sfi.m_strPath);
						BeginDownload(1,vru[1],m_filename);
					}
				}
			}
			else if(updatedlg.usver)
			{
				CString m_filen;
				m_filen.Format(_T("%s\\stockdat_.sdb"),m_strAppPath);
				BeginDownload(0,vru[3],m_filen,atoi(vru[2]));
			}
		}
	}
	else
		AfxMessageBox(IDS_SERVER_DATAERR,MB_ICONSTOP);
}

void CAboutDlg::GetRegInfo(LPCTSTR lpszValueName, CString &strRegInfo)
{
	CString strPath;
	HKEY hkRoot;
	unsigned char szValue[_MAX_PATH];
	LPCTSTR strValueName = lpszValueName;
	strPath.Format(_T("Software\\%s"),REG_KEY);
	LPCTSTR lpSubKey = strPath;
	DWORD cb = sizeof(szValue);
	
	if(RegOpenKey(HKEY_LOCAL_MACHINE,lpSubKey,&hkRoot) == ERROR_SUCCESS)
	{
		if(RegQueryValueEx(hkRoot,	(LPTSTR)strValueName, NULL, NULL,
				szValue, &cb) == ERROR_SUCCESS)
			strRegInfo = szValue;
	}
    RegCloseKey(hkRoot);
}

void CAboutDlg::OnButtonTechnic() 
{
	// TODO: Add your control notification handler code here
	AfxGetMainWnd()->SendMessage(WM_COMMAND,ID_HELP_MAILTO,0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -