1 Star 0 Fork 39

cxdmax/ChanlunX

forked from rubikplanet/ChanlunX 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
IniWriter.cpp 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
rubikplanet 提交于 2021-10-09 22:16 . 使用std::vector
#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/cxdmax/ChanlunX.git
git@gitee.com:cxdmax/ChanlunX.git
cxdmax
ChanlunX
ChanlunX
master

搜索帮助