[問題]設定起始資料路徑 SHBrowseForFolder

看板Programming作者 (修明)時間13年前 (2012/03/13 11:59), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
請問板上的大大們,我想用SHBrowseForFolder打開Folder browser。 但是,我想要設定起始的目錄, 因此用BrowseCallbackProc去收BFFM_INITIALIZED將lpData的值做起始路徑 下面的程式碼在VS2003,無法成功設定起始資料夾。 但,在VS2005卻是可以。 有板上的大大們,知道為什麼嗎? 下面是我的程式碼 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); } }break; } return 0; // The function should always return 0. } void CSHBrowser2003Dlg::OnBnClickedOk() { wchar_t path[MAX_PATH] = {0}; // TODO: Add your control notification handler code here BROWSEINFOW info; ZeroMemory(&info, sizeof(BROWSEINFO)); info.hwndOwner = NULL; info.lpszTitle = L"Try it"; info.ulFlags = BIF_NEWDIALOGSTYLE | BIF_VALIDATE | BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS; info.lpfn = BrowseCallbackProc; info.lParam = (LPARAM) L"C:\Users\Public\Videos"; LPITEMIDLIST pidl; if ((pidl = ::SHBrowseForFolderW(&info)) != NULL) { LPMALLOC pMalloc; //Retrieve a pointer to the shell's IMalloc interface if (SUCCEEDED(SHGetMalloc(&pMalloc))) { // free the PIDL that SHBrowseForFolder returned to us. pMalloc->Free(pidl); // release the shell's IMalloc interface (void)pMalloc->Release(); } } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.50.53.228
文章代碼(AID): #1FNiOOyU (Programming)
文章代碼(AID): #1FNiOOyU (Programming)