LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Handle de fichier INI sans Ini_New

Solved!
Go to solution

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

 

0 Kudos
Message 1 of 4
(3,099 Views)
Solution
Accepted by vincentk

Supposing automatic translation is right ( Smiley Surprised ) 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 Smiley Wink you may want to translate your question in English by yourself, or post it in the French board

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 4
(3,084 Views)

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 !

0 Kudos
Message 3 of 4
(3,054 Views)

You're welcome!

 

You could mark this post as solved so that future readers know.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 4
(3,051 Views)