<?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[Pfad vorbelegen in SHGetSpecialFolderLocation]]></title><description><![CDATA[<p>Ich habe da ein kleines Problem mit SHGetSpecialFolderLocation.<br />
Dort möchte ich eigentlich gern einen manuellen Pfad, bzw.<br />
den zuletzt gewählten einsetzen als Standardwert.</p>
<p>Muss ich auf SHGetSpecialFolderLocation verzichten und etwas<br />
anderes verwenden? Aus der MSDN werde ich in dem Punkt nicht<br />
ganz schlau. Soweit ich gelesen habe kann ich ausschließlich<br />
die fest definierten Ordner aus Windows ansteuern.</p>
<p>Wählt der User nun in c:\xyz\abc aus, dann hätte ich das aber schon ganz gern<br />
als vorbelegten Pfad fürs nächste Aufrufen des Dateidialoges.</p>
<p>Hier der Buttonaufruf in meiner MFC-Dialog-Anwendung:</p>
<pre><code class="language-cpp">CString m_csLocation=&quot;&quot;;
BROWSEINFO bi;
	ZeroMemory(&amp;bi, sizeof(BROWSEINFO));
	TCHAR szDiplayName[MAX_PATH];
	ZeroMemory(szDiplayName, MAX_PATH);
	LPITEMIDLIST lpStartFolder = NULL;
	SHGetSpecialFolderLocation(GetSafeHwnd(), 0, &amp;lpStartFolder);
//je nachdem welche csidl man angibt wird der entsprechende pfad vorbelegt!

	bi.hwndOwner = GetSafeHwnd();
	bi.pszDisplayName = szDiplayName;
	bi.lpszTitle = _T(&quot;Ordner wählen:&quot;);
	bi.ulFlags = BIF_USENEWUI|BIF_NEWDIALOGSTYLE;
	bi.pidlRoot = lpStartFolder;

	LPITEMIDLIST pIDList = SHBrowseForFolder(&amp;bi);
	LPMALLOC pMalloc = NULL;
	SHGetMalloc(&amp;pMalloc);
	if(pIDList != NULL){
		SHGetPathFromIDList(pIDList, m_csLocation.GetBuffer(MAX_PATH));
		m_csLocation.ReleaseBuffer();
		pMalloc-&gt;Free(pIDList);
	}
	pMalloc-&gt;Free(lpStartFolder);
	pMalloc-&gt;Release();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/185404/pfad-vorbelegen-in-shgetspecialfolderlocation</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 18:44:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/185404.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Jun 2007 11:00:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Pfad vorbelegen in SHGetSpecialFolderLocation on Mon, 25 Jun 2007 11:00:03 GMT]]></title><description><![CDATA[<p>Ich habe da ein kleines Problem mit SHGetSpecialFolderLocation.<br />
Dort möchte ich eigentlich gern einen manuellen Pfad, bzw.<br />
den zuletzt gewählten einsetzen als Standardwert.</p>
<p>Muss ich auf SHGetSpecialFolderLocation verzichten und etwas<br />
anderes verwenden? Aus der MSDN werde ich in dem Punkt nicht<br />
ganz schlau. Soweit ich gelesen habe kann ich ausschließlich<br />
die fest definierten Ordner aus Windows ansteuern.</p>
<p>Wählt der User nun in c:\xyz\abc aus, dann hätte ich das aber schon ganz gern<br />
als vorbelegten Pfad fürs nächste Aufrufen des Dateidialoges.</p>
<p>Hier der Buttonaufruf in meiner MFC-Dialog-Anwendung:</p>
<pre><code class="language-cpp">CString m_csLocation=&quot;&quot;;
BROWSEINFO bi;
	ZeroMemory(&amp;bi, sizeof(BROWSEINFO));
	TCHAR szDiplayName[MAX_PATH];
	ZeroMemory(szDiplayName, MAX_PATH);
	LPITEMIDLIST lpStartFolder = NULL;
	SHGetSpecialFolderLocation(GetSafeHwnd(), 0, &amp;lpStartFolder);
//je nachdem welche csidl man angibt wird der entsprechende pfad vorbelegt!

	bi.hwndOwner = GetSafeHwnd();
	bi.pszDisplayName = szDiplayName;
	bi.lpszTitle = _T(&quot;Ordner wählen:&quot;);
	bi.ulFlags = BIF_USENEWUI|BIF_NEWDIALOGSTYLE;
	bi.pidlRoot = lpStartFolder;

	LPITEMIDLIST pIDList = SHBrowseForFolder(&amp;bi);
	LPMALLOC pMalloc = NULL;
	SHGetMalloc(&amp;pMalloc);
	if(pIDList != NULL){
		SHGetPathFromIDList(pIDList, m_csLocation.GetBuffer(MAX_PATH));
		m_csLocation.ReleaseBuffer();
		pMalloc-&gt;Free(pIDList);
	}
	pMalloc-&gt;Free(lpStartFolder);
	pMalloc-&gt;Release();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1313241</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1313241</guid><dc:creator><![CDATA[HannesK]]></dc:creator><pubDate>Mon, 25 Jun 2007 11:00:03 GMT</pubDate></item><item><title><![CDATA[Reply to Pfad vorbelegen in SHGetSpecialFolderLocation on Mon, 25 Jun 2007 14:04:41 GMT]]></title><description><![CDATA[<p>Habe mir eben nochmal SHGetFolderLocation. Scheint ja, alsob man da nur<br />
Systempfade mit ansteuern kann <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/1313387</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1313387</guid><dc:creator><![CDATA[HannesK]]></dc:creator><pubDate>Mon, 25 Jun 2007 14:04:41 GMT</pubDate></item><item><title><![CDATA[Reply to Pfad vorbelegen in SHGetSpecialFolderLocation on Mon, 25 Jun 2007 18:14:20 GMT]]></title><description><![CDATA[<p>Das geht ganz einfach nicht und is auch winapi!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1313580</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1313580</guid><dc:creator><![CDATA[jedewette]]></dc:creator><pubDate>Mon, 25 Jun 2007 18:14:20 GMT</pubDate></item><item><title><![CDATA[Reply to Pfad vorbelegen in SHGetSpecialFolderLocation on Mon, 25 Jun 2007 18:27:48 GMT]]></title><description><![CDATA[<p><a href="http://blog.voidnish.com/?p=113" rel="nofollow">http://blog.voidnish.com/?p=113</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1313588</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1313588</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 25 Jun 2007 18:27:48 GMT</pubDate></item><item><title><![CDATA[Reply to Pfad vorbelegen in SHGetSpecialFolderLocation on Tue, 26 Jun 2007 08:38:43 GMT]]></title><description><![CDATA[<p>Danke Martin!!</p>
<p>Was ich noch nicht verstehe ist, wie ich den Pfad nun aus der letzten<br />
Auswahl wieder als &quot;Standard&quot; beim nächsten Aufruf des Suchendialoges<br />
setzen kann.</p>
<p>In meinem Versuch wird noch immer nur der Standard gewählt.</p>
<pre><code class="language-cpp">BROWSEINFO bi;
    TCHAR   szDisplayName[MAX_PATH];
    LPITEMIDLIST    pidl;
    LPMALLOC  pMalloc = NULL;
    ZeroMemory(&amp;bi, sizeof(bi));
	bi.hwndOwner = NULL;

//nun versuche ich einen CString dem lParam zuzuweisen
//e.g. c:\\test
	bi.lParam = (LPARAM)(&amp;pfadx);

	bi.lpfn = BrowseCallbackProc;
    bi.pszDisplayName = szDisplayName;
    bi.lpszTitle = TEXT(&quot;Select folder&quot;);
    bi.ulFlags = BIF_VALIDATE|BIF_RETURNONLYFSDIRS|BIF_USENEWUI|BIF_NEWDIALOGSTYLE;
    pidl = SHBrowseForFolder(&amp;bi); 

if ( pidl != 0 ) { 
	// get the name of the folder 
	TCHAR path[MAX_PATH]; 
	if ( SHGetPathFromIDList ( pidl, path ) ) 
	{ 
	MessageBox(path); 

//CString pfadx soll wert von Auswahl annehmen und beim
//nächsten Aufruf dann als Vorbelegung in den lParam fliessen.
	pfadx=path;

	} // free memory used 
	IMalloc * imalloc = 0; 
	if ( SUCCEEDED( SHGetMalloc ( &amp;imalloc )) ) 
	{ 
		imalloc-&gt;Free ( pidl );
		imalloc-&gt;Release ( );
	} 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1313811</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1313811</guid><dc:creator><![CDATA[HannesK]]></dc:creator><pubDate>Tue, 26 Jun 2007 08:38:43 GMT</pubDate></item><item><title><![CDATA[Reply to Pfad vorbelegen in SHGetSpecialFolderLocation on Tue, 26 Jun 2007 09:41:12 GMT]]></title><description><![CDATA[<p>Verstehe Dein Problem nicht. Das kurze Beispiel von Nish zeigt doch wie Du einen bestimmten Pfad vorgeben kannst über die Callback Funktion.</p>
<p>Du musst halt den Wert vorgeben, den Du haben möchtest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1313856</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1313856</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Tue, 26 Jun 2007 09:41:12 GMT</pubDate></item><item><title><![CDATA[Reply to Pfad vorbelegen in SHGetSpecialFolderLocation on Tue, 26 Jun 2007 10:43:19 GMT]]></title><description><![CDATA[<p>Hallo Martin,</p>
<p>den Pfad kann ich in der Callback ja angeben, aber wenn er aus der letzten<br />
erfolgreichen Auswahl des &quot;Öffnen&quot;-Dialoges generiert werden soll, dann<br />
müsste ich ja der Callback sagen:</p>
<p>Nimm aus CString path den Wert als Vorbelegung für deinen Aufruf<br />
mit LPARAM. Nur ist ja mein CString in der Callback nicht bekannt<br />
oder gültig.</p>
<pre><code class="language-cpp">int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lParam,LPARAM lpData)
{

    // Look for BFFM_INITIALIZED
    if(uMsg == BFFM_INITIALIZED)
    {
        SendMessage(hwnd, BFFM_SETSELECTION,
            TRUE,(LPARAM)_T(&quot;c:\\&quot;)); //lParam statisch;

/*
            TRUE,(LPARAM)(&amp;path)); //lParam aus CString generieren, was nicht geht...;

*/

   }
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1313901</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1313901</guid><dc:creator><![CDATA[HannesK]]></dc:creator><pubDate>Tue, 26 Jun 2007 10:43:19 GMT</pubDate></item><item><title><![CDATA[Reply to Pfad vorbelegen in SHGetSpecialFolderLocation on Tue, 26 Jun 2007 10:45:25 GMT]]></title><description><![CDATA[<p>Dann must Du eine entsprechende globale Variable nehmen, damnit es so ist!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1313903</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1313903</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Tue, 26 Jun 2007 10:45:25 GMT</pubDate></item></channel></rss>