BOOL WritePrivateProfileString(
LPCTSTR lpAppName,
LPCTSTR lpKeyName,
LPCTSTR lpString,
LPCTSTR lpFileName
);
The meaning of each parameter.
LPCTSTR lpAppName is a field name in the INI file.
LPCTSTR lpKeyName is a key name under lpAppName, commonly known as variable name.
LPCTSTR lpString is a key value, that is, the value of a variable, but it must be of type lpctstr or CString.
LPCTSTR lpFileName is the complete INI file name. If the full pathname is not specified, the file will be found in the windows directory (default). If the file cannot be found, the function will create it in the windows directory.
CString strName,strTemp
int nAge
StrName= "Zhang San";
nAge = 12;
* WritePrivateProfileString(" StudentInfo "," Name ",strName," c:\ \ stud \ \ student . ini ");
At this point, the contents in the c: \ study \ student.ini file are as follows:
[Student Information]
Name = Zhang San
To save a student's age, simply change the integer value to the character type:
strTemp。 Format ("%d", nage);
* WritePrivateProfileString(" StudentInfo "," Age ",strTemp," c:\ \ stud \ \ student . ini ");