伪代码如下:/*
结构体1
*/
typedef struct tagFileHeader
{
// ...
}FileHeader;
/*
结构体2
*/
typedef struct tagFileDocument
{
// ...
}FileDocument;
/*
结构体3
*/
typedef struct tagFileTail
{
// ...
}FileTail;
/*
单个串口的设置信息
*/
class CComPortInfo
{
public:
int m_nIndex; // 默认下标
CString m_strVender; // 厂家
CString m_strType; // 型号
int m_nBaudRate; // 比特率
int m_nStopBit; // 停止位
int m_nDateBit; // 数据位
CString m_strVerify; // 校验位
CString m_strHardOption; // 硬件选项
};///////////////////////////////////////////////////////////////////////////*
数据管理中心类
*/
class CDateManager
{
public:
int m_nComCount; // 串口个数
CComPortInfo *m_pComInfo; // 单个串口的配置
FileHeader *m_pFileHeader; // 文件头
FileDocument *m_pFileDocument; // 内容
FileTail *m_pFileTail; // 文件尾
};CDateManager这个类的实例,有没有办法保存起来为配置文件,下次直接读取它?

解决方案 »

  1.   

    保存兼容的INI文件里,或者保存在在注册表里;16位机一般保存在INI文件,32位的一般直接保存在注册表里
      

  2.   

    百度查查 CObject::Serialize(CArchive& ar)
      

  3.   

    借用MFC的串行化思想,关键字:Serialize(CArchive& ar)
    很容易做的,并且调用起来很方便
      

  4.   

    给你一个简单的示例: 
    CString   strSection               =   "My   Section "; 
          CString   strStringItem         =   "My   String   Item "; 
          CString   strIntItem               =   "My   Int   Item ";       CWinApp*   pApp   =   AfxGetApp();       pApp-> WriteProfileString(strSection,   strStringItem,   "test ");       CString   strValue; 
          strValue   =   pApp-> GetProfileString(strSection,   strStringItem); 
          ASSERT(strValue   ==   "test ");       pApp-> WriteProfileInt(strSection,   strIntItem,   1234); 
          int   nValue; 
          nValue   =   pApp-> GetProfileInt(strSection,   strIntItem,   0); 
          ASSERT(nValue   ==   1234);