<?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[GetPrivateProfileString]]></title><description><![CDATA[<p>Ich versteh was nicht. Wie funktioniert die Funktion GetPrivateProfileString?<br />
Ich habe eine ini, die sieht so aus:<br />
[Perf Programm]<br />
Datenbank= datenbank<br />
User= test<br />
Passwort= passwort</p>
<p>Ich dachte ich könnte das so auslesen:</p>
<pre><code class="language-cpp">GetPrivateProfileString(&quot;Perf Programm&quot;, &quot;Datenbank&quot;, NULL, pBuf, 300, m_strdatenbank);
</code></pre>
<p>Gruß Yvonne</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/4670/getprivateprofilestring</link><generator>RSS for Node</generator><lastBuildDate>Tue, 02 Jun 2026 08:02:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/4670.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 11 Feb 2003 09:48:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GetPrivateProfileString on Tue, 11 Feb 2003 09:48:00 GMT]]></title><description><![CDATA[<p>Ich versteh was nicht. Wie funktioniert die Funktion GetPrivateProfileString?<br />
Ich habe eine ini, die sieht so aus:<br />
[Perf Programm]<br />
Datenbank= datenbank<br />
User= test<br />
Passwort= passwort</p>
<p>Ich dachte ich könnte das so auslesen:</p>
<pre><code class="language-cpp">GetPrivateProfileString(&quot;Perf Programm&quot;, &quot;Datenbank&quot;, NULL, pBuf, 300, m_strdatenbank);
</code></pre>
<p>Gruß Yvonne</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22601</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22601</guid><dc:creator><![CDATA[wutzi]]></dc:creator><pubDate>Tue, 11 Feb 2003 09:48:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Tue, 11 Feb 2003 09:54:00 GMT]]></title><description><![CDATA[<p>Aus der MSDN:</p>
<blockquote>
<p>lpDefault<br />
[in] Pointer to a null-terminated default string. If the lpKeyName key cannot be found in the initialization file, GetPrivateProfileString copies the default string to the lpReturnedString buffer. This parameter cannot be NULL</p>
</blockquote>
<p>Das bedeutet:</p>
<p>[cpp]<br />
GetPrivateProfileString(&quot;Perf Programm&quot;, &quot;Datenbank&quot;, <strong>&quot;&quot;</strong>, pBuf, 300, m_strdatenbank);[/cpp]</p>
<p>Sollte es danach immer noch nicht gehen prüfe mal ob die angaben in m_strdatenbank stimmen.</p>
<p>Geht es immer noch nicht beschreib mal das Problem näher.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22602</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22602</guid><dc:creator><![CDATA[Knuddlbaer]]></dc:creator><pubDate>Tue, 11 Feb 2003 09:54:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Tue, 11 Feb 2003 10:09:00 GMT]]></title><description><![CDATA[<p>Im m_strdatenbank steht der Pfad der ini-DAtei drin.<br />
C:\...\test.ini<br />
Ist daran was falsch. Mein Problem mein pBuf ist leer.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22603</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22603</guid><dc:creator><![CDATA[wutzi]]></dc:creator><pubDate>Tue, 11 Feb 2003 10:09:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Tue, 11 Feb 2003 11:14:00 GMT]]></title><description><![CDATA[<p>Hallo !</p>
<p>Mal angenommen, &quot;m_strdatenbank&quot; ist ein CString: der Pfad muss mit &quot;\&quot; geschrieben werden (also C:\...\\test.ini).</p>
<p>Und so klappt das mit dem Buffer:</p>
<p>Entweder so:</p>
<pre><code class="language-cpp">char pBuf[256];
GetPrivateProfileString(&quot;Perf Programm&quot;, &quot;Datenbank&quot;, NULL, pBuf, 255, m_strdatenbank);
</code></pre>
<p>oder so:</p>
<pre><code class="language-cpp">CString pBuf;
GetPrivateProfileString(&quot;Perf Programm&quot;, &quot;Datenbank&quot;, NULL, pBuf.GetBuffer(255), 255, m_strdatenbank);
</code></pre>
<p>Tschüss</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22604</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22604</guid><dc:creator><![CDATA[isabeau]]></dc:creator><pubDate>Tue, 11 Feb 2003 11:14:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Tue, 11 Feb 2003 11:23:00 GMT]]></title><description><![CDATA[<p>ReleaseBuffer(-1) nicht vergessen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22605</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22605</guid><dc:creator><![CDATA[???]]></dc:creator><pubDate>Tue, 11 Feb 2003 11:23:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Tue, 11 Feb 2003 11:27:00 GMT]]></title><description><![CDATA[<p>Stimmt !<br />
Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22606</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22606</guid><dc:creator><![CDATA[isabeau]]></dc:creator><pubDate>Tue, 11 Feb 2003 11:27:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Mon, 17 Feb 2003 12:23:00 GMT]]></title><description><![CDATA[<p>Irgendwie kam ich durch eure Hilfe immer noch nicht weiter, mein GetPrivateProfileString liest immer nocht nichts ein. Kann mir niemand helfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22607</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22607</guid><dc:creator><![CDATA[wutzi]]></dc:creator><pubDate>Mon, 17 Feb 2003 12:23:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Mon, 17 Feb 2003 13:20:00 GMT]]></title><description><![CDATA[<p>Es ist wirklich dringen ich komm sonst nicht weiter</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22608</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22608</guid><dc:creator><![CDATA[wutzi]]></dc:creator><pubDate>Mon, 17 Feb 2003 13:20:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Mon, 17 Feb 2003 14:24:00 GMT]]></title><description><![CDATA[<p>Versuch's mal mit dieser Klasse:</p>
<p><a href="http://free.pages.at/happosai/download/cinictrl.zip" rel="nofollow">http://free.pages.at/happosai/download/cinictrl.zip</a></p>
<p>(Source online: <a href="http://free.pages.at/happosai/cpp/quellcodes/cinictrl.html" rel="nofollow">http://free.pages.at/happosai/cpp/quellcodes/cinictrl.html</a> - ist zum Posten zu lang, Original von Codeguru)</p>
<p>Dann ungefähr so benutzen:</p>
<pre><code class="language-cpp">CIniCtrl pINI;
pINI.SetFileName(&quot;C:\Programme\App\App.ini&quot;);
CString sDB   = pINI.GetStringValue(&quot;Perf Programm&quot;, &quot;Datenbank&quot;);
CString sUSER = pINI.GetStringValue(&quot;Perf Programm&quot;, &quot;User&quot;);
CString sPW   = pINI.GetStringValue(&quot;Perf Programm&quot;, &quot;Password&quot;);
</code></pre>
<p>CU</p>
<p>Happosai</p>
<p>[edit:] Download-URL war falsch [/edit]</p>
<p>[ Dieser Beitrag wurde am 17.02.2003 um 15:27 Uhr von <strong>Happosai</strong> editiert. ]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22609</guid><dc:creator><![CDATA[Sanji]]></dc:creator><pubDate>Mon, 17 Feb 2003 14:24:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Mon, 17 Feb 2003 14:26:00 GMT]]></title><description><![CDATA[<p>Danke ich werds mal so versuchen, meld mich dann wenn es läuft oder nicht läuft.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22610</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22610</guid><dc:creator><![CDATA[wutzi]]></dc:creator><pubDate>Mon, 17 Feb 2003 14:26:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Mon, 17 Feb 2003 14:56:00 GMT]]></title><description><![CDATA[<p>Ich löse es immer so:</p>
<pre><code class="language-cpp">CString m_pfad = &quot;c:\\data\\test.ini&quot;;   //dein pfad eben
CString test;
char data[25];     //ist einfach nur ne variable
GetPrivateProfileString(&quot;TEXT&quot;,&quot;text&quot;,data,data,80,m_pfad);
test = data;
AfxMessageBox(test); //dient jetzt nur zum testen
</code></pre>
<p>Nur mal so zum vergleichen ..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22611</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22611</guid><dc:creator><![CDATA[C-O-M-M-A-N-D-E-R]]></dc:creator><pubDate>Mon, 17 Feb 2003 14:56:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Mon, 17 Feb 2003 15:15:00 GMT]]></title><description><![CDATA[<p>Ich löse es immer so das ich ich in die FAQ schaue und mir den Source dort hole den ich mal dort gepostet habe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22612</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22612</guid><dc:creator><![CDATA[Unix-Tom]]></dc:creator><pubDate>Mon, 17 Feb 2003 15:15:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Mon, 17 Feb 2003 15:27:00 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> So geht's natürlich auch <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Happosai</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22613</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22613</guid><dc:creator><![CDATA[Sanji]]></dc:creator><pubDate>Mon, 17 Feb 2003 15:27:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Tue, 18 Feb 2003 10:47:00 GMT]]></title><description><![CDATA[<p>Es funktioniert endlich.<br />
Also erstmal tausend Dank für eure Hilfe. Ohne euch wäre ich nie weitergekommen. Ich habe die ganze Zeit den Fehler bei dem GetPrivateProfileString gesucht. In Wirklichkeit lag es aber daran, dass ich das ganze in einer if-Schleife hatte</p>
<pre><code class="language-cpp">if(m_file.Open(m_strProfileName, CFile::modeRead))
{
      //Das funktioniert,aber nur ohne if
      char pBuf[25];
      GetPrivateProfileString(&quot;Perf Programm&quot;, &quot;Datenbank&quot;, pBuf, pBuf, 80, m_strProfileName //Hier steht mein Pfad drinn);
        theApp.m_strdatenbank=pBuf;
      //Das funktioniert,aber nur ohne if
}
</code></pre>
<p>Ich wollte aber das if, denn ich wollte meinem Programm sagen, wenn keine ini.vorhandne ist, gebe eine Meldung aus, dass man eine ini erstellen solte. Was geht an diesem if nicht?</p>
<p>[ Dieser Beitrag wurde am 18.02.2003 um 12:13 Uhr von <strong>wutzi</strong> editiert. ]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22614</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22614</guid><dc:creator><![CDATA[wutzi]]></dc:creator><pubDate>Tue, 18 Feb 2003 10:47:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Tue, 18 Feb 2003 12:10:00 GMT]]></title><description><![CDATA[<p>Die if-Verzweigung müsste funzen. Meiner Meinung nach liegt der Fehler noch weiter oben.</p>
<p>Happosai</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22615</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22615</guid><dc:creator><![CDATA[Sanji]]></dc:creator><pubDate>Tue, 18 Feb 2003 12:10:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Tue, 18 Feb 2003 12:26:00 GMT]]></title><description><![CDATA[<p>Aber das Programm funzt ohne if. Dann kann ich doch keinen Fehler davor haben, oder?<br />
Das steht auf jedenfall davor:</p>
<pre><code class="language-cpp">BOOL CPerfApp::InitInstance()
{
    CStdioFile file;
    CFile m_file;
    CString filename, txt, m_strini, m_strProfileName, m_strget, m_strsection, m_strkey;
    char buffer[1000];
    filename=&quot;\\test.ini&quot;;
    static char strBuffer[_MAX_PATH + 1];
    m_strget=_getcwd(strBuffer, _MAX_PATH);
    strcat(strBuffer, &quot;\\perf.ini&quot;);
    TCHAR * pszBuffer = (TCHAR*)malloc( (_MAX_PATH+1)*sizeof(TCHAR) );
    m_strProfileName= m_strget+ filename;
 //und dann kommt if....
</code></pre>
<p>Die if Funktion hat auch funktioniert ohne den GetPrivateProfileString, d.h. wenn die Datei vorhandne war ging es in den if-Zweig und wenn nicht dann in else, warum klappt das so wie ich es machen will jetzt nicht mehr????</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22616</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22616</guid><dc:creator><![CDATA[wutzi]]></dc:creator><pubDate>Tue, 18 Feb 2003 12:26:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Tue, 18 Feb 2003 14:15:00 GMT]]></title><description><![CDATA[<p>wenn du - was ich glaube - den Pfad der exe ermitteln willst und an diesen einfach nur &quot;\\test.ini&quot; anhängen will, würde ICH das ganze so schreiben:</p>
<pre><code class="language-cpp">BOOL CPerfApp::InitInstance()
{
    CString sAppPath = GetCommandLine();
    sAppPath         = sAppPath.Mid(1, sAppPath.ReverseFind('\\') - 1);

    sAppPath += &quot;\\test.ini&quot;;

    //und dann kommt if....
}
</code></pre>
<p>Happosai</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22617</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22617</guid><dc:creator><![CDATA[Sanji]]></dc:creator><pubDate>Tue, 18 Feb 2003 14:15:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Tue, 18 Feb 2003 15:25:00 GMT]]></title><description><![CDATA[<p>Das man das anders schreiben kann ist mir schon klar, aber wenn ich es so mach wie du kommt der Debug Ordner raus und den wollt ich eigentlich nicht. Aber das ist mir eigentlich egal, dass man das besser schreiben kann. Ich brauch erst mal die Grundfunktion.</p>
<pre><code class="language-cpp">if(m_file.Open(m_strProfileName, CFile::modeRead))
{
      //Das funktioniert,aber nur ohne if
      char pBuf[25];
      GetPrivateProfileString(&quot;Perf Programm&quot;, &quot;Datenbank&quot;, pBuf, pBuf, 80, m_strProfileName //Hier steht mein Pfad drinn);
        theApp.m_strdatenbank=pBuf;
      //Das funktioniert,aber nur ohne if
}
</code></pre>
<p>Also warum funkioniert das GetPrivateProfileString nicht in dieser if Funktion. Kann mir da niemand helfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22618</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22618</guid><dc:creator><![CDATA[wutzi]]></dc:creator><pubDate>Tue, 18 Feb 2003 15:25:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Tue, 18 Feb 2003 16:05:00 GMT]]></title><description><![CDATA[<p>Bist du dir auch sicher, dass der Pfad am Ende vor der if-Anweisung auch RICHTIG ist? Lass' ihn dir doch per AfxMessageBox anzeigen. Ist der Pfad korrekt, können wir den Fehler bei CFIle suchen ... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>Happosai</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22619</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22619</guid><dc:creator><![CDATA[Sanji]]></dc:creator><pubDate>Tue, 18 Feb 2003 16:05:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Wed, 19 Feb 2003 06:49:00 GMT]]></title><description><![CDATA[<p>Ja de Pfad ist korrekt!!!<br />
Woran könnte bei CFile der Fehler liegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22620</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22620</guid><dc:creator><![CDATA[wutzi]]></dc:creator><pubDate>Wed, 19 Feb 2003 06:49:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Wed, 19 Feb 2003 07:59:00 GMT]]></title><description><![CDATA[<p>Hab mein Problem gelöst. Mit if(... .Open) öffne ich die Datei. Das GEtPrivatProfile möchte auch die Datei öffnen, da diese dann schon geöffnet ist geht das so nicht. Deswegenen muss ich mit access prüfen ob sie vorhandne ist, dabei öffnet er die Datei nicht.<br />
Trotzdem danke für deine Hilfe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/22621</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/22621</guid><dc:creator><![CDATA[wutzi]]></dc:creator><pubDate>Wed, 19 Feb 2003 07:59:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetPrivateProfileString on Thu, 27 Nov 2003 15:59:10 GMT]]></title><description><![CDATA[<p>ist es auch möglich einen rel. pfad anzugeben?<br />
normal liegt die ini datei immer in dem selben ordner mit der exe datei.<br />
wenn ich einen pfad mit c:\... angebe funktioniert es, gebe ich aber nur den dateinamen an leider nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/403394</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/403394</guid><dc:creator><![CDATA[Thomas79]]></dc:creator><pubDate>Thu, 27 Nov 2003 15:59:10 GMT</pubDate></item></channel></rss>