Modifies or adds a key to the currently loaded configuration file.

  • If the key exists then its value is modified to the new keyValue and the keyComment is updated if it is not blank.
  • If the key does not exist then it is added to the section with the specified value and comment.
  • The INI file is saved after the modification to the hard drive directory.

Parameters:

sectionName

The name of the section where the key exists or will be added.

keyName:

The key identifier.

keyValue

The value associated with the key.

keyComment

The comment to precede the key in the INI file.

Return Value:        

Success or failure.    If the function fails use GetErrorMessage to get the specific errors associated with the failure.

Prototype Signature:

success IniFileModifyKey(const charsectionNameconst char *keyNameconst charkeyValueconst charkeyComment);


An example of how this function could be used is shown below.

#include <malloc.h>
#include <string.h>
#include "api.h"

int main()
{
   success successful;
   int bufferLen = 1024;
   char* responseBuffer = malloc(bufferLen);
   int bytesCopied;

   //Initialize the library with a specific configuration file
   successful = IniFileModifyKey("FCM-1","IpAddress","10.10.1.1","The address under the new IP addressing scheme");
   if(!successful)
   {
       //Get the comma separated list of errors that have occured
       bytesCopied = GetErrorMessage(responseBuffer, bufferLen);
       if(bytesCopied > 0)
           printf(responseBuffer);
   }
}