04-05-2013 08:20 AM
Bonjour à tous,
Tout d'abord je m'excuse d'avance si cette question semble bateau pour beaucoup d'entre vous, mais je n'ai pas trouvé de bons exemples sur les fichiers INI.
Mon problème est le suivant :
J'ai un fichier INI déja existant, je veux changer quelques paramètres. Je ne sais pas comment créer mon Handle du fichier INI sans utiliser la fonction Ini_New.
Voici mon code :
GetProjectDir(dirName);
MakePathname(dirName,"config.ini",pathName);
iniText = Ini_New(0);
.................
.................
Ini_PutString(iniText,"partie1","name",NouvelleValeur);
Ini_WriteToFile(iniText,pathName);
où partie1 et name existent déja.
Quand j'éxecute ce code, il écrase le fichier INI déja existant pour en faire un nouveau, avec seulement
[partie1]
name = NouvelleValeur
Pourriez vous m'aider ?
Merci d'avance à tous.
Cordialement
Vincent
Solved! Go to Solution.
04-07-2013 03:59 PM - edited 04-07-2013 04:01 PM
Supposing automatic translation is right ( ) you want to modify some items in an .INI file without loosing existing content. If this is true, you have simply to read file content with Ini_ReadFromFile immediately after creating the handle, so that every modification is made starting from existing file structure.Saving the .INI will produce a file including new, modified and old content.
T = Ini_New (0); Ini_ReadFromFile (T, "myfile.ini"); Ini_Putxxx (T, ...); In_SaveToFile (T, "myfile.ini");
If Google translation failed you may want to translate your question in English by yourself, or post it in the French board
04-11-2013 02:31 AM
Thank you for your answer RobertoBozzolo,
Google translation seems to work very well ! I try just to use Ini_ReadFromFile as you recommend me, and the code works.
Thank you again !
04-11-2013 02:47 AM
You're welcome!
You could mark this post as solved so that future readers know.