⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rwini.cpp

📁 一个读写INI文件的程序源码
💻 CPP
字号:
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -