一·写入ini文件
1·写入字符串至ini文件
BOOL WritePrivateProfileString(
  LPCTSTR
lpAppName// pointer to section name
  LPCTSTR lpKeyName// pointer to key name
  LPCTSTR lpString,   // pointer to string to add
  LPCTSTR lpFileName  // pointer to initialization filename
);
参数含义:lpAppName:小节名
lpKeyName:小节下的条目名
lpString:该条目的字符串值
lpFileName:ini文件的目录
WritePrivateProfileString("Comm","Name","Andy",IniFile);
 
2.写入数值至ini文件
先将数值转化至字符串再进行写入
 
二.读取ini文件
1.读取字符串
DWORD GetPrivateProfileString(
  LPCTSTR
lpAppName,        // points to section name
  LPCTSTR lpKeyName,        // points to key name
  LPCTSTR lpDefault,        // points to default string
  LPTSTR lpReturnedString// points to destination buffer
  DWORD nSize,              // size of destination buffer
  LPCTSTR lpFileName        // points to initialization filename
);
 
CString PassLog;
 GetPrivateProfileString("Comm","PassLog","C:\\CameraPass.Log",PassLog.GetBuffer(MAX_PATH),MAX_PATH, IniFile);  
 PassLog.ReleaseBuffer();
 
2.读取整数
UINT GetPrivateProfileInt(
  LPCTSTR
lpAppName// address of section name
  LPCTSTR lpKeyName// address of key name
  INT nDefault,       // return value if key name is not found
  LPCTSTR lpFileName  // address of initialization filename
);
int m_RedR=GetPrivateProfileInt("Comm","RR",200,IniFile);