#include "precomp.h" #pragma hdrstop #include "svselfil.h" #include #include #include HRESULT OpenShellFolder::OpenShellFolderAndSelectFile( HWND hWnd, const CSimpleDynamicArray &Filenames ) { // // Assume failure // HRESULT hr = E_FAIL; // // Make sure we have some files // if (Filenames.Size()) { // // Save the path name from the first file // TCHAR szPath[MAX_PATH]; StrCpyN( szPath, Filenames[0], ARRAYSIZE(szPath)); // // Remove the filename and extension // if (PathRemoveFileSpec( szPath )) { // // Create the path's IDLIST // LPITEMIDLIST pidlFolder = NULL; if (SUCCEEDED(SHParseDisplayName( szPath, NULL, &pidlFolder, NULL, NULL )) && pidlFolder) if (pidlFolder) { // // Create an array to contain the list of filenames // LPCITEMIDLIST *ppidlFullyQualified = new LPCITEMIDLIST[Filenames.Size()]; if (ppidlFullyQualified) { // // Make sure the array doesn't contain any wild pointers // ZeroMemory(ppidlFullyQualified,sizeof(LPCITEMIDLIST) * Filenames.Size() ); // // Create the list of relative pidls // LPCITEMIDLIST *ppidlRelative = new LPCITEMIDLIST[Filenames.Size()]; if (ppidlRelative) { // // Make sure the array doesn't contain any wild pointers // ZeroMemory(ppidlRelative,sizeof(LPCITEMIDLIST) * Filenames.Size() ); // // Create the list of fully qualified pidls // int nFileCount = 0; for (int i=0;i(ppidlFullyQualified[i])); } } // // Free the PIDL array containing the relative pidls // delete[] ppidlRelative; } // // Free the PIDL array containing the fully qualified pidls // delete[] ppidlFullyQualified; } // // Free the folder PIDL // ILFree(pidlFolder); } } } return hr; }