伪代码如下:/*
结构体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
*/
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这个类的实例,有没有办法保存起来为配置文件,下次直接读取它?
很容易做的,并且调用起来很方便
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);