update_ini_line

 

Description

Update specified lines of ini file.

Syntax

bool update_ini_line( INIFile & iniFile, LPCSTR lpcszSectionName, LPCSTR lpcszKeyName, LPCSTR lpcszValue )

Parameters

iniFile
[modify]The file you want to update
lpcszSectionName
[input]Name of Section to update
lpcszKeyName
[input]Name of key to update, if equal to NULL, will remove the section .
lpcszValue
[input]Value you want to update of the key, if NULL, will delete the key.

Return

Returns true for success or false not.

Examples

EX1

void update_ini_line_ex1()
{    
    Tree trIni;
 
    INIFile iniFile("NLSF.ini");
    char szSection[] = "Origin Basic Functions";
    if(tree_read_ini_section(trIni, iniFile, szSection ))
    {
        out_tree(trIni);
        trIni.OriginBasicFunctions.AddTextNode("Func1", "Func1");
        
        //replace "Func1" with "Func2" 
        if( update_ini_line(iniFile,szSection,"Func1","Func2") )
                out_str("update successfully");
        else
                out_str("fail to update");
   } 
}

Remark

See Also

tree_read_ini_section

header to Include

origin.h

Reference