1 Star 1 Fork 39

逆风飞扬/ChanlunX

forked from rubikplanet/ChanlunX 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
IniWriter.cpp 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
devdevdevdeep 提交于 2019-03-08 20:45 . 修改文件的编码为utf-8-bom
#include "IniWriter.h"
#include <iostream>
#include <windows.h>
// http://blog.csdn.net/sdcxyz/article/details/10946111
// http://www.codeproject.com/Tips/376146/A-Small-Class-to-Read-INI-Files
CIniWriter::CIniWriter(LPCTSTR szFileName)
{
memset(m_szFileName, 0x00, sizeof(m_szFileName));
memcpy(m_szFileName, szFileName, _tcslen(szFileName)*sizeof(TCHAR));
}
void CIniWriter::WriteInteger(LPCTSTR szSection, LPCTSTR szKey, int iValue)
{
TCHAR szValue[255];
_sntprintf_s(szValue, sizeof(szValue) - 1, TEXT("%d"), iValue);
WritePrivateProfileString(szSection, szKey, szValue, m_szFileName);
}
void CIniWriter::WriteFloat(LPCTSTR szSection, LPCTSTR szKey, float fltValue)
{
TCHAR szValue[255];
_sntprintf_s(szValue, sizeof(szValue) - 1, TEXT("%f"), fltValue);
WritePrivateProfileString(szSection, szKey, szValue, m_szFileName);
}
void CIniWriter::WriteBoolean(LPCTSTR szSection, LPCTSTR szKey, bool bolValue)
{
TCHAR szValue[255];
_sntprintf_s(szValue, sizeof(szValue) - 1, TEXT("%s"), bolValue ? TEXT("True") : TEXT("False"));
WritePrivateProfileString(szSection, szKey, szValue, m_szFileName);
}
void CIniWriter::WriteString(LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szValue)
{
WritePrivateProfileString(szSection, szKey, szValue, m_szFileName);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ivu99/ChanlunX.git
git@gitee.com:ivu99/ChanlunX.git
ivu99
ChanlunX
ChanlunX
master

搜索帮助