📄 ini.h
字号:
// Copyright 1997-98 (c) Iuri Apollonio
// given freely to www.codeguru.com
// Ini.h: interface for the COwnerIni class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_INI_H__4A8E7C07_902F_11D1_8B70_0000B43382FE__INCLUDED_)
#define AFX_INI_H__4A8E7C07_902F_11D1_8B70_0000B43382FE__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include <afxcoll.h>
#include <stdlib.h>
#ifdef _UNICODE
class CFileHelper : public CFile
{
public:
CFileHelper(LPCTSTR strFileName
,int iFileMode) : CFile (strFileName,iFileMode)
{
};
~CFileHelper(){};
void SvrGetLine(BYTE * buff,UINT iMax)
{
int iPos = 0;
while (GetPosition() < GetLength() && iPos < (int)iMax)
{
BYTE c;
Read(&c,1);
if (c != _T('\r') && c!= _T('\n'))
{
{
buff [iPos++] = c;
}
}
else
{
if (iPos == 0)
{
}
else
{
break;
}
}
}
buff[iPos] = 0;
};
void SvrSetLine(const TCHAR * cStr)
{
char buff[MAX_PATH * 10];
DWORD dwSize = WideCharToMultiByte(CP_ACP,
0,(LPCTSTR)cStr,-1,(char*)buff,MAX_PATH * 10,NULL,NULL);
Write (buff,dwSize);
char buff2[2];
buff2[0] = _T('\r');
buff2[1] = _T('\n');
Write (buff2,2);
};
};
#else
#include <fstream.h>
#endif
// -----------------------------------
// Explanation of file structure:
// [A Section]
// A double Field = 0.23123
// A int Field = 132432
// A string Field = This is a string!
// A multicolumn string Field =
// This is a 1st line string鐋
// This is a 2nd line string鐋
// This is a 3rd line string
// [New Section]
#define TRIM(i) i.TrimLeft();i.TrimRight();
class COwnerIni
{
public:
void RemoveMultiLineItem(const int idx);
int FindItem(const int iSection, const TCHAR * cItem, CString &csVal);
int FindMultiItem(const int iSection, const TCHAR * cItem, CString &csVal);
bool RemoveSection(const TCHAR * cSection);
bool IsSection(const int iSection);
int InsertSection(const TCHAR * cSection);
int FindSection(const TCHAR * cSection);
bool SetMultiValue(const TCHAR * cSection, const TCHAR * cItem, const TCHAR * cVal);
bool SetValue(const TCHAR * cSection, const TCHAR * cItem, const COLORREF crVal);
bool SetValue(const TCHAR * cSection, const TCHAR * cItem, const bool bVal);
bool SetValue(const TCHAR * cSection, const TCHAR * cItem, const TCHAR * cVal);
bool SetValue(const TCHAR * cSection, const TCHAR * cItem, const double dbVal);
bool SetValue(const TCHAR * cSection, const TCHAR * cItem, const float fVal);
bool SetValue(const TCHAR * cSection, const TCHAR * cItem, const long lVal);
bool SetValue(const TCHAR * cSection, const TCHAR * cItem, const int iVal);
bool SetValue(const TCHAR * cSection, const TCHAR * cItem, const CRect rcVal);
bool SetValue(const TCHAR * cSection, const TCHAR * cItem, const CPoint ptVal);
bool GetMultiValue(const TCHAR * cSection, const TCHAR * cItem, CString &cVal);
bool GetValue(const TCHAR * cSection, const TCHAR * cItem, COLORREF &crVal);
bool GetValue(const TCHAR * cSection, const TCHAR * cItem, bool &bVal);
bool GetValue(const TCHAR * cSection, const TCHAR * cItem, CString &cVal);
bool GetValue(const TCHAR * cSection, const TCHAR * cItem, double &dbVal);
bool GetValue(const TCHAR * cSection, const TCHAR * cItem, float &fVal);
bool GetValue(const TCHAR * cSection, const TCHAR * cItem, long &lVal);
bool GetValue(const TCHAR * cSection, const TCHAR * cItem, int &iVal);
bool GetValue(const TCHAR * cSection, const TCHAR * cItem, CRect &rcVal);
bool GetValue(const TCHAR * cSection, const TCHAR * cItem, CPoint &ptVal);
void Clear();
bool Write(const TCHAR * cFileName);
bool Read(const TCHAR * cFileName);
COwnerIni();
virtual ~COwnerIni();
public:
CString csLineEnd; //
CStringArray csList;
};
#endif // !defined(AFX_INI_H__4A8E7C07_902F_11D1_8B70_0000B43382FE__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -