www.pudn.com > Tempe_Computer.rar > computesave.cpp


 
// computesave.cpp : implementation of the CWzdInfo class 
// 
 
 
#include "stdafx.h" 
#include "computesave.h" 
 
///////////////////////////////////////////////////////////////////////////// 
// computesave 
 
IMPLEMENT_SERIAL( computesave, CObject, 0 ) 
 
 
 computesave::computesave() 
{  BYTE BB; 
 
    conver_bit="8"; 
     GNDORVCC=0; 
	 resister_vol="47"; 
 
for(BB=0;BB<160;BB++) 
{    ADC_VOL[BB]=""; 
     ADC_VOL[BB]=""; 
} 
} 
 
computesave::~computesave() 
{ 
	 
} 
 
void computesave::Serialize( CArchive& ar ) 
{  BYTE BB; 
    CObject::Serialize( ar ); 
    if( ar.IsStoring() ) 
	{ UINT dd=54445; 
	   	ar<>dd; 
	 if(dd!=54445){::MessageBox(AfxGetMainWnd()->m_hWnd,"file error!",NULL,MB_ICONERROR);return;} 
	    ar>>GNDORVCC; 
	    ar>>conver_bit; 
		ar>>resister_vol; 
	   for(BB=0;BB<160;BB++) 
	   {ar>>TEMP_VOL[BB]; 
	    ar>>ADC_VOL[BB]; 
	   } 
	} 
	 
} 
 
void computesave::save() 
{   CString path; 
	path=Getpath(0); 
	CFile file; 
	if(path!="0") 
 if (file.Open(path, CFile::modeCreate|CFile::modeWrite ) ) 
	{ 
        CArchive ar(&file, CArchive::store); 
        Serialize( ar ); 
        ar.Close(); 
        file.Close() ; 
	} 
} 
 
bool computesave::open() 
{	CFile file; 
     CString path; 
	path=Getpath(1); 
    if(path!="0") 
 if (file.Open(path,CFile::modeRead)) 
  { 
      CArchive ar(&file, CArchive::load); 
     Serialize( ar ); 
      ar.Close(); 
      file.Close(); 
	  return TRUE; 
  }	 
 else {return FALSE;} 
 
} 
CString computesave::Getpath(bool openorsave) 
{  
  CFileDialog filedig( openorsave,  NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL,  NULL ); 
	CString path;//=filepath+"ico\\"; 
          // filedig.m_ofn.lpstrInitialDir=path; 
		   if(openorsave)filedig.m_ofn.lpstrTitle   =  _T("用户卡信息输入"); 
		    else filedig.m_ofn.lpstrTitle   =  _T("用户卡信息输出"); 
		   filedig.m_ofn.lpstrFilter = _T(".tdt\0*.tdt\0 "); 
         int nStructSize = 0; 
	DWORD dwVersion, dwWindowsMajorVersion, dwWindwosMinorVersion; 
	dwVersion = GetVersion(); 
	dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); 
	dwWindwosMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); 
	if(dwVersion < 0x80000000) 
	{ 
		nStructSize = 88;   //2k,xp下显示新的版本 
	} 
	else 
	{ 
		nStructSize = 76;  //98下显示老版本,如图1 
	} 
	filedig.m_ofn.lStructSize = nStructSize;  //------用来检测目前的操作系统的版本信息 
 
     if(filedig.DoModal()==IDOK) 
	 { 
	  
	 path=filedig.GetPathName(); 
	 return path; 
	 } 
	 else return "0"; 
 
}