ini配置文件讀寫(大華)

以下代碼來自大華工程師所寫,代碼摘自大華工業相機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);

	// 獲取配置文件路徑
	// get configuration file path

	CString GetCfgFile();

	// 獲取鍵值						| get key value
	// 參數列表:	appName	app名稱 | parameters list : application name
	// keySource	子鍵名稱        | subkey 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章