my solution:
inline static int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg, LPARAM lParam, LPARAM lpData)
{
switch (uMsg)
{
case BFFM_INITIALIZED:
{
if (NULL != lpData)
{
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
}
}
}
return 0; }
inline BOOL BrowseForFolder(HWND hwnd, LPCTSTR szCurrent, LPTSTR szPath)
{
BROWSEINFO bi = { 0 };
LPITEMIDLIST pidl;
TCHAR szDisplay[MAX_PATH];
BOOL retval;
CoInitialize(NULL);
if(szPath == NULL){
szPath = szDisplay;
}
bi.hwndOwner = hwnd;
bi.pszDisplayName = szDisplay;
bi.lpszTitle = TEXT("フォルダを選択してください。");
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM) szCurrent;
pidl = SHBrowseForFolder(&bi);
if (NULL != pidl)
{
retval = SHGetPathFromIDList(pidl, szPath);
CoTaskMemFree(pidl);
}
else
{
retval = FALSE;
}
if (!retval)
{
szPath[0] = TEXT('\0');
}
CoUninitialize();
return retval;
}