⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inifile.h

📁 能够对INI文件方便的读写
💻 H
字号:
// IniFile.h: interface for the CIniFile class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_INIFILE_H__YangZeQuan_163_Com__INCLUDED_)
#define AFX_INIFILE_H__YangZeQuan_163_Com__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <stdlib.h>
#include <Windows.h>

class CIniFile
{
public:
	CIniFile();
	virtual ~CIniFile();
	
	// 文件
	BOOL	SetFileName(LPCTSTR pszFileName);
	LPCTSTR	GetFileName() const;

	BOOL	SetFileNameByCurDir(LPCTSTR pszTitleName = NULL);
	BOOL	SetFileNameByExeDir(LPCTSTR pszTitleName = NULL);

	// Section
	BOOL	SetSection(LPCTSTR pszSection);
	LPCTSTR	GetSection() const;
	BOOL    DeleteSection(LPCTSTR pszSection);

#ifdef _MFC_VER
	int GetAllSection(CStringArray& arrSection);
	int GetAllKey(CStringArray& arrKey);
#endif

	// Key
	BOOL    DeleteKey(LPCTSTR pszKey);
	
	BOOL	WriteString(LPCTSTR pszKey, LPCTSTR pszValue);
	BOOL	WriteInt(LPCTSTR pszKey, int iValue);
		
	// 取出一个值,如果原来没有此值,则得到的是默认值
	// 如果 bWrite为TRUE, 再将该值保存到文件中
	LPCTSTR GetString(LPCTSTR pszKey, LPCTSTR pszDefult = _T(""), BOOL bWrite = FALSE );
	BOOL   GetString(LPCTSTR pszKey, LPCTSTR pszDefult, LPTSTR pszValue, int iSize);
	int    GetInt(LPCTSTR pszKey, int iDefault = 0, BOOL bWrite = FALSE);
	
private:
	TCHAR m_szFileName[MAX_PATH+1];
	TCHAR m_szSection[MAX_PATH+1];
	TCHAR m_szTempValue[MAX_PATH+1];

public: // 辅助工具函数
#ifdef _MFC_VER
	static int StringSplit(const CString& strSource, const CString& strSplit, CStringArray& arrResult, BOOL bTrim = TRUE);
	static int StringSplitEx(LPCTSTR pszSource, LPCTSTR pszMultiSplit, CStringArray &arrResult, BOOL bTrim = TRUE);
#endif	
	static BOOL CreateDirectoryEx(LPCTSTR pszPath);
};

#endif // !defined(AFX_INIFILE_H__YangZeQuan_163_Com__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -