程序所在的文件夹如"c:\\set.ini”
[PARAMS]
time1=8:00
mac1=50e549ab4492 //ini文件的格式如上
CString Readfile(CString strSetion,CString strSubject,CString strFilename) //参数对应上面的例子:
[PARAMS]、time1、set.ini 三个参数
{ TCHAR buf[MAX_PATH]; TCHAR path[MAX_PATH]; CString strpath; CString strname; int ren=GetModuleFileName(NULL,path,MAX_PATH); strpath=path; ren=strpath.ReverseFind(_T('\\')); strpath.Delete(ren,strpath.GetLength()-ren); strpath=strpath+"\\"+strFilename; ren=GetPrivateProfileString(strSetion,strSubject,0,buf,MAX_PATH,strpath); if(!ren) renturn NULL; strname.Format("%s",buf); return strname; }int Writefile(CString strSetion,CString strSubject,CString &strfile,CString strFilename)//
{ TCHAR buf[MAX_PATH]; TCHAR path[MAX_PATH]; CString strpath; CString strname; int ren=GetModuleFileName(NULL,path,MAX_PATH); strpath=path; ren=strpath.ReverseFind(_T('\\')); strpath.Delete(ren,strpath.GetLength()-ren); strpath=strpath+"//"+strFilename; ren=WritePrivateProfileString(strSetion,strSubject,strfile,strpath); if(!ren) return 0; return 1;}