<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Problem mit INI Files]]></title><description><![CDATA[<p>servus,</p>
<p>ich hab ein Problem beim Einlesen von INI-Files. Und zwar hab ich in meinem Programm 2 Profile, deren Einstellungen in einem INI-File gespeichert werden. Gespeichert werden die Daten richtig. Wenn ich das Programm starte, dann werden die Einstellungen auch richtig eingelesen. Wenn ich im Programm dann das Profil wechsle, muss die INI-Datei neu eingelesen werden, da für Profil 1&amp;2 die gleichen Textboxen etc verwendet werden. Dann liest er allerdings nur noch die erste Einstellung ein. In die restlichen Felder schreibt er 0 (der Defaultwert).</p>
<pre><code class="language-cpp">//INI File
[Profil1-RGBStart]
R=12
G=12
B=102
[Profil1-RGBEnde]
R=12
G=12
B=12
[Profil2-RGBStart]
R=123
G=1
B=2
[Profil2-RGBEnde]
R=3
G=4
B=5

//Funktion zum Einlesen
readINI(1 oder 2);

//readINI
void __fastcall Tmain::readINI(int profil)
{
	char *ch = new char[3];
	if(profil == 1)
	{
		GetPrivateProfileString(&quot;Profil1-RGBStart&quot;,&quot;R&quot;,0,ch,100,inipfad);
		gr-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil1-RGBStart&quot;,&quot;G&quot;,0,ch,100,inipfad);
		gg-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil1-RGBStart&quot;,&quot;B&quot;,0,ch,100,inipfad);
		gb-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil1-RGBEnde&quot;,&quot;R&quot;,0,ch,100,inipfad);
		kr-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil1-RGBEnde&quot;,&quot;G&quot;,0,ch,100,inipfad);
		kg-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil1-RGBEnde&quot;,&quot;B&quot;,0,ch,100,inipfad);
		kb-&gt;Text = ch;
		ch = &quot;&quot;;
		delete [] ch;
	}
	else
	{
		GetPrivateProfileString(&quot;Profil2-RGBStart&quot;,&quot;R&quot;,0,ch,100,inipfad);
		gr-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil2-RGBStart&quot;,&quot;G&quot;,0,ch,100,inipfad);
		gg-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil2-RGBStart&quot;,&quot;B&quot;,0,ch,100,inipfad);
		gb-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil2-RGBEnde&quot;,&quot;R&quot;,0,ch,100,inipfad);
		kr-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil2-RGBEnde&quot;,&quot;G&quot;,0,ch,100,inipfad);
		kg-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil2-RGBEnde&quot;,&quot;B&quot;,0,ch,100,inipfad);
		kb-&gt;Text = ch;
		ch = &quot;&quot;;
		delete [] ch;
	}
}
</code></pre>
<p>Also wie gesagt, beim ersten Aufruf geht alles. Nur danach nicht mehr.<br />
Wodran liegt das?</p>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/182298/problem-mit-ini-files</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 21:06:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/182298.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 23 May 2007 13:47:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit INI Files on Wed, 23 May 2007 13:47:07 GMT]]></title><description><![CDATA[<p>servus,</p>
<p>ich hab ein Problem beim Einlesen von INI-Files. Und zwar hab ich in meinem Programm 2 Profile, deren Einstellungen in einem INI-File gespeichert werden. Gespeichert werden die Daten richtig. Wenn ich das Programm starte, dann werden die Einstellungen auch richtig eingelesen. Wenn ich im Programm dann das Profil wechsle, muss die INI-Datei neu eingelesen werden, da für Profil 1&amp;2 die gleichen Textboxen etc verwendet werden. Dann liest er allerdings nur noch die erste Einstellung ein. In die restlichen Felder schreibt er 0 (der Defaultwert).</p>
<pre><code class="language-cpp">//INI File
[Profil1-RGBStart]
R=12
G=12
B=102
[Profil1-RGBEnde]
R=12
G=12
B=12
[Profil2-RGBStart]
R=123
G=1
B=2
[Profil2-RGBEnde]
R=3
G=4
B=5

//Funktion zum Einlesen
readINI(1 oder 2);

//readINI
void __fastcall Tmain::readINI(int profil)
{
	char *ch = new char[3];
	if(profil == 1)
	{
		GetPrivateProfileString(&quot;Profil1-RGBStart&quot;,&quot;R&quot;,0,ch,100,inipfad);
		gr-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil1-RGBStart&quot;,&quot;G&quot;,0,ch,100,inipfad);
		gg-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil1-RGBStart&quot;,&quot;B&quot;,0,ch,100,inipfad);
		gb-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil1-RGBEnde&quot;,&quot;R&quot;,0,ch,100,inipfad);
		kr-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil1-RGBEnde&quot;,&quot;G&quot;,0,ch,100,inipfad);
		kg-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil1-RGBEnde&quot;,&quot;B&quot;,0,ch,100,inipfad);
		kb-&gt;Text = ch;
		ch = &quot;&quot;;
		delete [] ch;
	}
	else
	{
		GetPrivateProfileString(&quot;Profil2-RGBStart&quot;,&quot;R&quot;,0,ch,100,inipfad);
		gr-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil2-RGBStart&quot;,&quot;G&quot;,0,ch,100,inipfad);
		gg-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil2-RGBStart&quot;,&quot;B&quot;,0,ch,100,inipfad);
		gb-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil2-RGBEnde&quot;,&quot;R&quot;,0,ch,100,inipfad);
		kr-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil2-RGBEnde&quot;,&quot;G&quot;,0,ch,100,inipfad);
		kg-&gt;Text = ch;
		ch = &quot;&quot;;
		GetPrivateProfileString(&quot;Profil2-RGBEnde&quot;,&quot;B&quot;,0,ch,100,inipfad);
		kb-&gt;Text = ch;
		ch = &quot;&quot;;
		delete [] ch;
	}
}
</code></pre>
<p>Also wie gesagt, beim ersten Aufruf geht alles. Nur danach nicht mehr.<br />
Wodran liegt das?</p>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1290738</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1290738</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Wed, 23 May 2007 13:47:07 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Wed, 23 May 2007 13:58:02 GMT]]></title><description><![CDATA[<p>Ich kenne die Funktion GetPrivateProfileString() nicht im Detail.</p>
<p>Was ich dir vorschlagen kann ist, die TIniFile/TMemIniFile-Klasse der VCL für so etwas zu nutzen. Da sind solche Ini-Zugriffe schön gekapselt. Vielleicht löst das schon dein Problem. Oder spricht etwas gegen die Verwendung der entsprechenden Klassen?</p>
<p>Keep smilin'<br />
vi.p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1290750</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1290750</guid><dc:creator><![CDATA[vi.p]]></dc:creator><pubDate>Wed, 23 May 2007 13:58:02 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Wed, 23 May 2007 16:16:23 GMT]]></title><description><![CDATA[<p>blöde Frage, aber TIniFile gibts bei mir nicht. Welche Funktion muss ich beim Installieren auswählen?<br />
Bild<br />
<a href="http://kn4ck3r.kn.ohost.de/borland.jpg" rel="nofollow">http://kn4ck3r.kn.ohost.de/borland.jpg</a></p>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1290871</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1290871</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Wed, 23 May 2007 16:16:23 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Wed, 23 May 2007 16:48:19 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>TInifile ist mit Sicherheit auch in der Builder-Version dabei (ohne das du beim Setup etwas spezielles auswählen must). Such mal in der Builder-Hilfe danach.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1290906</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1290906</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 23 May 2007 16:48:19 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Wed, 23 May 2007 16:57:49 GMT]]></title><description><![CDATA[<p>das hatte ich gemacht, als ich den Post obendrüber gelesen hatte. Die Hilfe findet da natürlich auch was. Nur WO steht da leider nicht. Weil ich es nicht gefunden habe, dachte ich ich hätte es nicht mitinstalliert.</p>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1290913</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1290913</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Wed, 23 May 2007 16:57:49 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Wed, 23 May 2007 17:02:52 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Dann hast du doch alles was du brauchst. In den Beispielen aus der Builder-Hilfe steht auch wie du TIniFile verwendest.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1290917</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1290917</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 23 May 2007 17:02:52 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Wed, 23 May 2007 17:08:18 GMT]]></title><description><![CDATA[<p>nope, wenn ich jetzt das Object TIniFile einbaue, dann sagt er mir, dass er die Klasse TIniFile nicht finden kann...</p>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1290923</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1290923</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Wed, 23 May 2007 17:08:18 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Wed, 23 May 2007 17:15:56 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Dann hast du die Builder-Hilfe nur ganz kurz überflogen. Denn gleich auf der ersten Seite zu TIniFile steht wie die Unit heißt die man für TIniFile braucht. Und in den Beispielen wird auch gezeigt wie diese Unit konret eingebunden wird.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1290929</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1290929</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 23 May 2007 17:15:56 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Wed, 23 May 2007 18:12:44 GMT]]></title><description><![CDATA[<p>so habe alle Beispiele durchgesehen. Bei mir wird in keinem einzigen auch nur ansatzweise etwas mit INI-Files gemacht...</p>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1290988</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1290988</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Wed, 23 May 2007 18:12:44 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Thu, 24 May 2007 04:59:55 GMT]]></title><description><![CDATA[<p>siehe <a href="http://bcb-tutorial.c-plusplus.net/TIniFile/index.html" rel="nofollow">hier</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291162</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291162</guid><dc:creator><![CDATA[Linnea]]></dc:creator><pubDate>Thu, 24 May 2007 04:59:55 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Thu, 24 May 2007 07:25:29 GMT]]></title><description><![CDATA[<p>KN4CK3R schrieb:</p>
<blockquote>
<p>so habe alle Beispiele durchgesehen. Bei mir wird in keinem einzigen auch nur ansatzweise etwas mit INI-Files gemacht...</p>
</blockquote>
<p>Gib doch einfach mal TIniFile im Hilfeindex ein. Da gibt es auch einen Punkt &quot;TIniFile verwenden&quot; (BCB5) oder &quot;TiniFile Benutzung&quot; (BCB6). Beim BDS2006 gibts das auch, allerdings nur für Delphi.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291201</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291201</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 24 May 2007 07:25:29 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Thu, 24 May 2007 17:40:44 GMT]]></title><description><![CDATA[<p>habs jetzt anders gelöst. Habe die Funktion genommen die ich oben gepostet hab und speichere die Werte noch zusätzlich in Variablen. Beim Profilwechsel wird dann nicht mehr die INI eingelesen, sondern nur noch die Variablen. Funzt wunderbar so <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291610</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291610</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Thu, 24 May 2007 17:40:44 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Fri, 25 May 2007 20:02:25 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">char *ch = new char[3];
if(profil == 1)
{
  GetPrivateProfileString(&quot;Profil1-RGBStart&quot;,&quot;R&quot;,0,ch,100,inipfad);
  ..
  ..
</code></pre>
<p>Die Funktion erwartet als 5. Parameter die Größe des Puffers, den Du zur Verfügung stellst. Du übergibst als Größe 100 Bytes, hast aber ch nur mit 3 Bytes erzeugt. Deine &quot;Lösung&quot; funktioniert wahrscheinlich nur, weil Dein Ergebnis nie größer als 3 Bytes ist, aber wehe, jemand schreibt mal einen größeren Text in Deine Ini-Datei.</p>
<p>Rob'</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1292438</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1292438</guid><dc:creator><![CDATA[Rob&#x27;]]></dc:creator><pubDate>Fri, 25 May 2007 20:02:25 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Sat, 26 May 2007 00:48:07 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/113">@Rob</a>'<br />
Die Panne ist doch schon passiert <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /><br />
Beim Einlesen von &quot;R=123&quot; werden doch schon 4 char's benötigt: man vergesse nicht die abschließende '\0'. Und ab da kannst Du dem Programm nicht mehr trauen.</p>
<p>Nebenbei <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/15576">@KN4CK3R</a>:<br />
Warum die 3 bzw. korret 4 char's mit new allokieren? Die kannst Du doch locker mit</p>
<pre><code>char ch[4];
</code></pre>
<p>auf dem Stack ablegen und mußt Dich nicht mal um deren Vernichtung kümmern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1292501</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1292501</guid><dc:creator><![CDATA[viertel]]></dc:creator><pubDate>Sat, 26 May 2007 00:48:07 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Sat, 26 May 2007 01:24:51 GMT]]></title><description><![CDATA[<p>hab mir mitlerweile ne kleine Datenbank gebastelt. Jetzt funzt alles...</p>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1292505</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1292505</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Sat, 26 May 2007 01:24:51 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Tue, 29 May 2007 12:46:45 GMT]]></title><description><![CDATA[<p>Wegen der Ini-FIles und VCL....<br />
Borland hat glaub ich in der Hilfe vergessen anzugeben das man die datei &quot;inifiles.hpp&quot; mit einbinden muss...</p>
<p>MFG Antwort</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1294438</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1294438</guid><dc:creator><![CDATA[Antwort]]></dc:creator><pubDate>Tue, 29 May 2007 12:46:45 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit INI Files on Tue, 29 May 2007 12:50:49 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Nein ist nicht vergessen</p>
<p>BCB-Hilfe zu TIniFile schrieb:</p>
<blockquote>
<p><strong>Unit</strong><br />
inifiles</p>
</blockquote>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1294440</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1294440</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Tue, 29 May 2007 12:50:49 GMT</pubDate></item></channel></rss>