Commit 426984dd authored by Michael Jung's avatar Michael Jung Committed by Alexandre Julliard

Use IShellFolder::GetDisplayNameOf instead of SHGetPathFromIDList to

be able to browse shell namespace extensions.
parent d8c10047
...@@ -511,6 +511,27 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType) ...@@ -511,6 +511,27 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
return ret; return ret;
} }
/******************************************************************************
* COMDLG32_GetDisplayNameOf [internal]
*
* Helper function to get the display name for a pidl.
*/
static BOOL COMDLG32_GetDisplayNameOf(LPCITEMIDLIST pidl, LPWSTR pwszPath) {
LPSHELLFOLDER psfDesktop;
STRRET strret;
if (FAILED(SHGetDesktopFolder(&psfDesktop)))
return FALSE;
if (FAILED(IShellFolder_GetDisplayNameOf(psfDesktop, pidl, SHGDN_FORPARSING, &strret))) {
IShellFolder_Release(psfDesktop);
return FALSE;
}
IShellFolder_Release(psfDesktop);
return SUCCEEDED(StrRetToBufW(&strret, pidl, pwszPath, MAX_PATH));
}
/*********************************************************************** /***********************************************************************
* ArrangeCtrlPositions [internal] * ArrangeCtrlPositions [internal]
* *
...@@ -841,7 +862,7 @@ HRESULT FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer) ...@@ -841,7 +862,7 @@ HRESULT FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer)
return -1; return -1;
/* get path and filenames */ /* get path and filenames */
SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrCurrentDir); COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrCurrentDir);
n = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, ' '); n = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, ' ');
TRACE("path >%s< filespec >%s< %d files\n", TRACE("path >%s< filespec >%s< %d files\n",
...@@ -925,6 +946,7 @@ HRESULT FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer) ...@@ -925,6 +946,7 @@ HRESULT FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer)
HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
WCHAR lpstrPath[MAX_PATH];
if(!fodInfos) return -1; if(!fodInfos) return -1;
switch(uMsg) switch(uMsg)
...@@ -934,22 +956,16 @@ HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam ...@@ -934,22 +956,16 @@ HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam
case CDM_GETFOLDERPATH: case CDM_GETFOLDERPATH:
TRACE("CDM_GETFOLDERPATH:\n"); TRACE("CDM_GETFOLDERPATH:\n");
if( fodInfos->unicode ) COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPath);
{ if (lParam)
WCHAR lpstrPath[MAX_PATH], *bufW = (LPWSTR)lParam;
SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
if (bufW)
lstrcpynW(bufW,lpstrPath,(int)wParam);
return strlenW(lpstrPath);
}
else
{ {
char lpstrPath[MAX_PATH], *bufA = (LPSTR)lParam; if (fodInfos->unicode)
SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath); lstrcpynW((LPWSTR)lParam, lpstrPath, (int)wParam);
if (bufA) else
lstrcpynA(bufA,lpstrPath,(int)wParam); WideCharToMultiByte(CP_ACP, 0, lpstrPath, -1,
return strlen(lpstrPath); (LPSTR)lParam, (int)wParam, NULL, NULL);
} }
return strlenW(lpstrPath);
case CDM_GETSPEC: case CDM_GETSPEC:
return FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam); return FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam);
...@@ -1597,7 +1613,7 @@ BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCo ...@@ -1597,7 +1613,7 @@ BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCo
ofn->lpstrFile[0] = '\0'; ofn->lpstrFile[0] = '\0';
} }
SHGetPathFromIDListW( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec ); COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
if ( !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) && if ( !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) && ( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) &&
...@@ -1742,14 +1758,10 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) ...@@ -1742,14 +1758,10 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
*/ */
/* Get the current directory name */ /* Get the current directory name */
if (!SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile)) if (!COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile))
{ {
/* we are in a special folder, default to desktop */ /* last fallback */
if(FAILED(COMDLG32_SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, lpstrPathAndFile))) GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
{
/* last fallback */
GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
}
} }
PathAddBackslashW(lpstrPathAndFile); PathAddBackslashW(lpstrPathAndFile);
......
...@@ -140,11 +140,25 @@ static void COMDLG32_DumpSBSPFlags(UINT uflags) ...@@ -140,11 +140,25 @@ static void COMDLG32_DumpSBSPFlags(UINT uflags)
static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos) static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos)
{ {
char lpstrPath[MAX_PATH]; LPSHELLFOLDER psfDesktop;
if(SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath)) { STRRET strret;
SetCurrentDirectoryA(lpstrPath); HRESULT res;
TRACE("new current folder %s\n", lpstrPath);
res = SHGetDesktopFolder(&psfDesktop);
if (FAILED(res))
return;
res = IShellFolder_GetDisplayNameOf(psfDesktop, fodInfos->ShellInfos.pidlAbsCurrent,
SHGDN_FORPARSING, &strret);
if (SUCCEEDED(res)) {
WCHAR wszCurrentDir[MAX_PATH];
res = StrRetToBufW(&strret, fodInfos->ShellInfos.pidlAbsCurrent, wszCurrentDir, MAX_PATH);
if (SUCCEEDED(res))
SetCurrentDirectoryW(wszCurrentDir);
} }
IShellFolder_Release(psfDesktop);
} }
/* copied from shell32 to avoid linking to it */ /* copied from shell32 to avoid linking to it */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment