读:
GetPrivateProfileString()
DWORD WINAPI GetPrivateProfileString(
__in LPCTSTR lpAppName,
__in LPCTSTR lpKeyName,
__in LPCTSTR lpDefault,
__out LPTSTR lpReturnedString,
__in DWORD nSize,
__in LPCTSTR lpFileName
);
Example:
//ini文件
CString strIniFileName;
//文本文件名
CString strTextFileName;
//文件状态
CString strTextFlieState;
GetPrivateProfileString(_T("file"),_T("text_file"),NULL,strTextFileName.GetBuffer(254),254,strIniFileName);
GetPrivateProfileString(_T("file"),_T("state"),_T("0"),strTextFlieState.GetBuffer(2),2,strIniFileName);
strTextFileName.ReleaseBuffer();
strTextFlieState.ReleaseBuffer();
写:
WritePrivateProfileString()
BOOL WINAPI WritePrivateProfileString(
__in LPCTSTR lpAppName,
__in LPCTSTR lpKeyName,
__in LPCTSTR lpString,
__in LPCTSTR lpFileName
);
Example:
//ini文件
CString strIniFileName;
WritePrivateProfileString(_T("file"),_T("state"),_T("1"),strIniFileName);