okutil_write_file_section
Description
Works like WritePrivateProfileString, also support comments for section and section without key entry
Syntax
int okutil_write_file_section( LPCSTR lpcszFilename, LPCSTR lpcszSecName, LPCSTR lpcszText, LPCSTR lpcszComments = NULL, int nCommentStyle = 0 )
Parameters
- lpcszFilename
- [input] fullpath file name
- lpcszSecName
- [input] section name, [] not needed
- lpcszText
- [input] content of the section,
- = "" will result in empty section,
- = NULL will remove section
- lpcszComments
- [input] Comments of the section. Note: if you want to write a file section in UTF16, set comment to "UTF16".
- nCommentStyle
- [input] if 0, comment will be written right after section name; if 1, comment will be written right below section name with ; mark
Return
The file size.
Examples
EX1
void Okutil_write_file_section()
{
string strFile = "C:\junk.txt";
// Write a section with comments into file,
int nn = okutil_write_file_section(strFile,"SQL","select * from files","select any from file");
nn = okutil_write_file_section(strFile,"MySQL","select name from files","select name from file");
string strSec, strComments;
okutil_read_file_section(strFile, "SQL", &strSec, &strComments);
vector<string> vsSecNames;
okutil_get_file_sections(strFile, &vsSecNames);
}
Remark
See Also
okutil_get_file_sections, okutil_read_file_section
header to Include
origin.h
Reference
|