📄 dlgstockinfo.cpp
字号:
//////////////////////////////////////////////////////////////////////////
CFile oFile;
CFileException err;
if( !oFile.Open( strFileName, CFile::modeRead, &err ) )
{
AfxMessageBox("Can't open the file , please try again!");
return -1; //_T("打开记录文件失败!"));
}
//////////////////////////////////////////////////////////////////////////
int dwFileSize=oFile.GetLength();
if(dwFileSize > ci_FILE_LEN)
{
CString strLen;
strLen.Format(_T("The File is too long, the lengh is less than %d !"), ci_FILE_LEN);
AfxMessageBox(strLen);
return -2;
}
/*
int i_FileRecordLen = dwFileSize/sizeof(unsigned short);*/
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
HANDLE s_hHeap = NULL;
s_hHeap = HeapCreate(HEAP_NO_SERIALIZE,0,0);
if(s_hHeap == NULL)
{
oFile.Close();
//m_oLock.Unlock();
return -3;
}
if (0<dwFileSize)
{
unsigned char* pBuf =(unsigned char*) HeapAlloc(s_hHeap,0,dwFileSize);
if (!pBuf )
{
oFile.Close();
return -4;
}
//delete the corresponding records.
//////////////////////////////////////////////////////////////////////////
//unsigned char *pBuf=new unsigned char [dwFileSize+1];
const int STR_LEN = 256;
char *chTitle = new char [STR_LEN];
oFile.SeekToBegin();
oFile.Read(pBuf, dwFileSize );
unsigned char* pchMax;
pchMax = pBuf+dwFileSize;
int index=0x522;
pBuf = pBuf+index;
//ST_StockReportInfoList shST_StockReportInfoList;
//ST_StockReportInfoList szST_StockReportInfoList;
while(1)
{
int iOffSet;
mStockDateProcess.FunParseStockTypeInfo(pBuf,&oST_StockReportInfo,&iOffSet);
char chTempCmp[12] ="20070901";
if((oST_StockReportInfo.chSsDate[0]!=0x20)
&&
(memcmp(oST_StockReportInfo.chGxrq,chTempCmp,sizeof(chTempCmp))>0)
)
{
mST_StockReportInfoList.push_back(oST_StockReportInfo);
}
pBuf = pBuf+iOffSet;
if(pBuf >= pchMax)
{
break;
}
}
}
oFile.Close();
HeapDestroy(s_hHeap);
return 0;
}
int DlgStockInfo::ReadRelationData(CString strDir)
{
CString strSh = "shex.tnf";
CString strSz = "szex.tnf";
//read shdata
CString strTemp = strSh;
CString strFileName;
strFileName = strDir+strTemp;//dlg.GetPathName();
//////////////////////////////////////////////////////////////////////////
//int pos = strFileName.ReverseFind('\\');
// CString strTempName = strFileName.Right(pos+1); //find
//CString strTempName = strFileName.Right(8); //find
CString strStockType = "";
if(strTemp == "szex.tnf")
{
strStockType = "深圳";
}
else if(strTemp == "shex.tnf")
{
strStockType = "上海";
}
else
{
AfxMessageBox("找不到文件,请重新找文件");
return -1;
}
mStockDateProcess.GenerateRalationList(strFileName,strStockType,&m_ST_StockNameInfoList);
//read sz data
strTemp = strSz;
strFileName = strDir+strTemp;
strStockType = "";
if(strTemp == "szex.tnf")
{
strStockType = "深圳";
}
else if(strTemp == "shex.tnf")
{
strStockType = "上海";
}
else
{
AfxMessageBox("找不到文件,请重新找文件");
return -2;
}
mStockDateProcess.GenerateRalationList(strFileName,strStockType,&m_ST_StockNameInfoList);
return 0;
}
int DlgStockInfo::ReadBanKuaiData(CString strDir)
{
const int ci_FILE_LEN=24*1024*1024;
const int ci_Len=10;
CString strFileName;
strFileName = strDir +"block.dat";
//////////////////////////////////////////////////////////////////////////
CFile oFile;
CFileException err;
if( !oFile.Open( strFileName, CFile::modeRead, &err ) )
{
AfxMessageBox("Can't open the file , please try again!");
return -1; //_T("打开记录文件失败!"));
}
//////////////////////////////////////////////////////////////////////////
int dwFileSize=oFile.GetLength();
if(dwFileSize > ci_FILE_LEN)
{
CString strLen;
strLen.Format(_T("The File is too long, the lengh is less than %d !"), ci_FILE_LEN);
AfxMessageBox(strLen);
return -2;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
HANDLE s_hHeap = NULL;
s_hHeap = HeapCreate(HEAP_NO_SERIALIZE,0,0);
if(s_hHeap == NULL)
{
oFile.Close();
//m_oLock.Unlock();
return -3;
}
if (0<dwFileSize)
{
unsigned char* pBuf =(unsigned char*) HeapAlloc(s_hHeap,0,dwFileSize);
if (!pBuf )
{
oFile.Close();
return -4;
}
const int STR_LEN = 256;
oFile.SeekToBegin();
oFile.Read(pBuf, dwFileSize );
unsigned char* pchTemp;
unsigned char* pchMax;
pchMax = pBuf+dwFileSize;
int index=0x181;
pBuf = pBuf+index;
//skip
int offset =0;
int iIndexIncre=0;
m_strOutput.Empty();
int loop =0;
while (1)
{
////////
while(*pBuf==0)
{
pBuf++;
}
if(pchMax < pBuf)
{
break;
}
pchTemp = pBuf;
int length =0;
while (*pchTemp++)
{
length++;
}
unsigned char* chTemp=new unsigned char[length+1];
memcpy(chTemp,pBuf,length+1);
CString strBanKuai= chTemp;
delete [] chTemp;
m_strOutput += strBanKuai+"\r\n";
m_COM_Block.InsertString(iIndexIncre,strBanKuai);
iIndexIncre++;
pBuf = pBuf+length;
while(*pBuf ==0)
{
pBuf++;
}
length = (int)((*pBuf)+256* (*(pBuf+1)));
pBuf = pBuf+4;
loop++;
/*
if(loop ==40)
{
int k =0;
}*/
//int* piStockCode = new int[length];
unsigned char chTempCode[7];
for(int i=0;i<length;i++)
{
CString strTemp;
memcpy(chTempCode,pBuf,7);
CString strStockCode = chTempCode;
//CString strStockName = mStockDateProcess.StockCode2StockName(strStockCode,m_ST_StockNameInfoList);
CString strStockName;
//*(piStockCode+i)= atoi((char*)chTempCode);
// strTemp.Format("%.6d\t",*(piStockCode+i));
strTemp.Format("%s %s\t",strStockCode,strStockName);
m_strOutput += strTemp;
const int ciNumber =6;
if(i%ciNumber== ciNumber-1)
{
m_strOutput +="\r\n";
}
pBuf = pBuf+7;
}
//delete[] piStockCode;
m_strOutput += "\r\n\r\n";
}
//mStockDateProcess.WriteFile(m_strOutput);
// UpdateData(FALSE);
}
return 0;
}
void DlgStockInfo::OnBtnBankuai()
{
// TODO: Add your control notification handler code here
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -