Ok thanks, is this ok to do? Also, why is it that I'm only calling dir.push_back once, yet I have 2 elements? The first is empty, the 2nd is my push_back call.
Code:
TCHAR SomeArray[_MAX_PATH];
buttonPush(hWnd,dir);
_tcscpy(SomeArray, dir[1].c_str());
SetWindowText(textBox2, SomeArray);
Code:
bool buttonPush(HWND hWnd, StringVector &dir ) {
BROWSEINFO bi;
TCHAR szDir[MAX_PATH];
LPITEMIDLIST pidl;
LPMALLOC pMalloc;
if (SUCCEEDED(SHGetMalloc(&pMalloc)))
{
ZeroMemory(&bi,sizeof(bi));
bi.hwndOwner = hWnd;
bi.pszDisplayName = 0;
bi.pidlRoot = 0;
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON;
bi.pszDisplayName = szDir; // Address of a buffer to receive the display name of the folder selected by the user
bi.lpszTitle = _T("Select a folder"); // Title of the dialog
bi.lpfn = BrowseCallbackProc;
pidl = SHBrowseForFolder(&bi);
if (pidl)
{
TCHAR SomeArray[_MAX_PATH];
BOOL bRet = ::SHGetPathFromIDList(pidl, SomeArray);
dir.push_back(SomeArray);
pMalloc->Free(pidl);
pMalloc->Release();
if(bRet) return true;
}
}
return false;
}