Use IShellFolder::GetDisplayNameOf instead of SHGetPathFromIDList to
be able to browse shell namespace extensions.
This commit is contained in:
parent
d8c100478e
commit
426984ddb4
|
@ -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)
|
||||||
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)
|
||||||
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
|
||||||
|
|
||||||
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;
|
if (fodInfos->unicode)
|
||||||
SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
|
lstrcpynW((LPWSTR)lParam, lpstrPath, (int)wParam);
|
||||||
if (bufW)
|
|
||||||
lstrcpynW(bufW,lpstrPath,(int)wParam);
|
|
||||||
return strlenW(lpstrPath);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
WideCharToMultiByte(CP_ACP, 0, lpstrPath, -1,
|
||||||
char lpstrPath[MAX_PATH], *bufA = (LPSTR)lParam;
|
(LPSTR)lParam, (int)wParam, NULL, NULL);
|
||||||
SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
|
|
||||||
if (bufA)
|
|
||||||
lstrcpynA(bufA,lpstrPath,(int)wParam);
|
|
||||||
return strlen(lpstrPath);
|
|
||||||
}
|
}
|
||||||
|
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
|
||||||
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,15 +1758,11 @@ 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 */
|
|
||||||
if(FAILED(COMDLG32_SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, lpstrPathAndFile)))
|
|
||||||
{
|
{
|
||||||
/* last fallback */
|
/* last fallback */
|
||||||
GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
|
GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
PathAddBackslashW(lpstrPathAndFile);
|
PathAddBackslashW(lpstrPathAndFile);
|
||||||
|
|
||||||
TRACE("current directory=%s\n", debugstr_w(lpstrPathAndFile));
|
TRACE("current directory=%s\n", debugstr_w(lpstrPathAndFile));
|
||||||
|
|
|
@ -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 */
|
||||||
|
|
Loading…
Reference in New Issue