| 2.2.5.2.13 INIFile::WriteStringWriteString
 DescriptionWrites a string value for a given keyname in a given section
 Syntaxvoid WriteString( LPCSTR lpcszSection, LPCSTR lpcszKey, LPCSTR lpcszValue ) Parameters lpcszSection[input] section name lpcszKey[input] key name, if equal to NULL, will remove the section . lpcszValue[input] the string that needs to be written, if NULL, will delete the key.
 ReturnExamplesEX1
 void INIFile_WriteString_ex1()
{
    // writes "***" into all the key values in all sections
    string str = "***";
    INIFile ini("EBGIF2.ini", FALSE);
    StringArray saSections, saKeys;
    ini.GetSectionNames(saSections);
    for( int iSection = 0; iSection < saSections.GetSize(); iSection++ )
    {
        printf("%s\n", saSections[iSection]);
        ini.GetKeyNames(saKeys, saSections[iSection]);
        for( int iKey = 0; iKey < saKeys.GetSize(); iKey++ )
        {
            ini.WriteString(saSections[iSection], saKeys[iKey], str);
            string str1 = ini.ReadString(saSections[iSection], saKeys[iKey], str);
            printf("    %s = %s\n", saKeys[iKey], str1);
        }
    }
}EX2
 //Remove "Other" section from origin.ini
void INIFile_WriteString_ex2()
{      
    INIFile iniFile("Origin.ini");
    iniFile.WriteString("OTHER", NULL, NULL);
    
    Tree trIni;
    if(tree_read_ini(trIni, iniFile))
        out_tree(trIni);
}RemarkSee AlsoHeader to Includeorigin.h
 |