以下代码来自大华工程师所写,代码摘自大华工业相机sdk
代码很简洁,也有很多注释,所以分享出来:
来看头文件:
// Cfg.h: interface for the CCfg class.
//
// 功能描述:配置功能,一般根据读取配置决定是否显示某配置项;
// Function Description: configuration function. Generally, whether to display a configuration item depends on the read configuration;
#if !defined(CONFIG)
#define CONFIG
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CConfig
{
typedef enum
{
MAX_VALUE_LEN = 300, //< 每个键值最大长度 | maximum length per key
}ENUM_LIMIT;
public:
//! 构造、析构函数
// construct、destructor function
CConfig();
CConfig(CString strFile);
virtual ~CConfig();
// 设置配置文件路径
// Set configuration path
void SetCfgFile(CString strFile);
//