<?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[OPENFILENAME mit dem Flag OFN_ALLOWMULTISELECT ...-&amp;gt; Ich griegs nit hin :(]]></title><description><![CDATA[<p>Hallo zusammen <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="😉"
    /> ,</p>
<p>Also ich habe jetzt meinen Öffnen-Dialog erfolgreich erstellen können, nämlich so:</p>
<pre><code class="language-cpp">OPENFILENAME ofnOpenFile;
TCHAR	     szSelectedFile[(MAX_PATH * 100) + 1];
ZeroMemory(szSelectedFile, sizeof(CSTRG) * (MAX_PATH * 100) + 1);
// Struktur für 'Öffnen-Dialog' füllen:
ZeroMemory(&amp;ofnOpenFile, sizeof(OPENFILENAME));
ofnOpenFile.lStructSize = sizeof(OPENFILENAME);
ofnOpenFile.hwndOwner   = hWnd;
ofnOpenFile.lpstrFilter = ...; // &lt;- Dateifilter
ofnOpenFile.lpstrFile   = szSelectedFile;
ofnOpenFile.nMaxFile    = (MAX_PATH * 2) + 1;
ofnOpenFile.Flags       = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT;
ofnOpenFile.lpstrTitle  = ...; // &lt;- Titel des 'Öffnen-Dialog'
// Öffnen-Dialog aufrufen:					
if(GetOpenFileName(&amp;ofnOpenFile))
{
   // ???
}
</code></pre>
<p><strong>Jetzt meine Frage:</strong><br />
Wie kann ich das Ergebnis (szSelectedFile), also den zusammengesetzten Pfad, der<br />
vom Benutzer selektiert wurde, nun so zerlegen, dass ich jeweils den Pfad plus<br />
den Dateinamen bekomme ?</p>
<p><strong>Mal ein Beispiel:</strong><br />
In dem Ordner:</p>
<pre><code>C:\Beispiel\
</code></pre>
<p>befinden sich 3 Dateien namens:</p>
<pre><code>info1.txt
info2.txt
info3.txt
</code></pre>
<p>Mein Ziel:</p>
<pre><code>C:\Beispiel\info1.txt
C:\Beispiel\info2.txt
C:\Beispiel\info3.txt
</code></pre>
<p>Wär echt super nett, wenn ihr mit da mal n kleines Snippet zu schreiben könntet, da ich schon alles probiert hab und google und Co auch nix ausspuckt ...Danke schonmal!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/161149/openfilename-mit-dem-flag-ofn_allowmultiselect-gt-ich-griegs-nit-hin</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 09:34:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/161149.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 03 Oct 2006 21:21:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to OPENFILENAME mit dem Flag OFN_ALLOWMULTISELECT ...-&amp;gt; Ich griegs nit hin :( on Tue, 03 Oct 2006 21:21:36 GMT]]></title><description><![CDATA[<p>Hallo zusammen <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="😉"
    /> ,</p>
<p>Also ich habe jetzt meinen Öffnen-Dialog erfolgreich erstellen können, nämlich so:</p>
<pre><code class="language-cpp">OPENFILENAME ofnOpenFile;
TCHAR	     szSelectedFile[(MAX_PATH * 100) + 1];
ZeroMemory(szSelectedFile, sizeof(CSTRG) * (MAX_PATH * 100) + 1);
// Struktur für 'Öffnen-Dialog' füllen:
ZeroMemory(&amp;ofnOpenFile, sizeof(OPENFILENAME));
ofnOpenFile.lStructSize = sizeof(OPENFILENAME);
ofnOpenFile.hwndOwner   = hWnd;
ofnOpenFile.lpstrFilter = ...; // &lt;- Dateifilter
ofnOpenFile.lpstrFile   = szSelectedFile;
ofnOpenFile.nMaxFile    = (MAX_PATH * 2) + 1;
ofnOpenFile.Flags       = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT;
ofnOpenFile.lpstrTitle  = ...; // &lt;- Titel des 'Öffnen-Dialog'
// Öffnen-Dialog aufrufen:					
if(GetOpenFileName(&amp;ofnOpenFile))
{
   // ???
}
</code></pre>
<p><strong>Jetzt meine Frage:</strong><br />
Wie kann ich das Ergebnis (szSelectedFile), also den zusammengesetzten Pfad, der<br />
vom Benutzer selektiert wurde, nun so zerlegen, dass ich jeweils den Pfad plus<br />
den Dateinamen bekomme ?</p>
<p><strong>Mal ein Beispiel:</strong><br />
In dem Ordner:</p>
<pre><code>C:\Beispiel\
</code></pre>
<p>befinden sich 3 Dateien namens:</p>
<pre><code>info1.txt
info2.txt
info3.txt
</code></pre>
<p>Mein Ziel:</p>
<pre><code>C:\Beispiel\info1.txt
C:\Beispiel\info2.txt
C:\Beispiel\info3.txt
</code></pre>
<p>Wär echt super nett, wenn ihr mit da mal n kleines Snippet zu schreiben könntet, da ich schon alles probiert hab und google und Co auch nix ausspuckt ...Danke schonmal!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1148920</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1148920</guid><dc:creator><![CDATA[ofn]]></dc:creator><pubDate>Tue, 03 Oct 2006 21:21:36 GMT</pubDate></item><item><title><![CDATA[Reply to OPENFILENAME mit dem Flag OFN_ALLOWMULTISELECT ...-&amp;gt; Ich griegs nit hin :( on Wed, 04 Oct 2006 07:19:32 GMT]]></title><description><![CDATA[<p>Willst du jetzt einfach nur den Pfad der ausgewählten Datei(en) haben, oder willst du alle Dateien aus einem Verzeichnis auslesen?</p>
<p>1.) z.B. so (in szFilePath steht hier jetzt vorher der komplette Pfad mit Dateiname drin): *(strrchr(szFilePath,'\')+1) = 0;<br />
2.) <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39396.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-39396.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149006</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Wed, 04 Oct 2006 07:19:32 GMT</pubDate></item><item><title><![CDATA[Reply to OPENFILENAME mit dem Flag OFN_ALLOWMULTISELECT ...-&amp;gt; Ich griegs nit hin :( on Wed, 04 Oct 2006 12:29:57 GMT]]></title><description><![CDATA[<p>Hi flenders,</p>
<p>flenders schrieb:</p>
<blockquote>
<p>Willst du jetzt einfach nur den Pfad der ausgewählten Datei(en) haben, [...]</p>
</blockquote>
<p>JA genau. Das ist es!</p>
<p>Aber dein Code unter 1. versteh ich irg wie nicht,...Muss ich den nicht in Schleifen parsen ?<br />
Danke nochmal, für deine Antwort! <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="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149206</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149206</guid><dc:creator><![CDATA[ofn]]></dc:creator><pubDate>Wed, 04 Oct 2006 12:29:57 GMT</pubDate></item><item><title><![CDATA[Reply to OPENFILENAME mit dem Flag OFN_ALLOWMULTISELECT ...-&amp;gt; Ich griegs nit hin :( on Wed, 04 Oct 2006 12:59:07 GMT]]></title><description><![CDATA[<p>ofn schrieb:</p>
<blockquote>
<p>dein Code unter 1. versteh ich irg wie nicht,...Muss ich den nicht in Schleifen parsen ?</p>
</blockquote>
<p>Dort wird einfach der jeweilige String nach dem letzten \ mit einer 0 terminiert (sprich der Dateiname abgeschnitten). Wenn du in szSelectedFile mehrere Dateien drin hast, musst du das für jede Datei machen (wobei die ja alle im selber Verzeichnis liegen und du somit wohl auch immer den selben Pfad bekommen wirst)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149241</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149241</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Wed, 04 Oct 2006 12:59:07 GMT</pubDate></item><item><title><![CDATA[Reply to OPENFILENAME mit dem Flag OFN_ALLOWMULTISELECT ...-&amp;gt; Ich griegs nit hin :( on Wed, 04 Oct 2006 13:18:53 GMT]]></title><description><![CDATA[<p>flenders schrieb:</p>
<blockquote>
<p>ofn schrieb:</p>
<blockquote>
<p>dein Code unter 1. versteh ich irg wie nicht,...Muss ich den nicht in Schleifen parsen ?</p>
</blockquote>
<p>Dort wird einfach der jeweilige String nach dem letzten \ mit einer 0 terminiert (sprich der Dateiname abgeschnitten). Wenn du in szSelectedFile mehrere Dateien drin hast, musst du das für jede Datei machen (wobei die ja alle im selber Verzeichnis liegen und du somit wohl auch immer den selben Pfad bekommen wirst)</p>
</blockquote>
<p>Also den Pfad habe ich ja...nur den Pfad mit den Dateinamen zusammenbringen, das funzt irg.wie nit <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="😞"
    /> ...<br />
Also so komme ich an den Pfad:</p>
<pre><code class="language-cpp">const std::string strPathOnly(szSelectedFile, ofnOpenFile.nFileOffset);
</code></pre>
<p>Denn:</p>
<p>MSDN zu OPENFILENAME schrieb:</p>
<blockquote>
<p>The nFileOffset member is the offset, in bytes or characters, to the first filename, and the nFileExtension member is not used.</p>
</blockquote>
<p>Hm hier vllt nochmal der ganze Absatz, ich werd daraus irg wie nit schlau(hab das meiner Meinung nach wichtigste mal markiert):</p>
<blockquote>
<p><strong>OFN_ALLOWMULTISELECT</strong><br />
Specifies that the File Name list box allows multiple selections. If you also set the OFN_EXPLORER flag, the dialog box uses the Explorer-style user interface; otherwise, it uses the old-style user interface.<br />
If the user selects more than one file, the lpstrFile buffer returns the path to the current directory followed by the filenames of the selected files. The nFileOffset member is the offset, in bytes or characters, to the first filename, and the nFileExtension member is not used. For Explorer-style dialog boxes, the directory and filename strings are NULL separated, with an extra NULL character after the last filename. This format enables the Explorer-style dialogs to return long filenames that include spaces. For old-style dialog boxes, the directory and filename strings are separated by spaces and the function uses short filenames for filenames with spaces. You can use theFindFirstFile function to convert between long and short filenames.</p>
<p>If you specify a custom template for an old-style dialog box, the definition of the File Name list box must contain the LBS_EXTENDEDSEL value.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1149254</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149254</guid><dc:creator><![CDATA[ofn]]></dc:creator><pubDate>Wed, 04 Oct 2006 13:18:53 GMT</pubDate></item><item><title><![CDATA[Reply to OPENFILENAME mit dem Flag OFN_ALLOWMULTISELECT ...-&amp;gt; Ich griegs nit hin :( on Wed, 04 Oct 2006 17:33:44 GMT]]></title><description><![CDATA[<p>Oh, ich hatte irgendwie nicht genau gelesen, was du überhaupt haben wolltest... <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>Also wenn ich das richtig verstehe, dann hast du nach</p>
<pre><code class="language-cpp">szSelectedFile += ofnOpenFile.nFileOffset;
</code></pre>
<p>in szSelectedFile hintereinander die einzelnen Dateinamen stehen. Also Dateiname, dann kommt (zusätzlich zum Sting-Abschluss-Null-Zeichen) ein zusätzliches Null-Zeichen und dann der nächste. Wenn du an jeden Dateinamen den Pfad drankopieren willst, dann muss du dir das mit lstrcat wieder zusammenkopieren. und nachdem du einen Dateinamen abgearbeitet hast, setzt du einfach so wie ober den szSelectedFile-Zeiger um die Stringlänge+2 weiter...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149409</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149409</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Wed, 04 Oct 2006 17:33:44 GMT</pubDate></item><item><title><![CDATA[Reply to OPENFILENAME mit dem Flag OFN_ALLOWMULTISELECT ...-&amp;gt; Ich griegs nit hin :( on Wed, 04 Oct 2006 21:11:38 GMT]]></title><description><![CDATA[<p>flenders schrieb:</p>
<blockquote>
<p>in szSelectedFile hintereinander die einzelnen Dateinamen stehen.</p>
</blockquote>
<p>Jo, aber an die komm ich ebend nit ran... <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/1149559</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149559</guid><dc:creator><![CDATA[ofn]]></dc:creator><pubDate>Wed, 04 Oct 2006 21:11:38 GMT</pubDate></item><item><title><![CDATA[Reply to OPENFILENAME mit dem Flag OFN_ALLOWMULTISELECT ...-&amp;gt; Ich griegs nit hin :( on Wed, 04 Oct 2006 22:40:14 GMT]]></title><description><![CDATA[<p>dann gib dir mühe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149597</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149597</guid><dc:creator><![CDATA[lo]]></dc:creator><pubDate>Wed, 04 Oct 2006 22:40:14 GMT</pubDate></item><item><title><![CDATA[Reply to OPENFILENAME mit dem Flag OFN_ALLOWMULTISELECT ...-&amp;gt; Ich griegs nit hin :( on Thu, 05 Oct 2006 06:53:45 GMT]]></title><description><![CDATA[<p>Ich bitte noch mal um Hilfe....<br />
@lo:</p>
<p>Ich sitz da schon ne Ewigkeit dran und hab alles mögliche probiert (sowohl mit std::strings und deren Methoden, als auch mit C-Strings und den Standard-Funktionen) aber da kam nie das richtige raus... <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>Nur ein <strong>KLEINES</strong> Snippet zum parsen <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/1149655</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149655</guid><dc:creator><![CDATA[ofn]]></dc:creator><pubDate>Thu, 05 Oct 2006 06:53:45 GMT</pubDate></item><item><title><![CDATA[Reply to OPENFILENAME mit dem Flag OFN_ALLOWMULTISELECT ...-&amp;gt; Ich griegs nit hin :( on Thu, 05 Oct 2006 07:01:09 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">if(GetOpenFileName(&amp;ofnOpenFile))
{
	int pos = ofnOpenFile.nFileOffset;

	TCHAR szFilePath[MAX_PATH+1];
	lstrcpy(szFilePath,szSelectedFile);
	lstrcat(szFilePath,&quot;\\&quot;);

	while(szSelectedFile[pos] != 0)
	{
		lstrcpy(&amp;szFilePath[ofnOpenFile.nFileOffset],&amp;szSelectedFile[pos]);
		pos += lstrlen(&amp;szSelectedFile[pos])+1;
		MessageBox(0,szFilePath,&quot;Ausgewählte Datei&quot;,0);// ???
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1149658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149658</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Thu, 05 Oct 2006 07:01:09 GMT</pubDate></item><item><title><![CDATA[Reply to OPENFILENAME mit dem Flag OFN_ALLOWMULTISELECT ...-&amp;gt; Ich griegs nit hin :( on Thu, 05 Oct 2006 08:06:56 GMT]]></title><description><![CDATA[<p>BOAH, bin baff....MEGA DICKES DANKE!!!!!!!!!!!!<br />
DAS ISSES!!!!!</p>
<p>VIELEN,VIELEN,VIELEN,VIELEN,VIELEN,VIELEN,VIELEN,VIELEN,VIELEN,VIELEN DANK!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149705</guid><dc:creator><![CDATA[ofn]]></dc:creator><pubDate>Thu, 05 Oct 2006 08:06:56 GMT</pubDate></item></channel></rss>