dir is a StringVector like you suggested - but I'm getting a crash after calling buttonPush -
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) { BOOL bRet = ::SHGetPathFromIDList(pidl, const_cast<char *>(dir[0].c_str())); // dir gets a bad ptr here, how can I do this with a StringVector? pMalloc->Free(pidl); pMalloc->Release(); if(bRet) return true; } } return false; }Is const casting safe to do in this scenario?Code:SetWindowText(textBox2, const_cast<char *>(dir[0].c_str()));




Reply With Quote