rwini.cpp
来自「一个读写INI文件的程序源码」· C++ 代码 · 共 68 行
CPP
68 行
// rwini.cpp: implementation of the Crwini class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <stdlib.h>
#include "rwini.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Crwini::Crwini()
{
}
Crwini::~Crwini()
{
}
bool Crwini::WriteString(LPCTSTR appname, LPCTSTR keyname,char* s, char *fn)
{
CHAR FilePath[255];
GetModuleFileName(NULL,FilePath,255);
(strrchr(FilePath,'\\'))[1] = 0;
strcat(FilePath,fn);
//MessageBox(hWnd,FilePath,"a",0);
WritePrivateProfileString(appname,keyname,s,FilePath);
return 1;
}
int Crwini::GetInt(LPCTSTR appname, LPCTSTR keyname, char *fn)
{
CHAR FilePath[255];
GetModuleFileName(NULL,FilePath,255);
(strrchr(FilePath,'\\'))[1] = 0;
strcat(FilePath,fn);
//MessageBox(hWnd,FilePath,"a",0);
return GetPrivateProfileInt(appname,keyname,1,FilePath);
}
void Crwini::ReadString(char *key, char *s, char *fn,char str[])
{
CHAR FilePath[255];
GetModuleFileName(NULL,FilePath,255);
(strrchr(FilePath,'\\'))[1] = 0;
strcat(FilePath,fn);
::GetPrivateProfileString(key,s,NULL,str,255,FilePath);
}
void Crwini::WriteInt(char *keyname, char *appname, char *fn, int i)
{CHAR FilePath[255];
GetModuleFileName(NULL,FilePath,255);
(strrchr(FilePath,'\\'))[1] = 0;
strcat(FilePath,fn);
char r[10];
_itoa(i,r,10);
WritePrivateProfileString(appname,keyname,r,FilePath);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?