From 23265de0b9037c5e8157b9285bf8bc4a5c37547f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Wed, 16 Mar 2005 07:51:01 +0000 Subject: [PATCH] Sync to Wine-20050310: Michael Jung - Beginning of a shell namespace extension to browse the unix filesystem. - Fixed parsing of ITEMIDLIST in InitializeTreeView. - Added some documentation. - Fixed a crash occuring when the user double-clicks a leaf item. Dimitrie O. Paun - Add support for .exe's with exported functions. Francois Gouget - Assorted spelling fixes. - Add the -noname flag to match the Platform SDK. - Don't hardcode ordinals if which are not hardcoded on Windows. Juan Lang - Convert more API calls to Unicode. - Convert tabs to space, wrap long lines, make indenting consistent. - Convert a few calls to Unicode. Mike McCormack - handle IFileSystemBindData in ISF_Desktop_fnParseDisplayName - more Unicode conversion - handle IFileSystemBindData in IShellFolder::ParseDisplayName - convert IShellFolder::ParseDisplayName to use Unicode - Remove tabs and make formatting consistent. - Reindent some code to improve readability. - Define some extra SHFGI values. - Remove tabs and reformat. - Use lstrcmpiA in preference to strcasecmp. - Make lstr* functions inline inside Wine. - implement loading and saving of MSI advertised shortcut info - make more test cases pass - read and write the location block - improve the binary compatibility of lnk files - Cleanup, create unicode versions of _ILCreateFromPath, _ILCreateGuidFromStr, and _ILCreateFromFindData. Jon Griffiths - Documentation spelling fixes. Hans Leidekker - Revert wrong -noname markup for Drag*, DoEnvironmentSubst and SHGetNewLinkInfo{A,W}. - Also mark stub exports -noname when they are exported by ordinal only on win98/2k. - Implementation level stubs for SheChangeDirA, SheGetDirA, SHHelpShortcuts_RunDLL{A,W}. - New spec file stubs for Control_RunDLLAsUserW, FixupOptionalComponents, OCInstall, SHChangeNotifySuspendResume, SHCreateProcessAsUserW, SHExtractIconsW, SHInvokePrinterCommand{A,W}, SHIsFileAvailableOffline, SHLoadNonloadedIconOverlayIdentifiers, SHPathPrepareForWrite{A,W}, ShellExec_RunDLL{,A,W}, SHGetIconOverlayIndex{A,W}. - Mark exports -noname when they are exported by ordinal only on win98/2k. Marcelo Duarte - Update the resources for Portuguese. Filip Navara - Don't crash if ShellFolder doesn't implement the IID_ISFHelper interface. Dmitry Timoshkov - Fix prototypes of GetClassLongA/W, GetClassLongPtrA/W and SetClassLongA/W according to SDK definitions. - Add prototypes for SetClassLongPtrA/W, protect some GWL_ and GCL_ constants from using in Wine or in _WIN64 mode. - Fix all places in Wine affected by the above changes. - Convert winemenubuilder to unicode. Alex Villacis Lasso - Change SUBLANG_DEFAULT to SUBLANG_NEUTRAL for LANG_SPANISH in all resources, so that Spanish locales other than Spain also use Spanish resources. Marcus Meissner - Output some more informations. - Mark one global variable static. Huw Davies - SetPath("") should return S_OK. SetPath("nonexistent_path") should return S_FALSE. - Don't prepend '\\' to the subkey name. Joris Huizer - renamed file_operation_delete and to shfileops_delete - renamed file_operation_checkFlags to shfileops_check_flags - added helper function shfileops_do_operation() - added helper function shfileops_get_parent_attr() - added helper function shfileops_get_parent_attr2() - various cleanups in SHFileOperationW using these functions Ge van Geldorp - Error numbers >= 32 are to be expected. svn path=/trunk/; revision=14118 --- reactos/lib/shell32/Makefile.in | 3 +- reactos/lib/shell32/brsfolder.c | 189 ++- reactos/lib/shell32/classes.c | 2 +- reactos/lib/shell32/clipboard.c | 2 +- reactos/lib/shell32/dialogs.c | 8 +- reactos/lib/shell32/enumidlist.c | 28 +- reactos/lib/shell32/enumidlist.h | 2 +- reactos/lib/shell32/folders.c | 2 +- reactos/lib/shell32/pidl.c | 2199 ++++++++++++++------------ reactos/lib/shell32/pidl.h | 3 + reactos/lib/shell32/shell32.spec | 531 ++++--- reactos/lib/shell32/shell32_Es.rc | 2 +- reactos/lib/shell32/shell32_Pt.rc | 32 + reactos/lib/shell32/shell32_main.c | 983 +++++++----- reactos/lib/shell32/shell32_main.h | 3 + reactos/lib/shell32/shelllink.c | 675 ++++++-- reactos/lib/shell32/shellpath.c | 4 +- reactos/lib/shell32/shfldr.h | 14 + reactos/lib/shell32/shfldr_desktop.c | 714 +++++---- reactos/lib/shell32/shfldr_fs.c | 1043 ++++++------ reactos/lib/shell32/shfldr_mycomp.c | 772 +++++---- reactos/lib/shell32/shfldr_unixfs.c | 21 + reactos/lib/shell32/shlexec.c | 2 +- reactos/lib/shell32/shlfileop.c | 140 +- reactos/lib/shell32/shlfolder.c | 4 +- reactos/lib/shell32/shlfsbind.c | 244 +-- reactos/lib/shell32/shlview.c | 8 +- 27 files changed, 4422 insertions(+), 3208 deletions(-) create mode 100644 reactos/lib/shell32/shfldr_unixfs.c diff --git a/reactos/lib/shell32/Makefile.in b/reactos/lib/shell32/Makefile.in index 36b71403ad8..9d74b969c1d 100644 --- a/reactos/lib/shell32/Makefile.in +++ b/reactos/lib/shell32/Makefile.in @@ -37,6 +37,7 @@ C_SRCS = \ shfldr_desktop.c \ shfldr_fs.c \ shfldr_mycomp.c \ + shfldr_unixfs.c \ shlexec.c \ shlfileop.c \ shlfolder.c \ @@ -77,7 +78,7 @@ version16.res: version16.rc $(LDPATH) $(RC16) $(RC16FLAGS) -fo$@ $(SRCDIR)/version16.rc shell.spec.c: shell.spec version16.res - $(WINEBUILD) $(DEFS) $(DLLFLAGS) -o $@ --main-module $(MODULE) --res version16.res --dll $(SRCDIR)/shell.spec + $(WINEBUILD) $(DEFS) $(DLLFLAGS) --dll -o $@ --main-module $(MODULE) --res version16.res --export $(SRCDIR)/shell.spec authors.c: $(TOPSRCDIR)/AUTHORS (LC_ALL=C; export LC_ALL; echo 'const char * const SHELL_Authors[] = {' && \ diff --git a/reactos/lib/shell32/brsfolder.c b/reactos/lib/shell32/brsfolder.c index 198c18d40f8..63be4a38079 100644 --- a/reactos/lib/shell32/brsfolder.c +++ b/reactos/lib/shell32/brsfolder.c @@ -55,68 +55,95 @@ static inline DWORD BrowseFlagsToSHCONTF(UINT ulFlags) return SHCONTF_FOLDERS | (ulFlags & BIF_BROWSEINCLUDEFILES ? SHCONTF_NONFOLDERS : 0); } +/****************************************************************************** + * InitializeTreeView [Internal] + * + * Called from WM_INITDIALOG handler. + * + * PARAMS + * hwndParent [I] The BrowseForFolder dialog + * root [I] ITEMIDLIST of the root shell folder + */ static void InitializeTreeView(HWND hwndParent, LPCITEMIDLIST root) { - HIMAGELIST hImageList; - IShellFolder * lpsf; - HRESULT hr; - IEnumIDList * pEnumIL = NULL; - LPITEMIDLIST parentofroot; - parentofroot = ILClone(root); - ILRemoveLastID(parentofroot); + LPITEMIDLIST pidlParent, pidlChild; + HIMAGELIST hImageList; + HRESULT hr; + IShellFolder *lpsfParent, *lpsfRoot; + IEnumIDList * pEnumChildren = NULL; - hwndTreeView = GetDlgItem (hwndParent, IDD_TREEVIEW); - Shell_GetImageList(NULL, &hImageList); + TRACE("dlg=%p tree=%p\n", hwndParent, hwndTreeView ); + + hwndTreeView = GetDlgItem (hwndParent, IDD_TREEVIEW); + if (!hwndTreeView) { + FIXME("Could not get handle to treeview control! Error: %08lx\n", GetLastError()); + return; + } + Shell_GetImageList(NULL, &hImageList); - TRACE("dlg=%p tree=%p\n", hwndParent, hwndTreeView ); + if (hImageList) + TreeView_SetImageList(hwndTreeView, hImageList, 0); - if (hImageList && hwndTreeView) - TreeView_SetImageList(hwndTreeView, hImageList, 0); + /* We want to call InsertTreeViewItem down the code, in order to insert + * the root item of the treeview. Due to InsertTreeViewItem's signature, + * we need the following to do this: + * + * + An ITEMIDLIST corresponding to _the parent_ of root. + * + An ITEMIDLIST, which is a relative path from root's parent to root + * (containing a single SHITEMID). + * + An IShellFolder interface pointer of root's parent folder. + * + * If root is 'Desktop', then root's parent is also 'Desktop'. + */ - if (_ILIsDesktop (root)) { - hr = SHGetDesktopFolder(&lpsf); - } else { - IShellFolder * lpsfdesktop; + pidlParent = ILClone(root); + ILRemoveLastID(pidlParent); + pidlChild = ILClone(ILFindLastID(root)); + + if (_ILIsDesktop(pidlParent)) { + hr = SHGetDesktopFolder(&lpsfParent); + } else { + IShellFolder *lpsfDesktop; + hr = SHGetDesktopFolder(&lpsfDesktop); + if (!SUCCEEDED(hr)) { + WARN("SHGetDesktopFolder failed! hr = %08lx\n", hr); + return; + } + hr = IShellFolder_BindToObject(lpsfDesktop, pidlParent, 0, &IID_IShellFolder, (LPVOID*)&lpsfParent); + IShellFolder_Release(lpsfDesktop); + } + + if (!SUCCEEDED(hr)) { + WARN("Could not bind to parent shell folder! hr = %08lx\n", hr); + return; + } - hr = SHGetDesktopFolder(&lpsfdesktop); - if (SUCCEEDED(hr)) { - hr = IShellFolder_BindToObject(lpsfdesktop, parentofroot, 0,(REFIID)&IID_IShellFolder,(LPVOID *)&lpsf); - IShellFolder_Release(lpsfdesktop); - } - } - if (SUCCEEDED(hr)) - { - IShellFolder * pSFRoot; - if (_ILIsPidlSimple(root)) - { - pSFRoot = lpsf; - IShellFolder_AddRef(pSFRoot); - } - else - hr = IShellFolder_BindToObject(lpsf,ILFindLastID(root),0,&IID_IShellFolder,(LPVOID *)&pSFRoot); - if (SUCCEEDED(hr)) - { - hr = IShellFolder_EnumObjects( - pSFRoot, - hwndParent, - BrowseFlagsToSHCONTF(lpBrowseInfo->ulFlags), - &pEnumIL); - IShellFolder_Release(pSFRoot); - } - } + if (pidlChild && pidlChild->mkid.cb) { + hr = IShellFolder_BindToObject(lpsfParent, pidlChild, 0, &IID_IShellFolder, (LPVOID*)&lpsfRoot); + } else { + lpsfRoot = lpsfParent; + hr = IShellFolder_AddRef(lpsfParent); + } + + if (!SUCCEEDED(hr)) { + WARN("Could not bind to root shell folder! hr = %08lx\n", hr); + IShellFolder_Release(lpsfParent); + return; + } - if (SUCCEEDED(hr) && hwndTreeView) - { - TreeView_DeleteAllItems(hwndTreeView); - TreeView_Expand(hwndTreeView, - InsertTreeViewItem(lpsf, _ILIsPidlSimple(root) ? root : ILFindLastID(root), parentofroot, pEnumIL, TVI_ROOT), - TVE_EXPAND); - } + hr = IShellFolder_EnumObjects(lpsfRoot, hwndParent, BrowseFlagsToSHCONTF(lpBrowseInfo->ulFlags), &pEnumChildren); + if (!SUCCEEDED(hr)) { + WARN("Could not get child iterator! hr = %08lx\n", hr); + IShellFolder_Release(lpsfParent); + IShellFolder_Release(lpsfRoot); + return; + } - if (SUCCEEDED(hr)) - IShellFolder_Release(lpsf); + TreeView_DeleteAllItems(hwndTreeView); + TreeView_Expand(hwndTreeView, InsertTreeViewItem(lpsfParent, pidlChild, pidlParent, pEnumChildren, TVI_ROOT), TVE_EXPAND); - TRACE("done\n"); + IShellFolder_Release(lpsfRoot); + IShellFolder_Release(lpsfParent); } static int GetIcon(LPITEMIDLIST lpi, UINT uFlags) @@ -149,12 +176,27 @@ static void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTVITEMW lpTV_ITEM) typedef struct tagID { - LPSHELLFOLDER lpsfParent; - LPITEMIDLIST lpi; - LPITEMIDLIST lpifq; - IEnumIDList* pEnumIL; + LPSHELLFOLDER lpsfParent; /* IShellFolder of the parent */ + LPITEMIDLIST lpi; /* PIDL relativ to parent */ + LPITEMIDLIST lpifq; /* Fully qualified PIDL */ + IEnumIDList* pEnumIL; /* Children iterator */ } TV_ITEMDATA, *LPTV_ITEMDATA; +/****************************************************************************** + * GetName [Internal] + * + * Query a shell folder for the display name of one of it's children + * + * PARAMS + * lpsf [I] IShellFolder interface of the folder to be queried. + * lpi [I] ITEMIDLIST of the child, relative to parent + * dwFlags [I] as in IShellFolder::GetDisplayNameOf + * lpFriendlyName [O] The desired display name in unicode + * + * RETURNS + * Success: TRUE + * Failure: FALSE + */ static BOOL GetName(LPSHELLFOLDER lpsf, LPCITEMIDLIST lpi, DWORD dwFlags, LPWSTR lpFriendlyName) { BOOL bSuccess=TRUE; @@ -175,7 +217,22 @@ static BOOL GetName(LPSHELLFOLDER lpsf, LPCITEMIDLIST lpi, DWORD dwFlags, LPWSTR return bSuccess; } -static HTREEITEM InsertTreeViewItem(IShellFolder * lpsf, LPCITEMIDLIST pidl, LPCITEMIDLIST pidlParent, IEnumIDList* pEnumIL, HTREEITEM hParent) +/****************************************************************************** + * InsertTreeViewItem [Internal] + * + * PARAMS + * lpsf [I] IShellFolder interface of the item's parent shell folder + * pidl [I] ITEMIDLIST of the child to insert, relativ to parent + * pidlParent [I] ITEMIDLIST of the parent shell folder + * pEnumIL [I] Iterator for the children of the item to be inserted + * hParent [I] The treeview-item that represents the parent shell folder + * + * RETURNS + * Success: Handle to the created and inserted treeview-item + * Failure: NULL + */ +static HTREEITEM InsertTreeViewItem(IShellFolder * lpsf, LPCITEMIDLIST pidl, + LPCITEMIDLIST pidlParent, IEnumIDList* pEnumIL, HTREEITEM hParent) { TVITEMW tvi; TVINSERTSTRUCTW tvins; @@ -211,6 +268,18 @@ static HTREEITEM InsertTreeViewItem(IShellFolder * lpsf, LPCITEMIDLIST pidl, LPC return (HTREEITEM)TreeView_InsertItemW(hwndTreeView, &tvins); } +/****************************************************************************** + * FillTreeView [Internal] + * + * For each child (given by lpe) of the parent shell folder, which is given by + * lpsf and whose PIDL is pidl, insert a treeview-item right under hParent + * + * PARAMS + * lpsf [I] IShellFolder interface of the parent shell folder + * pidl [I] ITEMIDLIST of the parent shell folder + * hParent [I] The treeview item that represents the parent shell folder + * lpe [I] An iterator for the children of the parent shell folder + */ static void FillTreeView(IShellFolder * lpsf, LPITEMIDLIST pidl, HTREEITEM hParent, IEnumIDList* lpe) { HTREEITEM hPrev = 0; @@ -219,7 +288,11 @@ static void FillTreeView(IShellFolder * lpsf, LPITEMIDLIST pidl, HTREEITEM hPar HRESULT hr; HWND hwnd=GetParent(hwndTreeView); - TRACE("%p %p %x\n",lpsf, pidl, (INT)hParent); + TRACE("%p %p %x %p\n",lpsf, pidl, (INT)hParent, lpe); + + /* No IEnumIDList -> No children */ + if (!lpe) return; + SetCapture(GetParent(hwndTreeView)); SetCursor(LoadCursorA(0, (LPSTR)IDC_WAIT)); diff --git a/reactos/lib/shell32/classes.c b/reactos/lib/shell32/classes.c index 0e47f6f9fb4..f5e8c382951 100644 --- a/reactos/lib/shell32/classes.c +++ b/reactos/lib/shell32/classes.c @@ -116,7 +116,7 @@ BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, DWORD len, BOOL b BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len ) { - static const WCHAR swShell[] = {'\\','s','h','e','l','l','\\',0}; + static const WCHAR swShell[] = {'s','h','e','l','l','\\',0}; static const WCHAR swCommand[] = {'\\','c','o','m','m','a','n','d',0}; BOOL ret = FALSE; diff --git a/reactos/lib/shell32/clipboard.c b/reactos/lib/shell32/clipboard.c index 71c929365b9..9f06d9703d3 100644 --- a/reactos/lib/shell32/clipboard.c +++ b/reactos/lib/shell32/clipboard.c @@ -26,7 +26,7 @@ * - a right mousebutton-copy sets the following formats: * classic: * Shell IDList Array - * Prefered Drop Effect + * Preferred Drop Effect * Shell Object Offsets * HDROP * FileName diff --git a/reactos/lib/shell32/dialogs.c b/reactos/lib/shell32/dialogs.c index 522e005819d..a243768bb63 100644 --- a/reactos/lib/shell32/dialogs.c +++ b/reactos/lib/shell32/dialogs.c @@ -127,9 +127,9 @@ INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar case WM_INITDIALOG : prfdp = (RUNFILEDLGPARAMS *)lParam ; SetWindowTextA (hwnd, prfdp->lpstrTitle) ; - SetClassLongA (hwnd, GCL_HICON, (LPARAM)prfdp->hIcon) ; - SendMessageA (GetDlgItem (hwnd, 12297), STM_SETICON, - (WPARAM)LoadIconA (NULL, (LPSTR)IDI_WINLOGO), 0); + SetClassLongPtrW (hwnd, GCLP_HICON, (LPARAM)prfdp->hIcon) ; + SendMessageW (GetDlgItem (hwnd, 12297), STM_SETICON, + (WPARAM)LoadIconW (NULL, (LPCWSTR)IDI_WINLOGO), 0); FillList (GetDlgItem (hwnd, 12298), NULL) ; SetFocus (GetDlgItem (hwnd, 12298)) ; return TRUE ; @@ -283,7 +283,7 @@ void FillList (HWND hCb, char *pszLatest) if (NULL != pszLatest) { - if (!strcasecmp (pszCmd, pszLatest)) + if (!lstrcmpiA(pszCmd, pszLatest)) { /* sprintf (szDbgMsg, "Found existing (%d).\n", Nix) ; diff --git a/reactos/lib/shell32/enumidlist.c b/reactos/lib/shell32/enumidlist.c index 1d78e29cbe3..072e3288f3d 100644 --- a/reactos/lib/shell32/enumidlist.c +++ b/reactos/lib/shell32/enumidlist.c @@ -25,6 +25,7 @@ #define COBJMACROS #include "wine/debug.h" +#include "wine/unicode.h" #include "windef.h" #include "winbase.h" #include "winreg.h" @@ -103,24 +104,27 @@ BOOL AddToEnumList( */ BOOL CreateFolderEnumList( IEnumIDList *list, - LPCSTR lpszPath, + LPCWSTR lpszPath, DWORD dwFlags) { LPITEMIDLIST pidl=NULL; - WIN32_FIND_DATAA stffile; + WIN32_FIND_DATAW stffile; HANDLE hFile; - CHAR szPath[MAX_PATH]; + WCHAR szPath[MAX_PATH]; BOOL succeeded = TRUE; + const static WCHAR stars[] = { '*','.','*',0 }; + const static WCHAR dot[] = { '.',0 }; + const static WCHAR dotdot[] = { '.','.',0 }; - TRACE("(%p)->(path=%s flags=0x%08lx) \n",list,debugstr_a(lpszPath),dwFlags); + TRACE("(%p)->(path=%s flags=0x%08lx) \n",list,debugstr_w(lpszPath),dwFlags); if(!lpszPath || !lpszPath[0]) return FALSE; - strcpy(szPath, lpszPath); - PathAddBackslashA(szPath); - strcat(szPath,"*.*"); + strcpyW(szPath, lpszPath); + PathAddBackslashW(szPath); + strcatW(szPath,stars); - hFile = FindFirstFileA(szPath,&stffile); + hFile = FindFirstFileW(szPath,&stffile); if ( hFile != INVALID_HANDLE_VALUE ) { BOOL findFinished = FALSE; @@ -132,21 +136,21 @@ BOOL CreateFolderEnumList( { if ( (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && dwFlags & SHCONTF_FOLDERS && - strcmp (stffile.cFileName, ".") && strcmp (stffile.cFileName, "..")) + strcmpW(stffile.cFileName, dot) && strcmpW(stffile.cFileName, dotdot)) { - pidl = _ILCreateFromFindDataA(&stffile); + pidl = _ILCreateFromFindDataW(&stffile); succeeded = succeeded && AddToEnumList(list, pidl); } else if (!(stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && dwFlags & SHCONTF_NONFOLDERS) { - pidl = _ILCreateFromFindDataA(&stffile); + pidl = _ILCreateFromFindDataW(&stffile); succeeded = succeeded && AddToEnumList(list, pidl); } } if (succeeded) { - if (!FindNextFileA(hFile, &stffile)) + if (!FindNextFileW(hFile, &stffile)) { if (GetLastError() == ERROR_NO_MORE_FILES) findFinished = TRUE; diff --git a/reactos/lib/shell32/enumidlist.h b/reactos/lib/shell32/enumidlist.h index 53b8b5ff111..26972aa191a 100644 --- a/reactos/lib/shell32/enumidlist.h +++ b/reactos/lib/shell32/enumidlist.h @@ -25,6 +25,6 @@ BOOL AddToEnumList(IEnumIDList *list, LPITEMIDLIST pidl); /* Enumerates the folders and/or files (depending on dwFlags) in lpszPath and * adds them to the already-created list. */ -BOOL CreateFolderEnumList(IEnumIDList *list, LPCSTR lpszPath, DWORD dwFlags); +BOOL CreateFolderEnumList(IEnumIDList *list, LPCWSTR lpszPath, DWORD dwFlags); #endif /* ndef __ENUMIDLIST_H__ */ diff --git a/reactos/lib/shell32/folders.c b/reactos/lib/shell32/folders.c index 12b6fe4d52a..efa3b2bdcb7 100644 --- a/reactos/lib/shell32/folders.c +++ b/reactos/lib/shell32/folders.c @@ -328,7 +328,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( found = TRUE; } - else if (!strcasecmp(sTemp, "lnkfile")) + else if (!lstrcmpiA(sTemp, "lnkfile")) { /* extract icon from shell shortcut */ IShellFolder* dsf; diff --git a/reactos/lib/shell32/pidl.c b/reactos/lib/shell32/pidl.c index d0f4206c5b7..1c1cf1b9158 100644 --- a/reactos/lib/shell32/pidl.c +++ b/reactos/lib/shell32/pidl.c @@ -1,7 +1,7 @@ /* - * pidl Handling + * pidl Handling * - * Copyright 1998 Juergen Schmied + * Copyright 1998 Juergen Schmied * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -57,7 +57,7 @@ extern LPVOID WINAPI Alloc(INT); extern BOOL WINAPI Free(LPVOID); /************************************************************************* - * ILGetDisplayNameEx [SHELL32.186] + * ILGetDisplayNameEx [SHELL32.186] * * Retrieves the display name of an ItemIDList * @@ -75,106 +75,108 @@ extern BOOL WINAPI Free(LPVOID); */ BOOL WINAPI ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type) { - BOOL ret = FALSE; - WCHAR wPath[MAX_PATH]; + BOOL ret = FALSE; + WCHAR wPath[MAX_PATH]; - TRACE("%p %p %p %ld\n", psf, pidl, path, type); + TRACE("%p %p %p %ld\n", psf, pidl, path, type); - if (!pidl || !path) - return FALSE; + if (!pidl || !path) + return FALSE; - ret = ILGetDisplayNameExW(psf, pidl, wPath, type); - WideCharToMultiByte(CP_ACP, 0, wPath, -1, path, MAX_PATH, NULL, NULL); - TRACE("%p %p %s\n", psf, pidl, debugstr_a(path)); + ret = ILGetDisplayNameExW(psf, pidl, wPath, type); + WideCharToMultiByte(CP_ACP, 0, wPath, -1, path, MAX_PATH, NULL, NULL); + TRACE("%p %p %s\n", psf, pidl, debugstr_a(path)); - return ret; + return ret; } BOOL WINAPI ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type) { - LPSHELLFOLDER psfParent, lsf = psf; - HRESULT ret = NO_ERROR; - LPCITEMIDLIST pidllast; - STRRET strret; - DWORD flag; + LPSHELLFOLDER psfParent, lsf = psf; + HRESULT ret = NO_ERROR; + LPCITEMIDLIST pidllast; + STRRET strret; + DWORD flag; - TRACE("%p %p %p %ld\n", psf, pidl, path, type); + TRACE("%p %p %p %ld\n", psf, pidl, path, type); - if (!pidl || !path) - return FALSE; + if (!pidl || !path) + return FALSE; - if (!lsf) - { - ret = SHGetDesktopFolder(&lsf); - if (FAILED(ret)) - return FALSE; - } + if (!lsf) + { + ret = SHGetDesktopFolder(&lsf); + if (FAILED(ret)) + return FALSE; + } - if (type >= 0 && type <= 2) - { - switch (type) - { - case ILGDN_FORPARSING: - flag = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR; - break; - case ILGDN_NORMAL: - flag = SHGDN_NORMAL; - break; - case ILGDN_INFOLDER: - flag = SHGDN_INFOLDER; - break; - default: - FIXME("Unknown type parameter = %lx\n", type); - flag = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR; - break; - } - if (!*(const WORD*)pidl || type == ILGDN_FORPARSING) - { - ret = IShellFolder_GetDisplayNameOf(lsf, pidl, flag, &strret); - if (SUCCEEDED(ret)) - { - ret = StrRetToStrNW(path, MAX_PATH, &strret, pidl); - } - } - else - { - ret = SHBindToParent(pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidllast); - if (SUCCEEDED(ret)) - { - ret = IShellFolder_GetDisplayNameOf(psfParent, pidllast, flag, &strret); - if (SUCCEEDED(ret)) - { - ret = StrRetToStrNW(path, MAX_PATH, &strret, pidllast); - } - IShellFolder_Release(psfParent); - } - } - } + if (type >= 0 && type <= 2) + { + switch (type) + { + case ILGDN_FORPARSING: + flag = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR; + break; + case ILGDN_NORMAL: + flag = SHGDN_NORMAL; + break; + case ILGDN_INFOLDER: + flag = SHGDN_INFOLDER; + break; + default: + FIXME("Unknown type parameter = %lx\n", type); + flag = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR; + break; + } + if (!*(const WORD*)pidl || type == ILGDN_FORPARSING) + { + ret = IShellFolder_GetDisplayNameOf(lsf, pidl, flag, &strret); + if (SUCCEEDED(ret)) + { + ret = StrRetToStrNW(path, MAX_PATH, &strret, pidl); + } + } + else + { + ret = SHBindToParent(pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidllast); + if (SUCCEEDED(ret)) + { + ret = IShellFolder_GetDisplayNameOf(psfParent, pidllast, flag, &strret); + if (SUCCEEDED(ret)) + { + ret = StrRetToStrNW(path, MAX_PATH, &strret, pidllast); + } + IShellFolder_Release(psfParent); + } + } + } - TRACE("%p %p %s\n", psf, pidl, debugstr_w(path)); + TRACE("%p %p %s\n", psf, pidl, debugstr_w(path)); - if (!psf) - IShellFolder_Release(lsf); - return SUCCEEDED(ret); + if (!psf) + IShellFolder_Release(lsf); + return SUCCEEDED(ret); } BOOL WINAPI ILGetDisplayNameEx(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPVOID path, DWORD type) { - TRACE_(shell)("%p %p %p %ld\n", psf, pidl, path, type); - if (SHELL_OsIsUnicode()) - return ILGetDisplayNameExW(psf, pidl, path, type); - return ILGetDisplayNameExA(psf, pidl, path, type); + TRACE_(shell)("%p %p %p %ld\n", psf, pidl, path, type); + + if (SHELL_OsIsUnicode()) + return ILGetDisplayNameExW(psf, pidl, path, type); + return ILGetDisplayNameExA(psf, pidl, path, type); } /************************************************************************* - * ILGetDisplayName [SHELL32.15] + * ILGetDisplayName [SHELL32.15] */ BOOL WINAPI ILGetDisplayName(LPCITEMIDLIST pidl, LPVOID path) { - TRACE_(shell)("%p %p\n", pidl, path); - if (SHELL_OsIsUnicode()) - return ILGetDisplayNameExW(NULL, pidl, path, ILGDN_FORPARSING); - return ILGetDisplayNameExA(NULL, pidl, path, ILGDN_FORPARSING); + TRACE_(shell)("%p %p\n", pidl, path); + + if (SHELL_OsIsUnicode()) + return ILGetDisplayNameExW(NULL, pidl, path, ILGDN_FORPARSING); + return ILGetDisplayNameExA(NULL, pidl, path, ILGDN_FORPARSING); } /************************************************************************* @@ -185,20 +187,21 @@ BOOL WINAPI ILGetDisplayName(LPCITEMIDLIST pidl, LPVOID path) */ LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl) { - LPCITEMIDLIST pidlLast = pidl; + LPCITEMIDLIST pidlLast = pidl; - TRACE("(pidl=%p)\n",pidl); + TRACE("(pidl=%p)\n",pidl); - if (!pidl) - return NULL; + if (!pidl) + return NULL; - while (pidl->mkid.cb) - { - pidlLast = pidl; - pidl = ILGetNext(pidl); - } - return (LPITEMIDLIST)pidlLast; + while (pidl->mkid.cb) + { + pidlLast = pidl; + pidl = ILGetNext(pidl); + } + return (LPITEMIDLIST)pidlLast; } + /************************************************************************* * ILRemoveLastID [SHELL32.17] * @@ -207,12 +210,12 @@ LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl) */ BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl) { - TRACE_(shell)("pidl=%p\n",pidl); + TRACE_(shell)("pidl=%p\n",pidl); - if (!pidl || !pidl->mkid.cb) - return 0; - ILFindLastID(pidl)->mkid.cb = 0; - return 1; + if (!pidl || !pidl->mkid.cb) + return 0; + ILFindLastID(pidl)->mkid.cb = 0; + return 1; } /************************************************************************* @@ -222,22 +225,24 @@ BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl) * duplicate an idlist */ LPITEMIDLIST WINAPI ILClone (LPCITEMIDLIST pidl) -{ DWORD len; - LPITEMIDLIST newpidl; +{ + DWORD len; + LPITEMIDLIST newpidl; - if (!pidl) - return NULL; + if (!pidl) + return NULL; - len = ILGetSize(pidl); - newpidl = (LPITEMIDLIST)SHAlloc(len); - if (newpidl) - memcpy(newpidl,pidl,len); + len = ILGetSize(pidl); + newpidl = (LPITEMIDLIST)SHAlloc(len); + if (newpidl) + memcpy(newpidl,pidl,len); - TRACE("pidl=%p newpidl=%p\n",pidl, newpidl); - pdump(pidl); + TRACE("pidl=%p newpidl=%p\n",pidl, newpidl); + pdump(pidl); - return newpidl; + return newpidl; } + /************************************************************************* * ILCloneFirst [SHELL32.19] * @@ -245,27 +250,28 @@ LPITEMIDLIST WINAPI ILClone (LPCITEMIDLIST pidl) * duplicates the first idlist of a complex pidl */ LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST pidl) -{ DWORD len; - LPITEMIDLIST pidlNew = NULL; +{ + DWORD len; + LPITEMIDLIST pidlNew = NULL; - TRACE("pidl=%p \n",pidl); - pdump(pidl); + TRACE("pidl=%p \n",pidl); + pdump(pidl); - if (pidl) - { - len = pidl->mkid.cb; - pidlNew = (LPITEMIDLIST) SHAlloc (len+2); - if (pidlNew) - { - memcpy(pidlNew,pidl,len+2); /* 2 -> mind a desktop pidl */ + if (pidl) + { + len = pidl->mkid.cb; + pidlNew = (LPITEMIDLIST) SHAlloc (len+2); + if (pidlNew) + { + memcpy(pidlNew,pidl,len+2); /* 2 -> mind a desktop pidl */ - if (len) - ILGetNext(pidlNew)->mkid.cb = 0x00; - } - } - TRACE("-- newpidl=%p\n",pidlNew); + if (len) + ILGetNext(pidlNew)->mkid.cb = 0x00; + } + } + TRACE("-- newpidl=%p\n",pidlNew); - return pidlNew; + return pidlNew; } /************************************************************************* @@ -275,51 +281,58 @@ LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST pidl) * the first two bytes are the len, the pidl is following then */ HRESULT WINAPI ILLoadFromStream (IStream * pStream, LPITEMIDLIST * ppPidl) -{ WORD wLen = 0; - DWORD dwBytesRead; - HRESULT ret = E_FAIL; +{ + WORD wLen = 0; + DWORD dwBytesRead; + HRESULT ret = E_FAIL; - TRACE_(shell)("%p %p\n", pStream , ppPidl); + TRACE_(shell)("%p %p\n", pStream , ppPidl); - if (*ppPidl) - { SHFree(*ppPidl); - *ppPidl = NULL; - } + if (*ppPidl) + { + SHFree(*ppPidl); + *ppPidl = NULL; + } - IStream_AddRef (pStream); + IStream_AddRef (pStream); - if (SUCCEEDED(IStream_Read(pStream, (LPVOID)&wLen, 2, &dwBytesRead))) - { - TRACE("PIDL length is %d\n", wLen); - if (wLen != 0) { - *ppPidl = SHAlloc (wLen); - if (SUCCEEDED(IStream_Read(pStream, *ppPidl , wLen, &dwBytesRead))) { - TRACE("Stream read OK\n"); - ret = S_OK; - } else { - WARN("reading pidl failed\n"); - SHFree(*ppPidl); - *ppPidl = NULL; - } - } else { - *ppPidl = NULL; - ret = S_OK; - } - } + if (SUCCEEDED(IStream_Read(pStream, (LPVOID)&wLen, 2, &dwBytesRead))) + { + TRACE("PIDL length is %d\n", wLen); + if (wLen != 0) + { + *ppPidl = SHAlloc (wLen); + if (SUCCEEDED(IStream_Read(pStream, *ppPidl , wLen, &dwBytesRead))) + { + TRACE("Stream read OK\n"); + ret = S_OK; + } + else + { + WARN("reading pidl failed\n"); + SHFree(*ppPidl); + *ppPidl = NULL; + } + } + else + { + *ppPidl = NULL; + ret = S_OK; + } + } - /* we are not yet fully compatible */ - if (*ppPidl && !pcheck(*ppPidl)) - { - WARN("Check failed\n"); - SHFree(*ppPidl); - *ppPidl = NULL; - } + /* we are not yet fully compatible */ + if (*ppPidl && !pcheck(*ppPidl)) + { + WARN("Check failed\n"); + SHFree(*ppPidl); + *ppPidl = NULL; + } - - IStream_Release (pStream); - TRACE("done\n"); - return ret; + IStream_Release (pStream); + TRACE("done\n"); + return ret; } /************************************************************************* @@ -330,30 +343,29 @@ HRESULT WINAPI ILLoadFromStream (IStream * pStream, LPITEMIDLIST * ppPidl) */ HRESULT WINAPI ILSaveToStream (IStream * pStream, LPCITEMIDLIST pPidl) { - LPCITEMIDLIST pidl; - WORD wLen = 0; - HRESULT ret = E_FAIL; + LPCITEMIDLIST pidl; + WORD wLen = 0; + HRESULT ret = E_FAIL; - TRACE_(shell)("%p %p\n", pStream, pPidl); + TRACE_(shell)("%p %p\n", pStream, pPidl); - IStream_AddRef (pStream); + IStream_AddRef (pStream); - pidl = pPidl; - while (pidl->mkid.cb) - { - wLen += sizeof(WORD) + pidl->mkid.cb; - pidl = ILGetNext(pidl); - } + pidl = pPidl; + while (pidl->mkid.cb) + { + wLen += sizeof(WORD) + pidl->mkid.cb; + pidl = ILGetNext(pidl); + } - if (SUCCEEDED(IStream_Write(pStream, (LPVOID)&wLen, 2, NULL))) - { - if (SUCCEEDED(IStream_Write(pStream, pPidl, wLen, NULL))) - { ret = S_OK; - } - } - IStream_Release (pStream); + if (SUCCEEDED(IStream_Write(pStream, (LPVOID)&wLen, 2, NULL))) + { + if (SUCCEEDED(IStream_Write(pStream, pPidl, wLen, NULL))) + ret = S_OK; + } + IStream_Release (pStream); - return ret; + return ret; } /************************************************************************* @@ -375,45 +387,37 @@ HRESULT WINAPI ILSaveToStream (IStream * pStream, LPCITEMIDLIST pPidl) */ HRESULT WINAPI SHILCreateFromPathA(LPCSTR path, LPITEMIDLIST * ppidl, DWORD * attributes) { - LPSHELLFOLDER sf; - WCHAR lpszDisplayName[MAX_PATH]; - DWORD pchEaten; - HRESULT ret = E_FAIL; + WCHAR lpszDisplayName[MAX_PATH]; - TRACE_(shell)("%s %p 0x%08lx\n", path, ppidl, attributes ? *attributes : 0); + TRACE_(shell)("%s %p 0x%08lx\n", path, ppidl, attributes ? *attributes : 0); - if (!MultiByteToWideChar(CP_ACP, 0, path, -1, lpszDisplayName, MAX_PATH)) - lpszDisplayName[MAX_PATH-1] = 0; + if (!MultiByteToWideChar(CP_ACP, 0, path, -1, lpszDisplayName, MAX_PATH)) + lpszDisplayName[MAX_PATH-1] = 0; - if (SUCCEEDED (SHGetDesktopFolder(&sf))) - { - ret = IShellFolder_ParseDisplayName(sf, 0, NULL, lpszDisplayName, &pchEaten, ppidl, attributes); - IShellFolder_Release(sf); - } - return ret; + return SHILCreateFromPathW(lpszDisplayName, ppidl, attributes); } HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST * ppidl, DWORD * attributes) { - LPSHELLFOLDER sf; - DWORD pchEaten; - HRESULT ret = E_FAIL; + LPSHELLFOLDER sf; + DWORD pchEaten; + HRESULT ret = E_FAIL; - TRACE_(shell)("%s %p 0x%08lx\n", debugstr_w(path), ppidl, attributes ? *attributes : 0); + TRACE_(shell)("%s %p 0x%08lx\n", debugstr_w(path), ppidl, attributes ? *attributes : 0); - if (SUCCEEDED (SHGetDesktopFolder(&sf))) - { - ret = IShellFolder_ParseDisplayName(sf, 0, NULL, (LPWSTR)path, &pchEaten, ppidl, attributes); - IShellFolder_Release(sf); - } - return ret; + if (SUCCEEDED (SHGetDesktopFolder(&sf))) + { + ret = IShellFolder_ParseDisplayName(sf, 0, NULL, (LPWSTR)path, &pchEaten, ppidl, attributes); + IShellFolder_Release(sf); + } + return ret; } HRESULT WINAPI SHILCreateFromPathAW (LPCVOID path, LPITEMIDLIST * ppidl, DWORD * attributes) { - if ( SHELL_OsIsUnicode()) - return SHILCreateFromPathW (path, ppidl, attributes); - return SHILCreateFromPathA (path, ppidl, attributes); + if ( SHELL_OsIsUnicode()) + return SHILCreateFromPathW (path, ppidl, attributes); + return SHILCreateFromPathA (path, ppidl, attributes); } /************************************************************************* @@ -422,9 +426,9 @@ HRESULT WINAPI SHILCreateFromPathAW (LPCVOID path, LPITEMIDLIST * ppidl, DWORD * * Create an ItemIDList to one of the special folders. * PARAMS - * hwndOwner [in] - * nFolder [in] CSIDL_xxxxx - * fCreate [in] Create folder if it does not exist + * hwndOwner [in] + * nFolder [in] CSIDL_xxxxx + * fCreate [in] Create folder if it does not exist * * RETURNS * Success: The newly created pidl @@ -436,14 +440,15 @@ HRESULT WINAPI SHILCreateFromPathAW (LPCVOID path, LPITEMIDLIST * ppidl, DWORD * * shells IMalloc interface, aka ILFree. */ LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, DWORD nFolder, BOOL fCreate) -{ LPITEMIDLIST ppidl; - TRACE_(shell)("(hwnd=%p,csidl=0x%lx,%s).\n", hwndOwner, nFolder, fCreate ? "T" : "F"); +{ + LPITEMIDLIST ppidl; + TRACE_(shell)("(hwnd=%p,csidl=0x%lx,%s).\n", hwndOwner, nFolder, fCreate ? "T" : "F"); - if (fCreate) - nFolder |= CSIDL_FLAG_CREATE; + if (fCreate) + nFolder |= CSIDL_FLAG_CREATE; - SHGetSpecialFolderLocation(hwndOwner, nFolder, &ppidl); - return ppidl; + SHGetSpecialFolderLocation(hwndOwner, nFolder, &ppidl); + return ppidl; } /************************************************************************* @@ -461,21 +466,22 @@ LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, DWORD nFolder, BOOL fCr * exported by ordinal. */ LPITEMIDLIST WINAPI ILGlobalClone(LPCITEMIDLIST pidl) -{ DWORD len; - LPITEMIDLIST newpidl; +{ + DWORD len; + LPITEMIDLIST newpidl; - if (!pidl) - return NULL; + if (!pidl) + return NULL; - len = ILGetSize(pidl); - newpidl = (LPITEMIDLIST)Alloc(len); - if (newpidl) - memcpy(newpidl,pidl,len); + len = ILGetSize(pidl); + newpidl = (LPITEMIDLIST)Alloc(len); + if (newpidl) + memcpy(newpidl,pidl,len); - TRACE("pidl=%p newpidl=%p\n",pidl, newpidl); - pdump(pidl); + TRACE("pidl=%p newpidl=%p\n",pidl, newpidl); + pdump(pidl); - return newpidl; + return newpidl; } /************************************************************************* @@ -484,42 +490,45 @@ LPITEMIDLIST WINAPI ILGlobalClone(LPCITEMIDLIST pidl) */ BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) { - char szData1[MAX_PATH]; - char szData2[MAX_PATH]; + char szData1[MAX_PATH]; + char szData2[MAX_PATH]; - LPCITEMIDLIST pidltemp1 = pidl1; - LPCITEMIDLIST pidltemp2 = pidl2; + LPCITEMIDLIST pidltemp1 = pidl1; + LPCITEMIDLIST pidltemp2 = pidl2; - TRACE("pidl1=%p pidl2=%p\n",pidl1, pidl2); + TRACE("pidl1=%p pidl2=%p\n",pidl1, pidl2); - /* explorer reads from registry directly (StreamMRU), - so we can only check here */ - if ((!pcheck (pidl1)) || (!pcheck (pidl2))) return FALSE; + /* + * Explorer reads from registry directly (StreamMRU), + * so we can only check here + */ + if (!pcheck(pidl1) || !pcheck (pidl2)) + return FALSE; - pdump (pidl1); - pdump (pidl2); + pdump (pidl1); + pdump (pidl2); - if ( (!pidl1) || (!pidl2) ) return FALSE; + if (!pidl1 || !pidl2) + return FALSE; - while (pidltemp1->mkid.cb && pidltemp2->mkid.cb) - { - _ILSimpleGetText(pidltemp1, szData1, MAX_PATH); - _ILSimpleGetText(pidltemp2, szData2, MAX_PATH); + while (pidltemp1->mkid.cb && pidltemp2->mkid.cb) + { + _ILSimpleGetText(pidltemp1, szData1, MAX_PATH); + _ILSimpleGetText(pidltemp2, szData2, MAX_PATH); - if (strcasecmp ( szData1, szData2 )!=0 ) - return FALSE; + if (strcasecmp( szData1, szData2 )) + return FALSE; - pidltemp1 = ILGetNext(pidltemp1); - pidltemp2 = ILGetNext(pidltemp2); - } + pidltemp1 = ILGetNext(pidltemp1); + pidltemp2 = ILGetNext(pidltemp2); + } - if (!pidltemp1->mkid.cb && !pidltemp2->mkid.cb) - { - return TRUE; - } + if (!pidltemp1->mkid.cb && !pidltemp2->mkid.cb) + return TRUE; - return FALSE; + return FALSE; } + /************************************************************************* * ILIsParent [SHELL32.23] * @@ -542,35 +551,37 @@ BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) */ BOOL WINAPI ILIsParent(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate) { - char szData1[MAX_PATH]; - char szData2[MAX_PATH]; + char szData1[MAX_PATH]; + char szData2[MAX_PATH]; + LPCITEMIDLIST pParent = pidlParent; + LPCITEMIDLIST pChild = pidlChild; - LPCITEMIDLIST pParent = pidlParent; - LPCITEMIDLIST pChild = pidlChild; + TRACE("%p %p %x\n", pidlParent, pidlChild, bImmediate); - TRACE("%p %p %x\n", pidlParent, pidlChild, bImmediate); + if (!pParent || !pChild) + return FALSE; - if (!pParent || !pChild) return FALSE; + while (pParent->mkid.cb && pChild->mkid.cb) + { + _ILSimpleGetText(pParent, szData1, MAX_PATH); + _ILSimpleGetText(pChild, szData2, MAX_PATH); - while (pParent->mkid.cb && pChild->mkid.cb) - { - _ILSimpleGetText(pParent, szData1, MAX_PATH); - _ILSimpleGetText(pChild, szData2, MAX_PATH); + if (strcasecmp( szData1, szData2 )) + return FALSE; - if (strcasecmp ( szData1, szData2 )!=0 ) - return FALSE; + pParent = ILGetNext(pParent); + pChild = ILGetNext(pChild); + } - pParent = ILGetNext(pParent); - pChild = ILGetNext(pChild); - } + /* child shorter or has equal length to parent */ + if (pParent->mkid.cb || !pChild->mkid.cb) + return FALSE; - if ( pParent->mkid.cb || ! pChild->mkid.cb) /* child shorter or has equal length to parent */ - return FALSE; + /* not immediate descent */ + if ( ILGetNext(pChild)->mkid.cb && bImmediate) + return FALSE; - if ( ILGetNext(pChild)->mkid.cb && bImmediate) /* not immediate descent */ - return FALSE; - - return TRUE; + return TRUE; } /************************************************************************* @@ -594,49 +605,47 @@ BOOL WINAPI ILIsParent(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL b */ LPITEMIDLIST WINAPI ILFindChild(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) { - char szData1[MAX_PATH]; - char szData2[MAX_PATH]; + char szData1[MAX_PATH]; + char szData2[MAX_PATH]; - LPCITEMIDLIST pidltemp1 = pidl1; - LPCITEMIDLIST pidltemp2 = pidl2; - LPCITEMIDLIST ret=NULL; + LPCITEMIDLIST pidltemp1 = pidl1; + LPCITEMIDLIST pidltemp2 = pidl2; + LPCITEMIDLIST ret=NULL; - TRACE("pidl1=%p pidl2=%p\n",pidl1, pidl2); + TRACE("pidl1=%p pidl2=%p\n",pidl1, pidl2); - /* explorer reads from registry directly (StreamMRU), - so we can only check here */ - if ((!pcheck (pidl1)) || (!pcheck (pidl2))) - return FALSE; + /* explorer reads from registry directly (StreamMRU), + so we can only check here */ + if ((!pcheck (pidl1)) || (!pcheck (pidl2))) + return FALSE; - pdump (pidl1); - pdump (pidl2); + pdump (pidl1); + pdump (pidl2); - if ( _ILIsDesktop(pidl1) ) - { - ret = pidl2; - } - else - { - while (pidltemp1->mkid.cb && pidltemp2->mkid.cb) - { - _ILSimpleGetText(pidltemp1, szData1, MAX_PATH); - _ILSimpleGetText(pidltemp2, szData2, MAX_PATH); + if (_ILIsDesktop(pidl1)) + { + ret = pidl2; + } + else + { + while (pidltemp1->mkid.cb && pidltemp2->mkid.cb) + { + _ILSimpleGetText(pidltemp1, szData1, MAX_PATH); + _ILSimpleGetText(pidltemp2, szData2, MAX_PATH); - if (strcasecmp(szData1,szData2)) - break; + if (strcasecmp(szData1,szData2)) + break; - pidltemp1 = ILGetNext(pidltemp1); - pidltemp2 = ILGetNext(pidltemp2); - ret = pidltemp2; - } + pidltemp1 = ILGetNext(pidltemp1); + pidltemp2 = ILGetNext(pidltemp2); + ret = pidltemp2; + } - if (pidltemp1->mkid.cb) - { - ret = NULL; /* elements of pidl1 left*/ - } - } - TRACE_(shell)("--- %p\n", ret); - return (LPITEMIDLIST)ret; /* pidl 1 is shorter */ + if (pidltemp1->mkid.cb) + ret = NULL; /* elements of pidl1 left*/ + } + TRACE_(shell)("--- %p\n", ret); + return (LPITEMIDLIST)ret; /* pidl 1 is shorter */ } /************************************************************************* @@ -660,40 +669,40 @@ LPITEMIDLIST WINAPI ILFindChild(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) */ LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) { - DWORD len1,len2; - LPITEMIDLIST pidlNew; + DWORD len1,len2; + LPITEMIDLIST pidlNew; - TRACE("pidl=%p pidl=%p\n",pidl1,pidl2); + TRACE("pidl=%p pidl=%p\n",pidl1,pidl2); - if(!pidl1 && !pidl2) return NULL; + if (!pidl1 && !pidl2) return NULL; - pdump (pidl1); - pdump (pidl2); + pdump (pidl1); + pdump (pidl2); - if(!pidl1) - { - pidlNew = ILClone(pidl2); - return pidlNew; - } + if (!pidl1) + { + pidlNew = ILClone(pidl2); + return pidlNew; + } - if(!pidl2) - { - pidlNew = ILClone(pidl1); - return pidlNew; - } + if (!pidl2) + { + pidlNew = ILClone(pidl1); + return pidlNew; + } - len1 = ILGetSize(pidl1)-2; - len2 = ILGetSize(pidl2); - pidlNew = SHAlloc(len1+len2); + len1 = ILGetSize(pidl1)-2; + len2 = ILGetSize(pidl2); + pidlNew = SHAlloc(len1+len2); - if (pidlNew) - { - memcpy(pidlNew,pidl1,len1); - memcpy(((BYTE *)pidlNew)+len1,pidl2,len2); - } + if (pidlNew) + { + memcpy(pidlNew,pidl1,len1); + memcpy(((BYTE *)pidlNew)+len1,pidl2,len2); + } - /* TRACE(pidl,"--new pidl=%p\n",pidlNew);*/ - return pidlNew; + /* TRACE(pidl,"--new pidl=%p\n",pidlNew);*/ + return pidlNew; } /************************************************************************* @@ -703,57 +712,61 @@ LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) */ HRESULT WINAPI SHGetRealIDL(LPSHELLFOLDER lpsf, LPCITEMIDLIST pidlSimple, LPITEMIDLIST *pidlReal) { - IDataObject* pDataObj; - HRESULT hr = IShellFolder_GetUIObjectOf(lpsf, 0, 1, &pidlSimple, &IID_IDataObject, 0, (LPVOID*)&pDataObj); + IDataObject* pDataObj; + HRESULT hr; - if (SUCCEEDED(hr)) { - STGMEDIUM medium; - FORMATETC fmt; + hr = IShellFolder_GetUIObjectOf(lpsf, 0, 1, &pidlSimple, + &IID_IDataObject, 0, (LPVOID*)&pDataObj); + if (SUCCEEDED(hr)) + { + STGMEDIUM medium; + FORMATETC fmt; - fmt.cfFormat = RegisterClipboardFormatA(CFSTR_SHELLIDLIST); - fmt.ptd = NULL; - fmt.dwAspect = DVASPECT_CONTENT; - fmt.lindex = -1; - fmt.tymed = TYMED_HGLOBAL; + fmt.cfFormat = RegisterClipboardFormatA(CFSTR_SHELLIDLIST); + fmt.ptd = NULL; + fmt.dwAspect = DVASPECT_CONTENT; + fmt.lindex = -1; + fmt.tymed = TYMED_HGLOBAL; - hr = IDataObject_GetData(pDataObj, &fmt, &medium); + hr = IDataObject_GetData(pDataObj, &fmt, &medium); - IDataObject_Release(pDataObj); + IDataObject_Release(pDataObj); - if (SUCCEEDED(hr)) { - /*assert(pida->cidl==1);*/ - LPIDA pida = (LPIDA)GlobalLock(medium.u.hGlobal); + if (SUCCEEDED(hr)) + { + /*assert(pida->cidl==1);*/ + LPIDA pida = (LPIDA)GlobalLock(medium.u.hGlobal); - LPCITEMIDLIST pidl_folder = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]); - LPCITEMIDLIST pidl_child = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[1]); + LPCITEMIDLIST pidl_folder = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]); + LPCITEMIDLIST pidl_child = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[1]); - *pidlReal = ILCombine(pidl_folder, pidl_child); + *pidlReal = ILCombine(pidl_folder, pidl_child); - if (!*pidlReal) - hr = E_OUTOFMEMORY; + if (!*pidlReal) + hr = E_OUTOFMEMORY; - GlobalUnlock(medium.u.hGlobal); - GlobalFree(medium.u.hGlobal); - } - } + GlobalUnlock(medium.u.hGlobal); + GlobalFree(medium.u.hGlobal); + } + } - return hr; + return hr; } /************************************************************************* * SHLogILFromFSIL [SHELL32.95] * * NOTES - * pild = CSIDL_DESKTOP ret = 0 - * pild = CSIDL_DRIVES ret = 0 + * pild = CSIDL_DESKTOP ret = 0 + * pild = CSIDL_DRIVES ret = 0 */ LPITEMIDLIST WINAPI SHLogILFromFSIL(LPITEMIDLIST pidl) { - FIXME("(pidl=%p)\n",pidl); + FIXME("(pidl=%p)\n",pidl); - pdump(pidl); + pdump(pidl); - return 0; + return 0; } /************************************************************************* @@ -772,18 +785,20 @@ LPITEMIDLIST WINAPI SHLogILFromFSIL(LPITEMIDLIST pidl) */ UINT WINAPI ILGetSize(LPCITEMIDLIST pidl) { - LPCSHITEMID si = &(pidl->mkid); - UINT len=0; + LPCSHITEMID si = &(pidl->mkid); + UINT len=0; - if (pidl) - { while (si->cb) - { len += si->cb; - si = (LPCSHITEMID)(((const BYTE*)si)+si->cb); - } - len += 2; - } - TRACE("pidl=%p size=%u\n",pidl, len); - return len; + if (pidl) + { + while (si->cb) + { + len += si->cb; + si = (LPCSHITEMID)(((const BYTE*)si)+si->cb); + } + len += 2; + } + TRACE("pidl=%p size=%u\n",pidl, len); + return len; } /************************************************************************* @@ -804,21 +819,21 @@ UINT WINAPI ILGetSize(LPCITEMIDLIST pidl) */ LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl) { - WORD len; + WORD len; - TRACE("%p\n", pidl); + TRACE("%p\n", pidl); - if(pidl) - { - len = pidl->mkid.cb; - if (len) - { - pidl = (LPCITEMIDLIST) (((const BYTE*)pidl)+len); - TRACE("-- %p\n", pidl); - return (LPITEMIDLIST)pidl; - } - } - return NULL; + if (pidl) + { + len = pidl->mkid.cb; + if (len) + { + pidl = (LPCITEMIDLIST) (((const BYTE*)pidl)+len); + TRACE("-- %p\n", pidl); + return (LPITEMIDLIST)pidl; + } + } + return NULL; } /************************************************************************* @@ -838,32 +853,28 @@ LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl) */ LPITEMIDLIST WINAPI ILAppend(LPITEMIDLIST pidl, LPCITEMIDLIST item, BOOL bEnd) { - LPITEMIDLIST idlRet; + LPITEMIDLIST idlRet; - WARN("(pidl=%p,pidl=%p,%08u)semi-stub\n",pidl,item,bEnd); + WARN("(pidl=%p,pidl=%p,%08u)semi-stub\n",pidl,item,bEnd); - pdump (pidl); - pdump (item); + pdump (pidl); + pdump (item); - if (_ILIsDesktop(pidl)) - { - idlRet = ILClone(item); - if (pidl) - SHFree (pidl); - return idlRet; - } + if (_ILIsDesktop(pidl)) + { + idlRet = ILClone(item); + if (pidl) + SHFree (pidl); + return idlRet; + } - if (bEnd) - { - idlRet = ILCombine(pidl, item); - } - else - { - idlRet = ILCombine(item, pidl); - } + if (bEnd) + idlRet = ILCombine(pidl, item); + else + idlRet = ILCombine(item, pidl); - SHFree(pidl); - return idlRet; + SHFree(pidl); + return idlRet; } /************************************************************************* @@ -879,8 +890,9 @@ LPITEMIDLIST WINAPI ILAppend(LPITEMIDLIST pidl, LPCITEMIDLIST item, BOOL bEnd) */ void WINAPI ILFree(LPITEMIDLIST pidl) { - TRACE("(pidl=%p)\n",pidl); - if(pidl) SHFree(pidl); + TRACE("(pidl=%p)\n",pidl); + if (pidl) + SHFree(pidl); } /************************************************************************* @@ -896,10 +908,10 @@ void WINAPI ILFree(LPITEMIDLIST pidl) */ void WINAPI ILGlobalFree( LPITEMIDLIST pidl) { - TRACE("%p\n", pidl); + TRACE("%p\n", pidl); - if(!pidl) return; - Free(pidl); + if (pidl) + Free(pidl); } /************************************************************************* @@ -916,16 +928,15 @@ void WINAPI ILGlobalFree( LPITEMIDLIST pidl) * NOTES * exported by ordinal. */ - LPITEMIDLIST WINAPI ILCreateFromPathA (LPCSTR path) { - LPITEMIDLIST pidlnew = NULL; + LPITEMIDLIST pidlnew = NULL; - TRACE_(shell)("%s\n", debugstr_a(path)); + TRACE_(shell)("%s\n", debugstr_a(path)); - if (SUCCEEDED(SHILCreateFromPathA(path, &pidlnew, NULL))) - return pidlnew; - return NULL; + if (SUCCEEDED(SHILCreateFromPathA(path, &pidlnew, NULL))) + return pidlnew; + return NULL; } /************************************************************************* @@ -933,13 +944,13 @@ LPITEMIDLIST WINAPI ILCreateFromPathA (LPCSTR path) */ LPITEMIDLIST WINAPI ILCreateFromPathW (LPCWSTR path) { - LPITEMIDLIST pidlnew = NULL; + LPITEMIDLIST pidlnew = NULL; - TRACE_(shell)("%s\n", debugstr_w(path)); + TRACE_(shell)("%s\n", debugstr_w(path)); - if (SUCCEEDED(SHILCreateFromPathW(path, &pidlnew, NULL))) - return pidlnew; - return NULL; + if (SUCCEEDED(SHILCreateFromPathW(path, &pidlnew, NULL))) + return pidlnew; + return NULL; } /************************************************************************* @@ -947,9 +958,9 @@ LPITEMIDLIST WINAPI ILCreateFromPathW (LPCWSTR path) */ LPITEMIDLIST WINAPI ILCreateFromPathAW (LPCVOID path) { - if ( SHELL_OsIsUnicode()) - return ILCreateFromPathW (path); - return ILCreateFromPathA (path); + if ( SHELL_OsIsUnicode()) + return ILCreateFromPathW (path); + return ILCreateFromPathA (path); } /************************************************************************* @@ -982,42 +993,40 @@ LPITEMIDLIST WINAPI ILCreateFromPathAW (LPCVOID path) static HRESULT WINAPI _ILParsePathW(LPCWSTR path, LPWIN32_FIND_DATAW lpFindFile, BOOL bBindCtx, LPITEMIDLIST *ppidl, LPDWORD prgfInOut) { - LPSHELLFOLDER pSF = NULL; - LPBC pBC = NULL; - HRESULT ret; + LPSHELLFOLDER pSF = NULL; + LPBC pBC = NULL; + HRESULT ret; - TRACE("%s %p %d (%p)->%p (%p)->0x%lx\n", debugstr_w(path), lpFindFile, bBindCtx, - ppidl, ppidl ? *ppidl : NULL, - prgfInOut, prgfInOut ? *prgfInOut : 0); + TRACE("%s %p %d (%p)->%p (%p)->0x%lx\n", debugstr_w(path), lpFindFile, bBindCtx, + ppidl, ppidl ? *ppidl : NULL, + prgfInOut, prgfInOut ? *prgfInOut : 0); - ret = SHGetDesktopFolder(&pSF); - if (FAILED(ret)) - { - return ret; - } + ret = SHGetDesktopFolder(&pSF); + if (FAILED(ret)) + return ret; - if (lpFindFile || bBindCtx) - ret = IFileSystemBindData_Constructor(lpFindFile, &pBC); + if (lpFindFile || bBindCtx) + ret = IFileSystemBindData_Constructor(lpFindFile, &pBC); - if (SUCCEEDED(ret)) - { - ret = IShellFolder_ParseDisplayName(pSF, 0, pBC, (LPOLESTR)path, NULL, ppidl, prgfInOut); - } + if (SUCCEEDED(ret)) + { + ret = IShellFolder_ParseDisplayName(pSF, 0, pBC, (LPOLESTR)path, NULL, ppidl, prgfInOut); + } - if (pBC) - { - IBindCtx_Release(pBC); - pBC = NULL; - } + if (pBC) + { + IBindCtx_Release(pBC); + pBC = NULL; + } - IShellFolder_Release(pSF); + IShellFolder_Release(pSF); - if (!SUCCEEDED(ret) && ppidl) - *ppidl = NULL; + if (!SUCCEEDED(ret) && ppidl) + *ppidl = NULL; - TRACE("%s %p 0x%lx\n", debugstr_w(path), ppidl ? *ppidl : NULL, prgfInOut ? *prgfInOut : 0); + TRACE("%s %p 0x%lx\n", debugstr_w(path), ppidl ? *ppidl : NULL, prgfInOut ? *prgfInOut : 0); - return ret; + return ret; } /************************************************************************* @@ -1064,20 +1073,20 @@ LPITEMIDLIST WINAPI SHSimpleIDListFromPathA(LPCSTR lpszPath) LPITEMIDLIST WINAPI SHSimpleIDListFromPathW(LPCWSTR lpszPath) { - LPITEMIDLIST pidl = NULL; + LPITEMIDLIST pidl = NULL; - TRACE("%s\n", debugstr_w(lpszPath)); + TRACE("%s\n", debugstr_w(lpszPath)); - _ILParsePathW(lpszPath, NULL, TRUE, &pidl, NULL); - TRACE("%s %p\n", debugstr_w(lpszPath), pidl); - return pidl; + _ILParsePathW(lpszPath, NULL, TRUE, &pidl, NULL); + TRACE("%s %p\n", debugstr_w(lpszPath), pidl); + return pidl; } LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW(LPCVOID lpszPath) { - if ( SHELL_OsIsUnicode()) - return SHSimpleIDListFromPathW (lpszPath); - return SHSimpleIDListFromPathA (lpszPath); + if ( SHELL_OsIsUnicode()) + return SHSimpleIDListFromPathW (lpszPath); + return SHSimpleIDListFromPathA (lpszPath); } /************************************************************************* @@ -1087,110 +1096,117 @@ LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW(LPCVOID lpszPath) * the pidl can be a simple one. since we can't get the path out of the pidl * we have to take all data from the pidl */ -HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID dest, int len) +HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, + int nFormat, LPVOID dest, int len) { - TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len); + LPSTR filename, shortname; + WIN32_FIND_DATAA * pfd; - pdump(pidl); - if (!psf || !dest ) return E_INVALIDARG; + TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len); - switch (nFormat) - { - case SHGDFIL_FINDDATA: - { - LPSTR filename, shortname; - WIN32_FIND_DATAA * pfd = dest; + pdump(pidl); + if (!psf || !dest) + return E_INVALIDARG; - if (_ILIsDrive(pidl)) - return E_INVALIDARG; + switch (nFormat) + { + case SHGDFIL_FINDDATA: + pfd = dest; - if (len < (int)sizeof(WIN32_FIND_DATAA)) return E_INVALIDARG; + if (_ILIsDrive(pidl)) + return E_INVALIDARG; - ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA)); - _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime)); - pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0); - pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0); + if (len < sizeof(WIN32_FIND_DATAA)) + return E_INVALIDARG; - filename = _ILGetTextPointer(pidl); - shortname = _ILGetSTextPointer(pidl); + ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA)); + _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime)); + pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0); + pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0); - if (filename) - lstrcpynA(pfd->cFileName, filename, MAX_PATH); - else - pfd->cFileName[0] = '\0'; + filename = _ILGetTextPointer(pidl); + shortname = _ILGetSTextPointer(pidl); - if (shortname) - lstrcpynA(pfd->cAlternateFileName, shortname, MAX_PATH); - else - pfd->cAlternateFileName[0] = '\0'; - } - return NOERROR; + if (filename) + lstrcpynA(pfd->cFileName, filename, MAX_PATH); + else + pfd->cFileName[0] = '\0'; - case SHGDFIL_NETRESOURCE: - case SHGDFIL_DESCRIPTIONID: - FIXME_(shell)("SHGDFIL %i stub\n", nFormat); - break; + if (shortname) + lstrcpynA(pfd->cAlternateFileName, shortname, MAX_PATH); + else + pfd->cAlternateFileName[0] = '\0'; + return NOERROR; - default: - ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat); - } + case SHGDFIL_NETRESOURCE: + case SHGDFIL_DESCRIPTIONID: + FIXME_(shell)("SHGDFIL %i stub\n", nFormat); + break; - return E_INVALIDARG; + default: + ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat); + } + + return E_INVALIDARG; } /************************************************************************* * SHGetDataFromIDListW [SHELL32.248] * */ -HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID dest, int len) +HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, + int nFormat, LPVOID dest, int len) { - TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len); + LPSTR filename, shortname; + WIN32_FIND_DATAW * pfd = dest; - pdump(pidl); + TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len); - if (! psf || !dest ) return E_INVALIDARG; + pdump(pidl); - switch (nFormat) - { - case SHGDFIL_FINDDATA: - { - LPSTR filename, shortname; - WIN32_FIND_DATAW * pfd = dest; + if (!psf || !dest) + return E_INVALIDARG; - if (_ILIsDrive(pidl)) - return E_INVALIDARG; + switch (nFormat) + { + case SHGDFIL_FINDDATA: + pfd = dest; - if (len < (int)sizeof(WIN32_FIND_DATAW)) return E_INVALIDARG; + if (_ILIsDrive(pidl)) + return E_INVALIDARG; - ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA)); - _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime)); - pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0); - pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0); + if (len < sizeof(WIN32_FIND_DATAW)) + return E_INVALIDARG; - filename = _ILGetTextPointer(pidl); - shortname = _ILGetSTextPointer(pidl); + ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA)); + _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime)); + pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0); + pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0); - if (!filename) - pfd->cFileName[0] = '\0'; - else if (!MultiByteToWideChar(CP_ACP, 0, filename, -1, pfd->cFileName, MAX_PATH)) - pfd->cFileName[MAX_PATH-1] = 0; + filename = _ILGetTextPointer(pidl); + shortname = _ILGetSTextPointer(pidl); - if (!shortname) - pfd->cAlternateFileName[0] = '\0'; - else if (!MultiByteToWideChar(CP_ACP, 0, shortname, -1, pfd->cAlternateFileName, 14)) - pfd->cAlternateFileName[13] = 0; - } - return NOERROR; - case SHGDFIL_NETRESOURCE: - case SHGDFIL_DESCRIPTIONID: - FIXME_(shell)("SHGDFIL %i stub\n", nFormat); - break; + if (!filename) + pfd->cFileName[0] = '\0'; + else if (!MultiByteToWideChar(CP_ACP, 0, filename, -1, pfd->cFileName, MAX_PATH)) + pfd->cFileName[MAX_PATH-1] = 0; - default: - ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat); - } + if (!shortname) + pfd->cAlternateFileName[0] = '\0'; + else if (!MultiByteToWideChar(CP_ACP, 0, shortname, -1, pfd->cAlternateFileName, 14)) + pfd->cAlternateFileName[13] = 0; + return NOERROR; - return E_INVALIDARG; + case SHGDFIL_NETRESOURCE: + case SHGDFIL_DESCRIPTIONID: + FIXME_(shell)("SHGDFIL %i stub\n", nFormat); + break; + + default: + ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat); + } + + return E_INVALIDARG; } /************************************************************************* @@ -1198,63 +1214,84 @@ HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int n */ HRESULT SHELL_GetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath, UINT uOutSize) { - HRESULT hr = S_OK; + HRESULT hr = S_OK; - pszPath[0]=0; + pszPath[0]=0; - /* One case is a PIDL rooted at desktop level */ - if (_ILIsValue(pidl) || _ILIsFolder(pidl)) { - hr = SHGetSpecialFolderPathA(0, pszPath, CSIDL_DESKTOP, FALSE); + /* One case is a PIDL rooted at desktop level */ + if (_ILIsValue(pidl) || _ILIsFolder(pidl)) + { + hr = SHGetSpecialFolderPathA(0, pszPath, CSIDL_DESKTOP, FALSE); - if (SUCCEEDED(hr)) - PathAddBackslashA(pszPath); - } - /* The only other valid case is a item ID list beginning at "My Computer" */ - else if (_ILIsMyComputer(pidl)) - pidl = ILGetNext(pidl); + if (SUCCEEDED(hr)) + PathAddBackslashA(pszPath); + } + /* The only other valid case is a item ID list beginning at "My Computer" */ + else if (_ILIsMyComputer(pidl)) + pidl = ILGetNext(pidl); - if (SUCCEEDED(hr)) { - LPSTR txt; + if (SUCCEEDED(hr)) + { + LPSTR txt; - while(pidl && pidl->mkid.cb) { - if (_ILIsSpecialFolder(pidl)) - {hr = E_INVALIDARG; break;} + while(pidl && pidl->mkid.cb) + { + if (_ILIsSpecialFolder(pidl)) + { + hr = E_INVALIDARG; + break; + } - txt = _ILGetTextPointer(pidl); - if (!txt) - {hr = E_INVALIDARG; break;} + txt = _ILGetTextPointer(pidl); + if (!txt) + { + hr = E_INVALIDARG; + break; + } - if (lstrlenA(txt) > pidl->mkid.cb) - ERR("pidl %p is borked\n",pidl); + if (lstrlenA(txt) > pidl->mkid.cb) + ERR("pidl %p is borked\n",pidl); - /* make sure there's enough space for the next segment */ - if ( (lstrlenA(txt) + lstrlenA(pszPath)) > uOutSize) - {hr = E_INVALIDARG; break;} - lstrcatA( pszPath, txt ); + /* make sure there's enough space for the next segment */ + if ((lstrlenA(txt) + lstrlenA(pszPath)) > uOutSize) + { + hr = E_INVALIDARG; + break; + } + lstrcatA( pszPath, txt ); - pidl = ILGetNext(pidl); - if (!pidl) - {hr = E_INVALIDARG; break;} + pidl = ILGetNext(pidl); + if (!pidl) + { + hr = E_INVALIDARG; + break; + } - if (!pidl->mkid.cb) { - /* We are at the end and successfully converted the complete PIDL. */ - break; - } + /* Are we at the end and successfully converted the complete PIDL? */ + if (!pidl->mkid.cb) + break; - if( (lstrlenA(pszPath) + 1) > uOutSize) - {hr = E_INVALIDARG; break;} - if (!PathAddBackslashA(pszPath)) - {hr = E_INVALIDARG; break;} - } - } else - hr = E_INVALIDARG; + if ((lstrlenA(pszPath) + 1) > uOutSize) + { + hr = E_INVALIDARG; + break; + } + if (!PathAddBackslashA(pszPath)) + { + hr = E_INVALIDARG; + break; + } + } + } + else + hr = E_INVALIDARG; - TRACE_(shell)("-- %s, 0x%08lx\n", pszPath, hr); - return hr; + TRACE_(shell)("-- %s, 0x%08lx\n", pszPath, hr); + return hr; } /************************************************************************* - * SHGetPathFromIDListA [SHELL32.@][NT 4.0: SHELL32.220] + * SHGetPathFromIDListA [SHELL32.@][NT 4.0: SHELL32.220] * * PARAMETERS * pidl, [IN] pidl @@ -1264,23 +1301,23 @@ HRESULT SHELL_GetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath, UINT uOutSiz * path from a passed PIDL. * * NOTES - * NULL returns FALSE - * desktop pidl gives path to desktop directory back - * special pidls returning FALSE + * NULL returns FALSE + * desktop pidl gives path to desktop directory back + * special pidls returning FALSE */ BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath) { - HRESULT hr; + HRESULT hr; - TRACE_(shell)("(pidl=%p,%p)\n",pidl,pszPath); - pdump(pidl); + TRACE_(shell)("(pidl=%p,%p)\n",pidl,pszPath); + pdump(pidl); - if (!pidl) - return FALSE; + if (!pidl) + return FALSE; - hr = SHELL_GetPathFromIDListA(pidl, pszPath, MAX_PATH); + hr = SHELL_GetPathFromIDListA(pidl, pszPath, MAX_PATH); - return SUCCEEDED(hr); + return SUCCEEDED(hr); } /************************************************************************* @@ -1288,144 +1325,166 @@ BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath) */ HRESULT SHELL_GetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize) { - HRESULT hr = S_OK; - UINT len; + HRESULT hr = S_OK; + UINT len; - pszPath[0]=0; + pszPath[0]=0; - /* One case is a PIDL rooted at desktop level */ - if (_ILIsValue(pidl) || _ILIsFolder(pidl)) { - hr = SHGetSpecialFolderPathW(0, pszPath, CSIDL_DESKTOP, FALSE); + /* One case is a PIDL rooted at desktop level */ + if (_ILIsValue(pidl) || _ILIsFolder(pidl)) + { + hr = SHGetSpecialFolderPathW(0, pszPath, CSIDL_DESKTOP, FALSE); - if (SUCCEEDED(hr)) - PathAddBackslashW(pszPath); - } - /* The only other valid case is a item ID list beginning at "My Computer" */ - else if (_ILIsMyComputer(pidl)) - pidl = ILGetNext(pidl); + if (SUCCEEDED(hr)) + PathAddBackslashW(pszPath); + } + /* The only other valid case is a item ID list beginning at "My Computer" */ + else if (_ILIsMyComputer(pidl)) + pidl = ILGetNext(pidl); - if (SUCCEEDED(hr)) { - LPSTR txt; + if (SUCCEEDED(hr)) + { + LPSTR txt; - while(pidl && pidl->mkid.cb) { - if (_ILIsSpecialFolder(pidl)) - {hr = E_INVALIDARG; break;} + while(pidl && pidl->mkid.cb) + { + if (_ILIsSpecialFolder(pidl)) + { + hr = E_INVALIDARG; + break; + } - txt = _ILGetTextPointer(pidl); - if (!txt) - {hr = E_INVALIDARG; break;} + txt = _ILGetTextPointer(pidl); + if (!txt) + { + hr = E_INVALIDARG; + break; + } - if (lstrlenA(txt) > pidl->mkid.cb) - ERR("pidl %p is borked\n",pidl); - len = MultiByteToWideChar(CP_ACP, 0, txt, -1, NULL, 0); - if ( (lstrlenW(pszPath) + len) > uOutSize ) - {hr = E_INVALIDARG; break;} + if (lstrlenA(txt) > pidl->mkid.cb) + ERR("pidl %p is borked\n",pidl); + len = MultiByteToWideChar(CP_ACP, 0, txt, -1, NULL, 0); + if ( (lstrlenW(pszPath) + len) > uOutSize ) + { + hr = E_INVALIDARG; + break; + } - MultiByteToWideChar(CP_ACP, 0, txt, -1, - &pszPath[lstrlenW(pszPath)], len); + MultiByteToWideChar(CP_ACP, 0, txt, -1, + &pszPath[lstrlenW(pszPath)], len); - pidl = ILGetNext(pidl); - if (!pidl) - {hr = E_INVALIDARG; break;} + pidl = ILGetNext(pidl); + if (!pidl) + { + hr = E_INVALIDARG; + break; + } - if (!pidl->mkid.cb) { - /* We are at the end and successfully converted the complete PIDL. */ - break; - } + /* Are we at the end and successfully converted the complete PIDL? */ + if (!pidl->mkid.cb) + break; - if ( (lstrlenW(pszPath) + 1) > uOutSize ) - {hr = E_INVALIDARG; break;} - if (!PathAddBackslashW(pszPath)) - {hr = E_INVALIDARG; break;} - } - } else - hr = E_INVALIDARG; + if ((lstrlenW(pszPath) + 1) > uOutSize ) + { + hr = E_INVALIDARG; + break; + } + if (!PathAddBackslashW(pszPath)) + { + hr = E_INVALIDARG; + break; + } + } + } + else + hr = E_INVALIDARG; TRACE_(shell)("-- %s, 0x%08lx\n", debugstr_w(pszPath), hr); return hr; } /************************************************************************* - * SHGetPathFromIDListW [SHELL32.@] + * SHGetPathFromIDListW [SHELL32.@] */ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath) { - HRESULT hr; + HRESULT hr; - TRACE_(shell)("(pidl=%p,%p)\n", pidl, debugstr_w(pszPath)); - pdump(pidl); + TRACE_(shell)("(pidl=%p,%p)\n", pidl, debugstr_w(pszPath)); + pdump(pidl); - if (!pidl) - return FALSE; + if (!pidl) + return FALSE; - hr = SHELL_GetPathFromIDListW(pidl, pszPath, MAX_PATH); + hr = SHELL_GetPathFromIDListW(pidl, pszPath, MAX_PATH); - TRACE_(shell)("-- %s, 0x%08lx\n",debugstr_w(pszPath), hr); - return SUCCEEDED(hr); + TRACE_(shell)("-- %s, 0x%08lx\n",debugstr_w(pszPath), hr); + return SUCCEEDED(hr); } /************************************************************************* - * SHBindToParent [shell version 5.0] + * SHBindToParent [shell version 5.0] */ HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast) { - IShellFolder * psf; - LPITEMIDLIST pidlChild, pidlParent; - HRESULT hr=E_FAIL; + IShellFolder * psf; + LPITEMIDLIST pidlChild, pidlParent; + HRESULT hr=E_FAIL; - TRACE_(shell)("pidl=%p\n", pidl); - pdump(pidl); + TRACE_(shell)("pidl=%p\n", pidl); + pdump(pidl); - *ppv = NULL; - if (ppidlLast) *ppidlLast = NULL; + *ppv = NULL; + if (ppidlLast) + *ppidlLast = NULL; - if (_ILIsPidlSimple(pidl)) - { - IShellFolder* desktop; + if (_ILIsPidlSimple(pidl)) + { + IShellFolder* desktop; - /* we are on desktop level */ - hr = SHGetDesktopFolder(&desktop); + /* we are on desktop level */ + hr = SHGetDesktopFolder(&desktop); - if (SUCCEEDED(hr)) - { - hr = IShellFolder_QueryInterface(desktop, riid, ppv); + if (SUCCEEDED(hr)) + { + hr = IShellFolder_QueryInterface(desktop, riid, ppv); - if (SUCCEEDED(hr) && ppidlLast) - *ppidlLast = ILClone(pidl); + if (SUCCEEDED(hr) && ppidlLast) + *ppidlLast = ILClone(pidl); - IShellFolder_Release(desktop); - } - } - else - { - pidlChild = ILClone(ILFindLastID(pidl)); - pidlParent = ILClone(pidl); - ILRemoveLastID(pidlParent); + IShellFolder_Release(desktop); + } + } + else + { + pidlChild = ILClone(ILFindLastID(pidl)); + pidlParent = ILClone(pidl); + ILRemoveLastID(pidlParent); - hr = SHGetDesktopFolder(&psf); + hr = SHGetDesktopFolder(&psf); - if (SUCCEEDED(hr)) - hr = IShellFolder_BindToObject(psf, pidlParent, NULL, riid, ppv); + if (SUCCEEDED(hr)) + hr = IShellFolder_BindToObject(psf, pidlParent, NULL, riid, ppv); - if (SUCCEEDED(hr) && ppidlLast) - *ppidlLast = pidlChild; - else - ILFree (pidlChild); + if (SUCCEEDED(hr) && ppidlLast) + *ppidlLast = pidlChild; + else + ILFree (pidlChild); - SHFree (pidlParent); - if (psf) IShellFolder_Release(psf); - } + SHFree (pidlParent); + if (psf) + IShellFolder_Release(psf); + } - - TRACE_(shell)("-- psf=%p pidl=%p ret=0x%08lx\n", *ppv, (ppidlLast)?*ppidlLast:NULL, hr); - return hr; + TRACE_(shell)("-- psf=%p pidl=%p ret=0x%08lx\n", *ppv, (ppidlLast)?*ppidlLast:NULL, hr); + return hr; } /************************************************************************** * - * internal functions + * internal functions * - * ### 1. section creating pidls ### + * ### 1. section creating pidls ### * ************************************************************************* */ @@ -1433,7 +1492,8 @@ LPITEMIDLIST _ILAlloc(PIDLTYPE type, size_t size) { LPITEMIDLIST pidlOut = NULL; - if((pidlOut = SHAlloc(size + 5))) + pidlOut = SHAlloc(size + 5); + if(pidlOut) { LPPIDLDATA pData; LPITEMIDLIST pidlNext; @@ -1441,10 +1501,12 @@ LPITEMIDLIST _ILAlloc(PIDLTYPE type, size_t size) ZeroMemory(pidlOut, size + 5); pidlOut->mkid.cb = size + 3; - if ((pData = _ILGetDataPointer(pidlOut))) + pData = _ILGetDataPointer(pidlOut); + if (pData) pData->type = type; - if ((pidlNext = ILGetNext(pidlOut))) + pidlNext = ILGetNext(pidlOut); + if (pidlNext) pidlNext->mkid.cb = 0x00; TRACE("-- (pidl=%p, size=%u)\n", pidlOut, size); } @@ -1464,13 +1526,15 @@ LPITEMIDLIST _ILCreateDesktop() } LPITEMIDLIST _ILCreateMyComputer() -{ TRACE("()\n"); - return _ILCreateGuid(PT_GUID, &CLSID_MyComputer); +{ + TRACE("()\n"); + return _ILCreateGuid(PT_GUID, &CLSID_MyComputer); } LPITEMIDLIST _ILCreateIExplore() -{ TRACE("()\n"); - return _ILCreateGuid(PT_GUID, &CLSID_Internet); +{ + TRACE("()\n"); + return _ILCreateGuid(PT_GUID, &CLSID_Internet); } LPITEMIDLIST _ILCreateControlPanel() @@ -1512,13 +1576,15 @@ LPITEMIDLIST _ILCreatePrinters() } LPITEMIDLIST _ILCreateNetwork() -{ TRACE("()\n"); - return _ILCreateGuid(PT_GUID, &CLSID_NetworkPlaces); +{ + TRACE("()\n"); + return _ILCreateGuid(PT_GUID, &CLSID_NetworkPlaces); } LPITEMIDLIST _ILCreateBitBucket() -{ TRACE("()\n"); - return _ILCreateGuid(PT_GUID, &CLSID_RecycleBin); +{ + TRACE("()\n"); + return _ILCreateGuid(PT_GUID, &CLSID_RecycleBin); } LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid) @@ -1534,7 +1600,7 @@ LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid) memcpy(&(pData->u.guid.guid), guid, sizeof(GUID)); TRACE("-- create GUID-pidl %s\n", - debugstr_guid(&(pData->u.guid.guid))); + debugstr_guid(&(pData->u.guid.guid))); } } else @@ -1547,21 +1613,52 @@ LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid) LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID) { - IID iid; + IID iid; - if (!SUCCEEDED(SHCLSIDFromStringA(szGUID, &iid))) - { - ERR("%s is not a GUID\n", szGUID); - return NULL; - } - return _ILCreateGuid(PT_GUID, &iid); + if (!SUCCEEDED(SHCLSIDFromStringA(szGUID, &iid))) + { + ERR("%s is not a GUID\n", szGUID); + return NULL; + } + return _ILCreateGuid(PT_GUID, &iid); +} + +LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID) +{ + IID iid; + + if (!SUCCEEDED(SHCLSIDFromStringW(szGUID, &iid))) + { + ERR("%s is not a GUID\n", debugstr_w(szGUID)); + return NULL; + } + return _ILCreateGuid(PT_GUID, &iid); +} + +LPITEMIDLIST _ILCreateFromFindDataW( WIN32_FIND_DATAW *wfd ) +{ + /* FIXME: should make unicode PIDLs */ + WIN32_FIND_DATAA fda; + + memset( &fda, 0, sizeof fda ); + fda.dwFileAttributes = wfd->dwFileAttributes; + fda.ftCreationTime = wfd->ftCreationTime; + fda.ftLastAccessTime = wfd->ftLastAccessTime; + fda.ftLastWriteTime = wfd->ftLastWriteTime; + fda.nFileSizeHigh = wfd->nFileSizeHigh; + fda.nFileSizeLow = wfd->nFileSizeLow; + fda.dwReserved0 = wfd->dwReserved0; + fda.dwReserved1 = wfd->dwReserved1; + WideCharToMultiByte( CP_ACP, 0, wfd->cFileName, -1, + fda.cFileName, MAX_PATH, NULL, NULL ); + return _ILCreateFromFindDataA( &fda ); } LPITEMIDLIST _ILCreateFromFindDataA(WIN32_FIND_DATAA * stffile ) { - char buff[MAX_PATH + 14 +1]; /* see WIN32_FIND_DATA */ - char * pbuff = buff; - size_t len, len1; + char buff[MAX_PATH + 14 +1]; /* see WIN32_FIND_DATA */ + char * pbuff = buff; + size_t len, len1; LPITEMIDLIST pidl; PIDLTYPE type; @@ -1578,25 +1675,30 @@ LPITEMIDLIST _ILCreateFromFindDataA(WIN32_FIND_DATAA * stffile ) len1 = strlen (stffile->cAlternateFileName)+1; memcpy (pbuff, stffile->cAlternateFileName, len1); - type = (stffile->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? PT_FOLDER : - PT_VALUE; - /* FileStruct already has one byte for the first name, so use len - 1 in + type = (stffile->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? PT_FOLDER : PT_VALUE; + + /* + * FileStruct already has one byte for the first name, so use len - 1 in * size calculation */ - if ((pidl = _ILAlloc(type, sizeof(FileStruct) + (len - 1) + len1))) + pidl = _ILAlloc(type, sizeof(FileStruct) + (len - 1) + len1); + if (pidl) { LPPIDLDATA pData; LPSTR pszDest; /* set attributes */ - if ((pData = _ILGetDataPointer(pidl))) + pData = _ILGetDataPointer(pidl); + if (pData) { pData->type = type; - FileTimeToDosDateTime(&(stffile->ftLastWriteTime),&pData->u.file.uFileDate,&pData->u.file.uFileTime); + FileTimeToDosDateTime( &(stffile->ftLastWriteTime), + &pData->u.file.uFileDate, &pData->u.file.uFileTime); pData->u.file.dwFileSize = stffile->nFileSizeLow; pData->u.file.uFileAttribs = (WORD)stffile->dwFileAttributes; } - if ((pszDest = _ILGetTextPointer(pidl))) + pszDest = _ILGetTextPointer(pidl); + if (pszDest) { memcpy(pszDest, buff, len + len1); TRACE("-- create Value: %s\n",debugstr_a(pszDest)); @@ -1607,42 +1709,58 @@ LPITEMIDLIST _ILCreateFromFindDataA(WIN32_FIND_DATAA * stffile ) HRESULT _ILCreateFromPathA(LPCSTR szPath, LPITEMIDLIST* ppidl) { - HANDLE hFile; - WIN32_FIND_DATAA stffile; + HANDLE hFile; + WIN32_FIND_DATAA stffile; if (!ppidl) return E_INVALIDARG; - hFile = FindFirstFileA(szPath, &stffile); + hFile = FindFirstFileA(szPath, &stffile); + if (hFile == INVALID_HANDLE_VALUE) + return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); - if (hFile == INVALID_HANDLE_VALUE) - return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); + FindClose(hFile); - FindClose(hFile); + *ppidl = _ILCreateFromFindDataA(&stffile); - *ppidl = _ILCreateFromFindDataA(&stffile); + return *ppidl ? S_OK : E_OUTOFMEMORY; +} - return *ppidl ? S_OK : E_OUTOFMEMORY; +HRESULT _ILCreateFromPathW(LPCWSTR szPath, LPITEMIDLIST* ppidl) +{ + HANDLE hFile; + WIN32_FIND_DATAW stffile; + + if (!ppidl) + return E_INVALIDARG; + + hFile = FindFirstFileW(szPath, &stffile); + if (hFile == INVALID_HANDLE_VALUE) + return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); + + FindClose(hFile); + + *ppidl = _ILCreateFromFindDataW(&stffile); + + return *ppidl ? S_OK : E_OUTOFMEMORY; } LPITEMIDLIST _ILCreateDrive(LPCWSTR lpszNew) { - WCHAR sTemp[4]; LPITEMIDLIST pidlOut; - sTemp[0]=toupperW(lpszNew[0]); - sTemp[1]=':'; - sTemp[2]='\\'; - sTemp[3]=0x00; - TRACE("(%s)\n",debugstr_w(sTemp)); + TRACE("(%s)\n",debugstr_w(lpszNew)); - if ((pidlOut = _ILAlloc(PT_DRIVE, sizeof(DriveStruct)))) + pidlOut = _ILAlloc(PT_DRIVE, sizeof(DriveStruct)); + if (pidlOut) { LPSTR pszDest; - if ((pszDest = _ILGetTextPointer(pidlOut))) + pszDest = _ILGetTextPointer(pidlOut); + if (pszDest) { - WideCharToMultiByte(CP_ACP, 0, sTemp, sizeof(sTemp)/sizeof(WCHAR), pszDest, sizeof(sTemp)/sizeof(WCHAR), NULL, NULL); + strcpy(pszDest, "x:\\"); + pszDest[0]=toupperW(lpszNew[0]); TRACE("-- create Drive: %s\n", debugstr_a(pszDest)); } } @@ -1658,20 +1776,21 @@ LPITEMIDLIST _ILCreateDrive(LPCWSTR lpszNew) * strlen (lpszText) */ DWORD _ILGetDrive(LPCITEMIDLIST pidl,LPSTR pOut, UINT uSize) -{ TRACE("(%p,%p,%u)\n",pidl,pOut,uSize); +{ + TRACE("(%p,%p,%u)\n",pidl,pOut,uSize); - if(_ILIsMyComputer(pidl)) - pidl = ILGetNext(pidl); + if(_ILIsMyComputer(pidl)) + pidl = ILGetNext(pidl); - if (pidl && _ILIsDrive(pidl)) - return _ILSimpleGetText(pidl, pOut, uSize); + if (pidl && _ILIsDrive(pidl)) + return _ILSimpleGetText(pidl, pOut, uSize); - return 0; + return 0; } /************************************************************************** * - * ### 2. section testing pidls ### + * ### 2. section testing pidls ### * ************************************************************************** * _ILIsDesktop() @@ -1683,79 +1802,96 @@ DWORD _ILGetDrive(LPCITEMIDLIST pidl,LPSTR pOut, UINT uSize) * _ILIsPidlSimple() */ BOOL _ILIsDesktop(LPCITEMIDLIST pidl) -{ TRACE("(%p)\n",pidl); - return pidl && pidl->mkid.cb ? 0 : 1; +{ + TRACE("(%p)\n",pidl); + + return pidl && pidl->mkid.cb ? 0 : 1; } BOOL _ILIsMyComputer(LPCITEMIDLIST pidl) { - REFIID iid = _ILGetGUIDPointer(pidl); + REFIID iid = _ILGetGUIDPointer(pidl); - TRACE("(%p)\n",pidl); + TRACE("(%p)\n",pidl); - if (iid) - return IsEqualIID(iid, &CLSID_MyComputer); - return FALSE; + if (iid) + return IsEqualIID(iid, &CLSID_MyComputer); + return FALSE; } BOOL _ILIsSpecialFolder (LPCITEMIDLIST pidl) { - LPPIDLDATA lpPData = _ILGetDataPointer(pidl); - TRACE("(%p)\n",pidl); - return (pidl && ( (lpPData && (PT_GUID== lpPData->type || PT_SHELLEXT== lpPData->type)) || - (pidl && pidl->mkid.cb == 0x00) - )); + LPPIDLDATA lpPData = _ILGetDataPointer(pidl); + + TRACE("(%p)\n",pidl); + + return (pidl && ( (lpPData && (PT_GUID== lpPData->type || PT_SHELLEXT== lpPData->type)) || + (pidl && pidl->mkid.cb == 0x00) + )); } BOOL _ILIsDrive(LPCITEMIDLIST pidl) -{ LPPIDLDATA lpPData = _ILGetDataPointer(pidl); - TRACE("(%p)\n",pidl); - return (pidl && lpPData && (PT_DRIVE == lpPData->type || - PT_DRIVE1 == lpPData->type || - PT_DRIVE2 == lpPData->type || - PT_DRIVE3 == lpPData->type)); +{ + LPPIDLDATA lpPData = _ILGetDataPointer(pidl); + + TRACE("(%p)\n",pidl); + + return (pidl && lpPData && (PT_DRIVE == lpPData->type || + PT_DRIVE1 == lpPData->type || + PT_DRIVE2 == lpPData->type || + PT_DRIVE3 == lpPData->type)); } BOOL _ILIsFolder(LPCITEMIDLIST pidl) -{ LPPIDLDATA lpPData = _ILGetDataPointer(pidl); - TRACE("(%p)\n",pidl); - return (pidl && lpPData && (PT_FOLDER == lpPData->type || PT_FOLDER1 == lpPData->type)); +{ + LPPIDLDATA lpPData = _ILGetDataPointer(pidl); + + TRACE("(%p)\n",pidl); + + return (pidl && lpPData && (PT_FOLDER == lpPData->type || PT_FOLDER1 == lpPData->type)); } BOOL _ILIsValue(LPCITEMIDLIST pidl) -{ LPPIDLDATA lpPData = _ILGetDataPointer(pidl); - TRACE("(%p)\n",pidl); - return (pidl && lpPData && PT_VALUE == lpPData->type); +{ + LPPIDLDATA lpPData = _ILGetDataPointer(pidl); + + TRACE("(%p)\n",pidl); + + return (pidl && lpPData && PT_VALUE == lpPData->type); } BOOL _ILIsCPanelStruct(LPCITEMIDLIST pidl) -{ LPPIDLDATA lpPData = _ILGetDataPointer(pidl); - TRACE("(%p)\n",pidl); - return (pidl && lpPData && (lpPData->type == 0)); +{ + LPPIDLDATA lpPData = _ILGetDataPointer(pidl); + + TRACE("(%p)\n",pidl); + + return (pidl && lpPData && (lpPData->type == 0)); } /************************************************************************** - * _ILIsPidlSimple + * _ILIsPidlSimple */ -BOOL _ILIsPidlSimple ( LPCITEMIDLIST pidl) +BOOL _ILIsPidlSimple(LPCITEMIDLIST pidl) { - BOOL ret = TRUE; + BOOL ret = TRUE; - if(! _ILIsDesktop(pidl)) /* pidl=NULL or mkid.cb=0 */ - { - WORD len = pidl->mkid.cb; - LPCITEMIDLIST pidlnext = (LPCITEMIDLIST) (((const BYTE*)pidl) + len ); - if (pidlnext->mkid.cb) - ret = FALSE; - } + if(! _ILIsDesktop(pidl)) /* pidl=NULL or mkid.cb=0 */ + { + WORD len = pidl->mkid.cb; + LPCITEMIDLIST pidlnext = (LPCITEMIDLIST) (((const BYTE*)pidl) + len ); - TRACE("%s\n", ret ? "Yes" : "No"); - return ret; + if (pidlnext->mkid.cb) + ret = FALSE; + } + + TRACE("%s\n", ret ? "Yes" : "No"); + return ret; } /************************************************************************** * - * ### 3. section getting values from pidls ### + * ### 3. section getting values from pidls ### */ /************************************************************************** @@ -1767,55 +1903,56 @@ BOOL _ILIsPidlSimple ( LPCITEMIDLIST pidl) */ DWORD _ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize) { - DWORD dwReturn=0; - LPSTR szSrc; - GUID const * riid; - char szTemp[MAX_PATH]; + DWORD dwReturn=0; + LPSTR szSrc; + GUID const * riid; + char szTemp[MAX_PATH]; - TRACE("(%p %p %x)\n",pidl,szOut,uOutSize); + TRACE("(%p %p %x)\n",pidl,szOut,uOutSize); - if (!pidl) return 0; + if (!pidl) + return 0; - if (szOut) - *szOut = 0; + if (szOut) + *szOut = 0; - if (_ILIsDesktop(pidl)) - { - /* desktop */ - if (HCR_GetClassNameA(&CLSID_ShellDesktop, szTemp, MAX_PATH)) - { - if (szOut) - lstrcpynA(szOut, szTemp, uOutSize); + if (_ILIsDesktop(pidl)) + { + /* desktop */ + if (HCR_GetClassNameA(&CLSID_ShellDesktop, szTemp, MAX_PATH)) + { + if (szOut) + lstrcpynA(szOut, szTemp, uOutSize); - dwReturn = strlen (szTemp); - } - } - else if (( szSrc = _ILGetTextPointer(pidl) )) - { - /* filesystem */ - if (szOut) - lstrcpynA(szOut, szSrc, uOutSize); + dwReturn = strlen (szTemp); + } + } + else if (( szSrc = _ILGetTextPointer(pidl) )) + { + /* filesystem */ + if (szOut) + lstrcpynA(szOut, szSrc, uOutSize); - dwReturn = strlen(szSrc); - } - else if (( riid = _ILGetGUIDPointer(pidl) )) - { - /* special folder */ - if ( HCR_GetClassNameA(riid, szTemp, MAX_PATH) ) - { - if (szOut) - lstrcpynA(szOut, szTemp, uOutSize); + dwReturn = strlen(szSrc); + } + else if (( riid = _ILGetGUIDPointer(pidl) )) + { + /* special folder */ + if ( HCR_GetClassNameA(riid, szTemp, MAX_PATH) ) + { + if (szOut) + lstrcpynA(szOut, szTemp, uOutSize); - dwReturn = strlen (szTemp); - } - } - else - { - ERR("-- no text\n"); - } + dwReturn = strlen (szTemp); + } + } + else + { + ERR("-- no text\n"); + } - TRACE("-- (%p=%s 0x%08lx)\n",szOut,debugstr_a(szOut),dwReturn); - return dwReturn; + TRACE("-- (%p=%s 0x%08lx)\n",szOut,debugstr_a(szOut),dwReturn); + return dwReturn; } /************************************************************************** @@ -1827,32 +1964,32 @@ DWORD _ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize) */ DWORD _ILSimpleGetTextW (LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize) { - DWORD dwReturn; - char szTemp[MAX_PATH]; + DWORD dwReturn; + char szTemp[MAX_PATH]; - TRACE("(%p %p %x)\n",pidl,szOut,uOutSize); + TRACE("(%p %p %x)\n",pidl,szOut,uOutSize); - dwReturn = _ILSimpleGetText(pidl, szTemp, uOutSize); + dwReturn = _ILSimpleGetText(pidl, szTemp, uOutSize); - if (!MultiByteToWideChar(CP_ACP, 0, szTemp, -1, szOut, MAX_PATH)) - *szOut = 0; + if (!MultiByteToWideChar(CP_ACP, 0, szTemp, -1, szOut, MAX_PATH)) + *szOut = 0; - TRACE("-- (%p=%s 0x%08lx)\n",szOut,debugstr_w(szOut),dwReturn); - return dwReturn; + TRACE("-- (%p=%s 0x%08lx)\n",szOut,debugstr_w(szOut),dwReturn); + return dwReturn; } /************************************************************************** * - * ### 4. getting pointers to parts of pidls ### + * ### 4. getting pointers to parts of pidls ### * ************************************************************************** * _ILGetDataPointer() */ LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl) { - if(pidl && pidl->mkid.cb != 0x00) - return (LPPIDLDATA) &(pidl->mkid.abID); - return NULL; + if(pidl && pidl->mkid.cb != 0x00) + return (LPPIDLDATA) &(pidl->mkid.abID); + return NULL; } /************************************************************************** @@ -1860,41 +1997,42 @@ LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl) * gets a pointer to the long filename string stored in the pidl */ LPSTR _ILGetTextPointer(LPCITEMIDLIST pidl) -{/* TRACE(pidl,"(pidl%p)\n", pidl);*/ +{ + /* TRACE(pidl,"(pidl%p)\n", pidl);*/ - LPPIDLDATA pdata = _ILGetDataPointer(pidl); + LPPIDLDATA pdata = _ILGetDataPointer(pidl); - if (pdata) - { - switch (pdata->type) - { - case PT_GUID: - case PT_SHELLEXT: - case PT_YAGUID: - return NULL; + if (!pdata) + return NULL; - case PT_DRIVE: - case PT_DRIVE1: - case PT_DRIVE2: - case PT_DRIVE3: - return (LPSTR)&(pdata->u.drive.szDriveName); + switch (pdata->type) + { + case PT_GUID: + case PT_SHELLEXT: + case PT_YAGUID: + return NULL; - case PT_FOLDER: - case PT_FOLDER1: - case PT_VALUE: - case PT_IESPECIAL1: - case PT_IESPECIAL2: - return (LPSTR)&(pdata->u.file.szNames); + case PT_DRIVE: + case PT_DRIVE1: + case PT_DRIVE2: + case PT_DRIVE3: + return (LPSTR)&(pdata->u.drive.szDriveName); - case PT_WORKGRP: - case PT_COMP: - case PT_NETWORK: - case PT_NETPROVIDER: - case PT_SHARE: - return (LPSTR)&(pdata->u.network.szNames); - } - } - return NULL; + case PT_FOLDER: + case PT_FOLDER1: + case PT_VALUE: + case PT_IESPECIAL1: + case PT_IESPECIAL2: + return (LPSTR)&(pdata->u.file.szNames); + + case PT_WORKGRP: + case PT_COMP: + case PT_NETWORK: + case PT_NETPROVIDER: + case PT_SHARE: + return (LPSTR)&(pdata->u.network.szNames); + } + return NULL; } /************************************************************************** @@ -1902,25 +2040,26 @@ LPSTR _ILGetTextPointer(LPCITEMIDLIST pidl) * gets a pointer to the short filename string stored in the pidl */ LPSTR _ILGetSTextPointer(LPCITEMIDLIST pidl) -{/* TRACE(pidl,"(pidl%p)\n", pidl);*/ +{ + /* TRACE(pidl,"(pidl%p)\n", pidl); */ - LPPIDLDATA pdata =_ILGetDataPointer(pidl); + LPPIDLDATA pdata =_ILGetDataPointer(pidl); - if (pdata) - { - switch (pdata->type) - { - case PT_FOLDER: - case PT_VALUE: - case PT_IESPECIAL1: - case PT_IESPECIAL2: - return (LPSTR)(pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1); + if (!pdata) + return NULL; - case PT_WORKGRP: - return (LPSTR)(pdata->u.network.szNames + strlen (pdata->u.network.szNames) + 1); - } - } - return NULL; + switch (pdata->type) + { + case PT_FOLDER: + case PT_VALUE: + case PT_IESPECIAL1: + case PT_IESPECIAL2: + return (LPSTR)(pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1); + + case PT_WORKGRP: + return (LPSTR)(pdata->u.network.szNames + strlen (pdata->u.network.szNames) + 1); + } + return NULL; } /************************************************************************** @@ -1930,25 +2069,25 @@ LPSTR _ILGetSTextPointer(LPCITEMIDLIST pidl) */ IID* _ILGetGUIDPointer(LPCITEMIDLIST pidl) { - LPPIDLDATA pdata =_ILGetDataPointer(pidl); + LPPIDLDATA pdata =_ILGetDataPointer(pidl); - TRACE("%p\n", pidl); + TRACE("%p\n", pidl); - if (pdata) - { - TRACE("pdata->type 0x%04x\n", pdata->type); - switch (pdata->type) - { - case PT_SHELLEXT: - case PT_GUID: - return &(pdata->u.guid.guid); + if (!pdata) + return NULL; - default: - TRACE("Unknown pidl type 0x%04x\n", pdata->type); - break; - } - } - return NULL; + TRACE("pdata->type 0x%04x\n", pdata->type); + switch (pdata->type) + { + case PT_SHELLEXT: + case PT_GUID: + return &(pdata->u.guid.guid); + + default: + TRACE("Unknown pidl type 0x%04x\n", pdata->type); + break; + } + return NULL; } /************************************************************************* @@ -1970,36 +2109,39 @@ BOOL _ILGetFileDateTime(LPCITEMIDLIST pidl, FILETIME *pFt) { LPPIDLDATA pdata = _ILGetDataPointer(pidl); - if(! pdata) return FALSE; + if (!pdata) + return FALSE; switch (pdata->type) { - case PT_FOLDER: - case PT_VALUE: - DosDateTimeToFileTime(pdata->u.file.uFileDate, pdata->u.file.uFileTime, pFt); - break; - default: - return FALSE; + case PT_FOLDER: + case PT_VALUE: + DosDateTimeToFileTime(pdata->u.file.uFileDate, pdata->u.file.uFileTime, pFt); + break; + default: + return FALSE; } return TRUE; } BOOL _ILGetFileDate (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) { - FILETIME ft,lft; - SYSTEMTIME time; - BOOL ret; - - if (_ILGetFileDateTime( pidl, &ft )) { - FileTimeToLocalFileTime(&ft, &lft); - FileTimeToSystemTime (&lft, &time); - ret = GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&time, NULL, pOut, uOutSize); - } else { - pOut[0] = '\0'; - ret = FALSE; - } - return ret; + FILETIME ft,lft; + SYSTEMTIME time; + BOOL ret; + if (_ILGetFileDateTime( pidl, &ft )) + { + FileTimeToLocalFileTime(&ft, &lft); + FileTimeToSystemTime (&lft, &time); + ret = GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&time, NULL, pOut, uOutSize); + } + else + { + pOut[0] = '\0'; + ret = FALSE; + } + return ret; } /************************************************************************* @@ -2008,59 +2150,66 @@ BOOL _ILGetFileDate (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) * Given the ItemIdList, get the FileSize * * PARAMS - * pidl [I] The ItemIDList - * pOut [I] The buffer to save the result - * uOutsize [I] The size of the buffer + * pidl [I] The ItemIDList + * pOut [I] The buffer to save the result + * uOutsize [I] The size of the buffer * * RETURNS - * The FileSize + * The FileSize * * NOTES - * pOut can be null when no string is needed + * pOut can be null when no string is needed * */ DWORD _ILGetFileSize (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) { - LPPIDLDATA pdata = _ILGetDataPointer(pidl); - DWORD dwSize; + LPPIDLDATA pdata = _ILGetDataPointer(pidl); + DWORD dwSize; - if(! pdata) return 0; + if (!pdata) + return 0; - switch (pdata->type) - { - case PT_VALUE: - dwSize = pdata->u.file.dwFileSize; - if (pOut) StrFormatByteSizeA(dwSize, pOut, uOutSize); - return dwSize; - } - if (pOut) *pOut = 0x00; - return 0; + switch (pdata->type) + { + case PT_VALUE: + dwSize = pdata->u.file.dwFileSize; + if (pOut) + StrFormatByteSizeA(dwSize, pOut, uOutSize); + return dwSize; + } + if (pOut) + *pOut = 0x00; + return 0; } BOOL _ILGetExtension (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) { - char szTemp[MAX_PATH]; - const char * pPoint; - LPCITEMIDLIST pidlTemp=pidl; + char szTemp[MAX_PATH]; + const char * pPoint; + LPCITEMIDLIST pidlTemp=pidl; - TRACE("pidl=%p\n",pidl); + TRACE("pidl=%p\n",pidl); - if (!pidl) return FALSE; + if (!pidl) + return FALSE; - pidlTemp = ILFindLastID(pidl); + pidlTemp = ILFindLastID(pidl); - if (!_ILIsValue(pidlTemp)) return FALSE; - if (!_ILSimpleGetText(pidlTemp, szTemp, MAX_PATH)) return FALSE; + if (!_ILIsValue(pidlTemp)) + return FALSE; + if (!_ILSimpleGetText(pidlTemp, szTemp, MAX_PATH)) + return FALSE; - pPoint = PathFindExtensionA(szTemp); + pPoint = PathFindExtensionA(szTemp); - if (! *pPoint) return FALSE; + if (!*pPoint) + return FALSE; - pPoint++; - lstrcpynA(pOut, pPoint, uOutSize); - TRACE("%s\n",pOut); + pPoint++; + lstrcpynA(pOut, pPoint, uOutSize); + TRACE("%s\n",pOut); - return TRUE; + return TRUE; } /************************************************************************* @@ -2074,34 +2223,31 @@ BOOL _ILGetExtension (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) * uOutsize [I] The size of the buffer * * RETURNS - * nothing + * nothing * * NOTES - * This function copies as much as possible into the buffer. + * This function copies as much as possible into the buffer. */ void _ILGetFileType(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) { - if(_ILIsValue(pidl)) - { - char sTemp[64]; - if(uOutSize > 0) - { + if(_ILIsValue(pidl)) + { + char sTemp[64]; + + if(uOutSize > 0) pOut[0] = 0; - } - if (_ILGetExtension (pidl, sTemp, 64)) - { - if (!( HCR_MapTypeToValueA(sTemp, sTemp, 64, TRUE) - && HCR_MapTypeToValueA(sTemp, pOut, uOutSize, FALSE ))) - { - lstrcpynA (pOut, sTemp, uOutSize - 6); - strcat (pOut, "-file"); - } - } - } - else - { - lstrcpynA(pOut, "Folder", uOutSize); - } + if (_ILGetExtension (pidl, sTemp, 64)) + { + if (!( HCR_MapTypeToValueA(sTemp, sTemp, 64, TRUE) + && HCR_MapTypeToValueA(sTemp, pOut, uOutSize, FALSE ))) + { + lstrcpynA (pOut, sTemp, uOutSize - 6); + strcat (pOut, "-file"); + } + } + } + else + lstrcpynA(pOut, "Folder", uOutSize); } /************************************************************************* @@ -2123,98 +2269,95 @@ void _ILGetFileType(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) */ DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) { - LPPIDLDATA pData = _ILGetDataPointer(pidl); - WORD wAttrib = 0; - int i; + LPPIDLDATA pData = _ILGetDataPointer(pidl); + WORD wAttrib = 0; + int i; - if(! pData) return 0; + if (!pData) + return 0; - switch(pData->type) - { - case PT_FOLDER: - case PT_VALUE: - wAttrib = pData->u.file.uFileAttribs; - break; - } + switch(pData->type) + { + case PT_FOLDER: + case PT_VALUE: + wAttrib = pData->u.file.uFileAttribs; + break; + } - if(uOutSize >= 6) - { - i=0; - if(wAttrib & FILE_ATTRIBUTE_READONLY) - { - pOut[i++] = 'R'; - } - if(wAttrib & FILE_ATTRIBUTE_HIDDEN) - { - pOut[i++] = 'H'; - } - if(wAttrib & FILE_ATTRIBUTE_SYSTEM) - { - pOut[i++] = 'S'; - } - if(wAttrib & FILE_ATTRIBUTE_ARCHIVE) - { - pOut[i++] = 'A'; - } - if(wAttrib & FILE_ATTRIBUTE_COMPRESSED) - { - pOut[i++] = 'C'; - } - pOut[i] = 0x00; - } - return wAttrib; + if(uOutSize >= 6) + { + i=0; + if(wAttrib & FILE_ATTRIBUTE_READONLY) + pOut[i++] = 'R'; + if(wAttrib & FILE_ATTRIBUTE_HIDDEN) + pOut[i++] = 'H'; + if(wAttrib & FILE_ATTRIBUTE_SYSTEM) + pOut[i++] = 'S'; + if(wAttrib & FILE_ATTRIBUTE_ARCHIVE) + pOut[i++] = 'A'; + if(wAttrib & FILE_ATTRIBUTE_COMPRESSED) + pOut[i++] = 'C'; + pOut[i] = 0x00; + } + return wAttrib; } /************************************************************************* -* ILFreeaPidl -* -* free a aPidl struct -*/ + * ILFreeaPidl + * + * free a aPidl struct + */ void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl) { - UINT i; + UINT i; - if (apidl) - { - for (i = 0; i < cidl; i++) SHFree(apidl[i]); - SHFree(apidl); - } + if (apidl) + { + for (i = 0; i < cidl; i++) + SHFree(apidl[i]); + SHFree(apidl); + } } /************************************************************************* -* ILCopyaPidl -* -* copies an aPidl struct -*/ + * ILCopyaPidl + * + * copies an aPidl struct + */ LPITEMIDLIST* _ILCopyaPidl(LPCITEMIDLIST * apidlsrc, UINT cidl) { - UINT i; - LPITEMIDLIST * apidldest = (LPITEMIDLIST*)SHAlloc(cidl * sizeof(LPITEMIDLIST)); - if(!apidlsrc) return NULL; + UINT i; + LPITEMIDLIST *apidldest; - for (i = 0; i < cidl; i++) - apidldest[i] = ILClone(apidlsrc[i]); + apidldest = SHAlloc(cidl * sizeof(LPITEMIDLIST)); + if (!apidlsrc) + return NULL; - return apidldest; + for (i = 0; i < cidl; i++) + apidldest[i] = ILClone(apidlsrc[i]); + + return apidldest; } /************************************************************************* -* _ILCopyCidaToaPidl -* -* creates aPidl from CIDA -*/ + * _ILCopyCidaToaPidl + * + * creates aPidl from CIDA + */ LPITEMIDLIST* _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, LPIDA cida) { - UINT i; - LPITEMIDLIST * dst = (LPITEMIDLIST*)SHAlloc(cida->cidl * sizeof(LPITEMIDLIST)); + UINT i; + LPITEMIDLIST *dst; - if(!dst) return NULL; + dst = SHAlloc(cida->cidl * sizeof(LPITEMIDLIST)); + if (!dst) + return NULL; - if (pidl) - *pidl = ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[0]])); + if (pidl) + *pidl = ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[0]])); - for (i = 0; i < cida->cidl; i++) - dst[i] = ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[i + 1]])); + for (i = 0; i < cida->cidl; i++) + dst[i] = ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[i + 1]])); - return dst; + return dst; } diff --git a/reactos/lib/shell32/pidl.h b/reactos/lib/shell32/pidl.h index b28d217ff6b..1bf1828beba 100644 --- a/reactos/lib/shell32/pidl.h +++ b/reactos/lib/shell32/pidl.h @@ -208,11 +208,14 @@ LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid); /* Like _ILCreateGuid, but using the string szGUID. */ LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID); +LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID); /* Commonly used PIDLs representing file system objects. */ LPITEMIDLIST _ILCreateDesktop (void); LPITEMIDLIST _ILCreateFromFindDataA(WIN32_FIND_DATAA *stffile); +LPITEMIDLIST _ILCreateFromFindDataW(WIN32_FIND_DATAW *stffile); HRESULT _ILCreateFromPathA (LPCSTR szPath, LPITEMIDLIST* ppidl); +HRESULT _ILCreateFromPathW (LPCWSTR szPath, LPITEMIDLIST* ppidl); /* Other helpers */ LPITEMIDLIST _ILCreateMyComputer (void); diff --git a/reactos/lib/shell32/shell32.spec b/reactos/lib/shell32/shell32.spec index 17e70984602..b038862cd3f 100644 --- a/reactos/lib/shell32/shell32.spec +++ b/reactos/lib/shell32/shell32.spec @@ -3,193 +3,186 @@ # win95 and winNT dlls import shell32.dll by ordinal) # This list was updated to dll version 4.72 - 2 stdcall SHChangeNotifyRegister(long long long long long ptr) - 4 stdcall SHChangeNotifyDeregister (long) - 5 stdcall SHChangeNotifyUpdateEntryList (long long long long) - 9 stub PifMgr_OpenProperties - 10 stub PifMgr_GetProperties - 11 stub PifMgr_SetProperties - 13 stub PifMgr_CloseProperties - 15 stdcall ILGetDisplayName(ptr ptr) - 16 stdcall ILFindLastID(ptr) - 17 stdcall ILRemoveLastID(ptr) - 18 stdcall ILClone(ptr) - 19 stdcall ILCloneFirst (ptr) - 20 stdcall ILGlobalClone (ptr) - 21 stdcall ILIsEqual (ptr ptr) - 23 stdcall ILIsParent (ptr ptr long) - 24 stdcall ILFindChild (ptr ptr) - 25 stdcall ILCombine(ptr ptr) - 26 stdcall ILLoadFromStream (ptr ptr) - 27 stdcall ILSaveToStream(ptr ptr) - 28 stdcall SHILCreateFromPath(ptr ptr ptr) SHILCreateFromPathAW - 29 stdcall PathIsRoot(ptr) PathIsRootAW - 30 stdcall PathBuildRoot(ptr long) PathBuildRootAW - 31 stdcall PathFindExtension(ptr) PathFindExtensionAW - 32 stdcall PathAddBackslash(ptr) PathAddBackslashAW - 33 stdcall PathRemoveBlanks(ptr) PathRemoveBlanksAW - 34 stdcall PathFindFileName(ptr) PathFindFileNameAW - 35 stdcall PathRemoveFileSpec(ptr) PathRemoveFileSpecAW - 36 stdcall PathAppend(ptr ptr) PathAppendAW - 37 stdcall PathCombine(ptr ptr ptr) PathCombineAW - 38 stdcall PathStripPath(ptr)PathStripPathAW - 39 stdcall PathIsUNC (ptr) PathIsUNCAW - 40 stdcall PathIsRelative (ptr) PathIsRelativeAW - 41 stdcall IsLFNDriveA(str) - 42 stdcall IsLFNDriveW(wstr) - 43 stdcall PathIsExe (ptr) PathIsExeAW - 45 stdcall PathFileExists(ptr) PathFileExistsAW - 46 stdcall PathMatchSpec (ptr ptr) PathMatchSpecAW - 47 stdcall PathMakeUniqueName (ptr long ptr ptr ptr)PathMakeUniqueNameAW - 48 stdcall PathSetDlgItemPath (long long ptr) PathSetDlgItemPathAW - 49 stdcall PathQualify (ptr) PathQualifyAW - 50 stdcall PathStripToRoot (ptr) PathStripToRootAW - 51 stdcall PathResolve(str long long) PathResolveAW - 52 stdcall PathGetArgs(str) PathGetArgsAW - 53 stdcall DoEnvironmentSubst (long long) DoEnvironmentSubstAW - 54 stdcall DragAcceptFiles(long long) - 55 stdcall PathQuoteSpaces (ptr) PathQuoteSpacesAW - 56 stdcall PathUnquoteSpaces(str) PathUnquoteSpacesAW - 57 stdcall PathGetDriveNumber (str) PathGetDriveNumberAW - 58 stdcall ParseField(str long ptr long) ParseFieldAW - 59 stdcall RestartDialog(long wstr long) - 60 stdcall ExitWindowsDialog(long) - 61 stdcall RunFileDlg(long long long str str long) - 62 stdcall PickIconDlg(long long long long) - 63 stdcall GetFileNameFromBrowse(long long long long str str str) - 64 stdcall DriveType (long) - 65 stub InvalidateDriveType - 66 stdcall IsNetDrive(long) - 67 stdcall Shell_MergeMenus (long long long long long long) - 68 stdcall SHGetSetSettings(ptr long long) - 69 stub SHGetNetResource - 70 stdcall SHCreateDefClassObject(long long long long long) - 71 stdcall Shell_GetImageList(ptr ptr) - 72 stdcall Shell_GetCachedImageIndex(ptr ptr long) Shell_GetCachedImageIndexAW - 73 stdcall SHShellFolderView_Message(long long long) - 74 stdcall SHCreateStdEnumFmtEtc(long ptr ptr) - 75 stdcall PathYetAnotherMakeUniqueName(ptr wstr wstr wstr) + 2 stdcall -noname SHChangeNotifyRegister(long long long long long ptr) + 4 stdcall -noname SHChangeNotifyDeregister(long) + 5 stdcall -noname SHChangeNotifyUpdateEntryList(long long long long) + 9 stub -noname PifMgr_OpenProperties + 10 stub -noname PifMgr_GetProperties + 11 stub -noname PifMgr_SetProperties + 13 stub -noname PifMgr_CloseProperties + 15 stdcall -noname ILGetDisplayName(ptr ptr) + 16 stdcall -noname ILFindLastID(ptr) + 17 stdcall -noname ILRemoveLastID(ptr) + 18 stdcall -noname ILClone(ptr) + 19 stdcall -noname ILCloneFirst(ptr) + 20 stdcall -noname ILGlobalClone(ptr) + 21 stdcall -noname ILIsEqual(ptr ptr) + 23 stdcall -noname ILIsParent(ptr ptr long) + 24 stdcall -noname ILFindChild(ptr ptr) + 25 stdcall -noname ILCombine(ptr ptr) + 26 stdcall -noname ILLoadFromStream(ptr ptr) + 27 stdcall -noname ILSaveToStream(ptr ptr) + 28 stdcall -noname SHILCreateFromPath(ptr ptr ptr) SHILCreateFromPathAW + 29 stdcall -noname PathIsRoot(ptr) PathIsRootAW + 30 stdcall -noname PathBuildRoot(ptr long) PathBuildRootAW + 31 stdcall -noname PathFindExtension(ptr) PathFindExtensionAW + 32 stdcall -noname PathAddBackslash(ptr) PathAddBackslashAW + 33 stdcall -noname PathRemoveBlanks(ptr) PathRemoveBlanksAW + 34 stdcall -noname PathFindFileName(ptr) PathFindFileNameAW + 35 stdcall -noname PathRemoveFileSpec(ptr) PathRemoveFileSpecAW + 36 stdcall -noname PathAppend(ptr ptr) PathAppendAW + 37 stdcall -noname PathCombine(ptr ptr ptr) PathCombineAW + 38 stdcall -noname PathStripPath(ptr)PathStripPathAW + 39 stdcall -noname PathIsUNC(ptr) PathIsUNCAW + 40 stdcall -noname PathIsRelative(ptr) PathIsRelativeAW + 41 stdcall -noname IsLFNDriveA(str) + 42 stdcall -noname IsLFNDriveW(wstr) + 43 stdcall -noname PathIsExe(ptr) PathIsExeAW + 45 stdcall -noname PathFileExists(ptr) PathFileExistsAW + 46 stdcall -noname PathMatchSpec(ptr ptr) PathMatchSpecAW + 47 stdcall -noname PathMakeUniqueName(ptr long ptr ptr ptr)PathMakeUniqueNameAW + 48 stdcall -noname PathSetDlgItemPath(long long ptr) PathSetDlgItemPathAW + 49 stdcall -noname PathQualify(ptr) PathQualifyAW + 50 stdcall -noname PathStripToRoot(ptr) PathStripToRootAW + 51 stdcall -noname PathResolve(str long long) PathResolveAW + 52 stdcall -noname PathGetArgs(str) PathGetArgsAW + 53 stdcall DoEnvironmentSubst(long long) DoEnvironmentSubstAW + 55 stdcall -noname PathQuoteSpaces(ptr) PathQuoteSpacesAW + 56 stdcall -noname PathUnquoteSpaces(str) PathUnquoteSpacesAW + 57 stdcall -noname PathGetDriveNumber(str) PathGetDriveNumberAW + 58 stdcall -noname ParseField(str long ptr long) ParseFieldAW + 59 stdcall -noname RestartDialog(long wstr long) + 60 stdcall -noname ExitWindowsDialog(long) + 61 stdcall -noname RunFileDlg(long long long str str long) + 62 stdcall -noname PickIconDlg(long long long long) + 63 stdcall -noname GetFileNameFromBrowse(long long long long str str str) + 64 stdcall -noname DriveType(long) + 65 stub -noname InvalidateDriveType + 66 stdcall -noname IsNetDrive(long) + 67 stdcall -noname Shell_MergeMenus(long long long long long long) + 68 stdcall -noname SHGetSetSettings(ptr long long) + 69 stub -noname SHGetNetResource + 70 stdcall -noname SHCreateDefClassObject(long long long long long) + 71 stdcall -noname Shell_GetImageList(ptr ptr) + 72 stdcall -noname Shell_GetCachedImageIndex(ptr ptr long) Shell_GetCachedImageIndexAW + 73 stdcall -noname SHShellFolderView_Message(long long long) + 74 stdcall -noname SHCreateStdEnumFmtEtc(long ptr ptr) + 75 stdcall -noname PathYetAnotherMakeUniqueName(ptr wstr wstr wstr) 76 stub DragQueryInfo - 77 stdcall SHMapPIDLToSystemImageListIndex(ptr ptr ptr) - 78 stdcall OleStrToStrN(str long wstr long) OleStrToStrNAW - 79 stdcall StrToOleStrN(wstr long str long) StrToOleStrNAW - 80 stdcall DragFinish(long) - 81 stdcall DragQueryFile(long long ptr long) DragQueryFileA - 82 stdcall DragQueryFileA(long long ptr long) - 83 stdcall CIDLData_CreateFromIDArray(ptr long ptr ptr) + 77 stdcall -noname SHMapPIDLToSystemImageListIndex(ptr ptr ptr) + 78 stdcall -noname OleStrToStrN(str long wstr long) OleStrToStrNAW + 79 stdcall -noname StrToOleStrN(wstr long str long) StrToOleStrNAW + 83 stdcall -noname CIDLData_CreateFromIDArray(ptr long ptr ptr) 84 stub SHIsBadInterfacePtr - 85 stdcall OpenRegStream(long str str long) shlwapi.SHOpenRegStreamA - 86 stdcall SHRegisterDragDrop(long ptr) - 87 stdcall SHRevokeDragDrop(long) - 88 stdcall SHDoDragDrop(long ptr ptr long ptr) - 89 stdcall SHCloneSpecialIDList(long long long) - 90 stdcall SHFindFiles(ptr ptr) + 85 stdcall -noname OpenRegStream(long str str long) shlwapi.SHOpenRegStreamA + 86 stdcall -noname SHRegisterDragDrop(long ptr) + 87 stdcall -noname SHRevokeDragDrop(long) + 88 stdcall -noname SHDoDragDrop(long ptr ptr long ptr) + 89 stdcall -noname SHCloneSpecialIDList(long long long) + 90 stdcall -noname SHFindFiles(ptr ptr) 91 stub SHFindComputer - 92 stdcall PathGetShortPath (ptr) PathGetShortPathAW - 93 stdcall Win32CreateDirectory(wstr ptr) Win32CreateDirectoryAW - 94 stdcall Win32RemoveDirectory(wstr) Win32RemoveDirectoryAW - 95 stdcall SHLogILFromFSIL (ptr) - 96 stdcall StrRetToStrN (ptr long ptr ptr) StrRetToStrNAW - 97 stdcall SHWaitForFileToOpen (long long long) - 98 stdcall SHGetRealIDL (ptr ptr ptr) - 99 stdcall SetAppStartingCursor (long long) - 100 stdcall SHRestricted(long) + 92 stdcall -noname PathGetShortPath(ptr) PathGetShortPathAW + 93 stdcall -noname Win32CreateDirectory(wstr ptr) Win32CreateDirectoryAW + 94 stdcall -noname Win32RemoveDirectory(wstr) Win32RemoveDirectoryAW + 95 stdcall -noname SHLogILFromFSIL(ptr) + 96 stdcall -noname StrRetToStrN(ptr long ptr ptr) StrRetToStrNAW + 97 stdcall -noname SHWaitForFileToOpen (long long long) + 98 stdcall -noname SHGetRealIDL(ptr ptr ptr) + 99 stdcall -noname SetAppStartingCursor(long long) + 100 stdcall -noname SHRestricted(long) - 102 stdcall SHCoCreateInstance(wstr ptr long ptr ptr) - 103 stdcall SignalFileOpen(long) - 104 stdcall FileMenu_DeleteAllItems(long) - 105 stdcall FileMenu_DrawItem(long ptr) - 106 stdcall FileMenu_FindSubMenuByPidl(long ptr) - 107 stdcall FileMenu_GetLastSelectedItemPidls(long ptr ptr) - 108 stdcall FileMenu_HandleMenuChar(long long) - 109 stdcall FileMenu_InitMenuPopup (long) - 110 stdcall FileMenu_InsertUsingPidl (long long ptr long long ptr) - 111 stdcall FileMenu_Invalidate (long) - 112 stdcall FileMenu_MeasureItem(long ptr) - 113 stdcall FileMenu_ReplaceUsingPidl (long long ptr long ptr) - 114 stdcall FileMenu_Create (long long long long long) - 115 stdcall FileMenu_AppendItem (long ptr long long long long) FileMenu_AppendItemAW - 116 stdcall FileMenu_TrackPopupMenuEx (long long long long long long) - 117 stdcall FileMenu_DeleteItemByCmd(long long) - 118 stdcall FileMenu_Destroy (long) - 119 stdcall IsLFNDrive(ptr) IsLFNDriveAW - 120 stdcall FileMenu_AbortInitMenu () - 121 stdcall SHFlushClipboard () + 102 stdcall -noname SHCoCreateInstance(wstr ptr long ptr ptr) + 103 stdcall -noname SignalFileOpen(long) + 104 stdcall -noname FileMenu_DeleteAllItems(long) + 105 stdcall -noname FileMenu_DrawItem(long ptr) + 106 stdcall -noname FileMenu_FindSubMenuByPidl(long ptr) + 107 stdcall -noname FileMenu_GetLastSelectedItemPidls(long ptr ptr) + 108 stdcall -noname FileMenu_HandleMenuChar(long long) + 109 stdcall -noname FileMenu_InitMenuPopup(long) + 110 stdcall -noname FileMenu_InsertUsingPidl (long long ptr long long ptr) + 111 stdcall -noname FileMenu_Invalidate(long) + 112 stdcall -noname FileMenu_MeasureItem(long ptr) + 113 stdcall -noname FileMenu_ReplaceUsingPidl(long long ptr long ptr) + 114 stdcall -noname FileMenu_Create(long long long long long) + 115 stdcall -noname FileMenu_AppendItem(long ptr long long long long) FileMenu_AppendItemAW + 116 stdcall -noname FileMenu_TrackPopupMenuEx(long long long long long long) + 117 stdcall -noname FileMenu_DeleteItemByCmd(long long) + 118 stdcall -noname FileMenu_Destroy(long) + 119 stdcall -noname IsLFNDrive(ptr) IsLFNDriveAW + 120 stdcall -noname FileMenu_AbortInitMenu() + 121 stdcall -noname SHFlushClipboard() 122 stdcall -noname RunDLL_CallEntry16(long long long str long) #name wrong? - 123 stdcall SHFreeUnusedLibraries () - 124 stdcall FileMenu_AppendFilesForPidl(long ptr long) - 125 stdcall FileMenu_AddFilesForPidl(long long long ptr long long ptr) - 126 stdcall SHOutOfMemoryMessageBox (long long long) - 127 stdcall SHWinHelp (long long long long) - 128 stdcall -private DllGetClassObject(long long ptr) SHELL32_DllGetClassObject - 129 stdcall DAD_AutoScroll(long ptr ptr) - 130 stdcall DAD_DragEnter(long) - 131 stdcall DAD_DragEnterEx(long long long) - 132 stdcall DAD_DragLeave() - 133 stdcall DragQueryFileW(long long ptr long) - 134 stdcall DAD_DragMove(long long) - 135 stdcall DragQueryPoint(long ptr) - 136 stdcall DAD_SetDragImage(long long) - 137 stdcall DAD_ShowDragImage (long) + 123 stdcall -noname SHFreeUnusedLibraries() + 124 stdcall -noname FileMenu_AppendFilesForPidl(long ptr long) + 125 stdcall -noname FileMenu_AddFilesForPidl(long long long ptr long long ptr) + 126 stdcall -noname SHOutOfMemoryMessageBox(long long long) + 127 stdcall -noname SHWinHelp(long long long long) + 129 stdcall -noname DAD_AutoScroll(long ptr ptr) + 130 stdcall -noname DAD_DragEnter(long) + 131 stdcall -noname DAD_DragEnterEx(long long long) + 132 stdcall -noname DAD_DragLeave() + 134 stdcall -noname DAD_DragMove(long long) + 136 stdcall -noname DAD_SetDragImage(long long) + 137 stdcall -noname DAD_ShowDragImage(long) 139 stub Desktop_UpdateBriefcaseOnEvent - 140 stdcall FileMenu_DeleteItemByIndex(long long) - 141 stdcall FileMenu_DeleteItemByFirstID(long long) - 142 stdcall FileMenu_DeleteSeparator(long) - 143 stdcall FileMenu_EnableItemByCmd(long long long) - 144 stdcall FileMenu_GetItemExtent (long long) - 145 stdcall PathFindOnPath (ptr ptr) PathFindOnPathAW - 146 stdcall RLBuildListOfPaths() - 147 stdcall SHCLSIDFromString(long long) SHCLSIDFromStringAW - 149 stdcall SHFind_InitMenuPopup(long long long long) + 140 stdcall -noname FileMenu_DeleteItemByIndex(long long) + 141 stdcall -noname FileMenu_DeleteItemByFirstID(long long) + 142 stdcall -noname FileMenu_DeleteSeparator(long) + 143 stdcall -noname FileMenu_EnableItemByCmd(long long long) + 144 stdcall -noname FileMenu_GetItemExtent(long long) + 145 stdcall -noname PathFindOnPath(ptr ptr) PathFindOnPathAW + 146 stdcall -noname RLBuildListOfPaths() + 147 stdcall -noname SHCLSIDFromString(long long) SHCLSIDFromStringAW + 149 stdcall -noname SHFind_InitMenuPopup(long long long long) - 151 stdcall SHLoadOLE (long) - 152 stdcall ILGetSize(ptr) - 153 stdcall ILGetNext(ptr) - 154 stdcall ILAppend (long long long) - 155 stdcall ILFree (ptr) - 156 stdcall ILGlobalFree (ptr) - 157 stdcall ILCreateFromPath (ptr) ILCreateFromPathAW - 158 stdcall PathGetExtension(str long long) PathGetExtensionAW - 159 stdcall PathIsDirectory(ptr)PathIsDirectoryAW + 151 stdcall -noname SHLoadOLE(long) + 152 stdcall -noname ILGetSize(ptr) + 153 stdcall -noname ILGetNext(ptr) + 154 stdcall -noname ILAppend(long long long) + 155 stdcall -noname ILFree(ptr) + 156 stdcall -noname ILGlobalFree(ptr) + 157 stdcall -noname ILCreateFromPath(ptr) ILCreateFromPathAW + 158 stdcall -noname PathGetExtension(str long long) PathGetExtensionAW + 159 stdcall -noname PathIsDirectory(ptr) PathIsDirectoryAW 160 stub SHNetConnectionDialog - 161 stdcall SHRunControlPanel (long long) - 162 stdcall SHSimpleIDListFromPath (ptr) SHSimpleIDListFromPathAW - 163 stdcall StrToOleStr (wstr str) StrToOleStrAW - 164 stdcall Win32DeleteFile(str) Win32DeleteFileAW - 165 stdcall SHCreateDirectory(long ptr) - 166 stdcall CallCPLEntry16(long long long long long long) - 167 stdcall SHAddFromPropSheetExtArray(long long long) - 168 stdcall SHCreatePropSheetExtArray(long str long) - 169 stdcall SHDestroyPropSheetExtArray(long) - 170 stdcall SHReplaceFromPropSheetExtArray(long long long long) - 171 stdcall PathCleanupSpec(ptr ptr) - 172 stdcall SHCreateLinks(long str ptr long ptr) - 173 stdcall SHValidateUNC(long long long) - 174 stdcall SHCreateShellFolderViewEx (ptr ptr) - 175 stdcall SHGetSpecialFolderPath(long long long long) SHGetSpecialFolderPathAW - 176 stdcall SHSetInstanceExplorer (long) + 161 stdcall -noname SHRunControlPanel(long long) + 162 stdcall -noname SHSimpleIDListFromPath(ptr) SHSimpleIDListFromPathAW + 163 stdcall -noname StrToOleStr(wstr str) StrToOleStrAW + 164 stdcall -noname Win32DeleteFile(str) Win32DeleteFileAW + 165 stdcall -noname SHCreateDirectory(long ptr) + 166 stdcall -noname CallCPLEntry16(long long long long long long) + 167 stdcall -noname SHAddFromPropSheetExtArray(long long long) + 168 stdcall -noname SHCreatePropSheetExtArray(long str long) + 169 stdcall -noname SHDestroyPropSheetExtArray(long) + 170 stdcall -noname SHReplaceFromPropSheetExtArray(long long long long) + 171 stdcall -noname PathCleanupSpec(ptr ptr) + 172 stdcall -noname SHCreateLinks(long str ptr long ptr) + 173 stdcall -noname SHValidateUNC(long long long) + 174 stdcall -noname SHCreateShellFolderViewEx(ptr ptr) + 175 stdcall -noname SHGetSpecialFolderPath(long long long long) SHGetSpecialFolderPathAW + 176 stdcall -noname SHSetInstanceExplorer(long) 177 stub DAD_SetDragImageFromListView - 178 stdcall SHObjectProperties(long long wstr wstr) - 179 stdcall SHGetNewLinkInfoA(str str ptr long long) - 180 stdcall SHGetNewLinkInfoW(wstr wstr ptr long long) - 181 stdcall RegisterShellHook(long long) - 182 varargs ShellMessageBoxW(long long long str long) - 183 varargs ShellMessageBoxA(long long long str long) - 184 stdcall ArrangeWindows(long long long long long) + 178 stdcall -noname SHObjectProperties(long long wstr wstr) + 179 stdcall -noname SHGetNewLinkInfoA(str str ptr long long) + 180 stdcall -noname SHGetNewLinkInfoW(wstr wstr ptr long long) + 181 stdcall -noname RegisterShellHook(long long) + 182 varargs -noname ShellMessageBoxW(long long long str long) + 183 varargs -noname ShellMessageBoxA(long long long str long) + 184 stdcall -noname ArrangeWindows(long long long long long) 185 stub SHHandleDiskFull - 186 stdcall ILGetDisplayNameEx(ptr ptr ptr long) + 186 stdcall -noname ILGetDisplayNameEx(ptr ptr ptr long) 187 stub ILGetPseudoNameW - 188 stdcall ShellDDEInit(long) - 189 stdcall ILCreateFromPathA(str) - 190 stdcall ILCreateFromPathW(wstr) - 191 stdcall SHUpdateImageA(str long long long) - 192 stdcall SHUpdateImageW(wstr long long long) - 193 stdcall SHHandleUpdateImage(ptr) + 188 stdcall -noname ShellDDEInit(long) + 189 stdcall -noname ILCreateFromPathA(str) + 190 stdcall -noname ILCreateFromPathW(wstr) + 191 stdcall -noname SHUpdateImageA(str long long long) + 192 stdcall -noname SHUpdateImageW(wstr long long long) + 193 stdcall -noname SHHandleUpdateImage(ptr) 194 stub SHCreatePropSheetExtArrayEx - 195 stdcall SHFree(ptr) - 196 stdcall SHAlloc(long) + 195 stdcall -noname SHFree(ptr) + 196 stdcall -noname SHAlloc(long) 197 stub SHGlobalDefect - 198 stdcall SHAbortInvokeCommand () + 198 stdcall -noname SHAbortInvokeCommand() 199 stub SHGetFileIcon 200 stub SHLocalAlloc 201 stub SHLocalFree @@ -206,72 +199,15 @@ 212 stub Printers_AddPrinterPropPages 213 stub Printers_RegisterWindowW 214 stub Printers_UnregisterWindow - 215 stdcall SHStartNetConnectionDialog(long str long) + 215 stdcall -noname SHStartNetConnectionDialog(long str long) 243 stdcall @(long long) shell32_243 - 244 stdcall SHInitRestricted(ptr ptr) - 247 stdcall SHGetDataFromIDListA (ptr ptr long ptr long) - 248 stdcall SHGetDataFromIDListW (ptr ptr long ptr long) - 249 stdcall PathParseIconLocation (ptr) PathParseIconLocationAW - 250 stdcall PathRemoveExtension (ptr) PathRemoveExtensionAW - 251 stdcall PathRemoveArgs (ptr) PathRemoveArgsAW + 244 stdcall -noname SHInitRestricted(ptr ptr) + 249 stdcall -noname PathParseIconLocation(ptr) PathParseIconLocationAW + 250 stdcall -noname PathRemoveExtension(ptr) PathRemoveExtensionAW + 251 stdcall -noname PathRemoveArgs(ptr) PathRemoveArgsAW 256 stdcall @(ptr ptr) SHELL32_256 - 271 stub SheChangeDirA - 272 stub SheChangeDirExA - 273 stub SheChangeDirExW - 274 stdcall SheChangeDirW(wstr) - 275 stub SheConvertPathW - 276 stub SheFullPathA - 277 stub SheFullPathW - 278 stub SheGetCurDrive - 279 stub SheGetDirA - 280 stub SheGetDirExW - 281 stdcall SheGetDirW (long long) - 282 stub SheGetPathOffsetW - 283 stub SheRemoveQuotesA - 284 stub SheRemoveQuotesW - 285 stub SheSetCurDrive - 286 stub SheShortenPathA - 287 stub SheShortenPathW - 288 stdcall ShellAboutA(long str str long) - 289 stdcall ShellAboutW(long wstr wstr long) - 290 stdcall ShellExecuteA(long str str str str long) - 291 stdcall ShellExecuteEx (long) ShellExecuteExA - 292 stdcall ShellExecuteExA (long) - 293 stdcall ShellExecuteExW (long) - 294 stdcall ShellExecuteW (long wstr wstr wstr wstr long) - 296 stdcall Shell_NotifyIcon(long ptr) Shell_NotifyIconA - 297 stdcall Shell_NotifyIconA(long ptr) - 298 stdcall Shell_NotifyIconW(long ptr) #299 stub Shl1632_ThunkData32 #300 stub Shl3216_ThunkData32 - 301 stdcall StrChrA(str long) shlwapi.StrChrA - 302 stdcall StrChrIA(str long) shlwapi.StrChrIA - 303 stdcall StrChrIW(wstr long) shlwapi.StrChrIW - 304 stdcall StrChrW(wstr long) shlwapi.StrChrW - 305 stdcall StrCmpNA(str str long) shlwapi.StrCmpNA - 306 stdcall StrCmpNIA(str str long) shlwapi.StrCmpNIA - 307 stdcall StrCmpNIW(wstr wstr long) shlwapi.StrCmpNIW - 308 stdcall StrCmpNW(wstr wstr long) shlwapi.StrCmpNW - 309 stdcall StrCpyNA (ptr str long) lstrcpynA - 310 stdcall StrCpyNW(wstr wstr long) shlwapi.StrCpyNW - 311 stdcall StrNCmpA(str str long) shlwapi.StrCmpNA - 312 stdcall StrNCmpIA(str str long) shlwapi.StrCmpNIA - 313 stdcall StrNCmpIW(wstr wstr long) shlwapi.StrCmpNIW - 314 stdcall StrNCmpW(wstr wstr long) shlwapi.StrCmpNW - 315 stdcall StrNCpyA (ptr str long) lstrcpynA - 316 stdcall StrNCpyW(wstr wstr long) shlwapi.StrCpyNW - 317 stdcall StrRChrA(str str long) shlwapi.StrRChrA - 318 stdcall StrRChrIA(str str long) shlwapi.StrRChrIA - 319 stdcall StrRChrIW(str str long) shlwapi.StrRChrIW - 320 stdcall StrRChrW(wstr wstr long) shlwapi.StrRChrW - 321 stub StrRStrA - 322 stdcall StrRStrIA(str str str) shlwapi.StrRStrIA - 323 stdcall StrRStrIW(wstr wstr wstr) shlwapi.StrRStrIW - 324 stub StrRStrW - 325 stdcall StrStrA(str str) shlwapi.StrStrA - 326 stdcall StrStrIA(str str) shlwapi.StrStrIA - 327 stdcall StrStrIW(wstr wstr) shlwapi.StrStrIW - 328 stdcall StrStrW(wstr wstr) shlwapi.StrStrW 505 stdcall SHRegCloseKey (long) 506 stdcall SHRegOpenKeyA (long str long) @@ -282,38 +218,38 @@ 511 stdcall SHRegQueryValueExW (long wstr ptr ptr ptr ptr) 512 stdcall SHRegDeleteKeyW (long wstr) - 520 stdcall -noname SHAllocShared (ptr long long) - 521 stdcall -noname SHLockShared (long long) - 522 stdcall -noname SHUnlockShared (ptr) - 523 stdcall -noname SHFreeShared (long long) - 524 stdcall RealDriveType (long long) + 520 stdcall -noname SHAllocShared(ptr long long) + 521 stdcall -noname SHLockShared(long long) + 522 stdcall -noname SHUnlockShared(ptr) + 523 stdcall -noname SHFreeShared(long long) + 524 stdcall -noname RealDriveType(long long) 525 stub RealDriveTypeFlags - 640 stdcall NTSHChangeNotifyRegister (long long long long long long) - 641 stdcall NTSHChangeNotifyDeregister (long) + 640 stdcall -noname NTSHChangeNotifyRegister(long long long long long long) + 641 stdcall -noname NTSHChangeNotifyDeregister(long) 643 stub SHChangeNotifyReceive - 644 stdcall SHChangeNotification_Lock(long long ptr ptr) - 645 stdcall SHChangeNotification_Unlock(long) + 644 stdcall -noname SHChangeNotification_Lock(long long ptr ptr) + 645 stdcall -noname SHChangeNotification_Unlock(long) 646 stub SHChangeRegistrationReceive 647 stub ReceiveAddToRecentDocs 648 stub SHWaitOp_Operate - 650 stdcall PathIsSameRoot(ptr ptr)PathIsSameRootAW + 650 stdcall -noname PathIsSameRoot(ptr ptr) PathIsSameRootAW # nt40/win98 - 651 stdcall ReadCabinetState (long long) # OldReadCabinetState - 652 stdcall WriteCabinetState (long) - 653 stdcall PathProcessCommand (long long long long) PathProcessCommandAW + 651 stdcall -noname ReadCabinetState(long long) # OldReadCabinetState + 652 stdcall -noname WriteCabinetState(long) + 653 stdcall -noname PathProcessCommand(long long long long) PathProcessCommandAW # win98 - 654 stdcall @(long long)shell32_654 # ReadCabinetState@8 - 660 stdcall FileIconInit(long) - 680 stdcall IsUserAdmin() + 654 stdcall @(long long) shell32_654 # ReadCabinetState@8 + 660 stdcall -noname FileIconInit(long) + 680 stdcall -noname IsUserAdmin() # >= NT5 - 714 stdcall @(ptr)SHELL32_714 # PathIsTemporaryW - 730 stdcall RestartDialogEx(long wstr long long) + 714 stdcall @(ptr) SHELL32_714 # PathIsTemporaryW + 730 stdcall -noname RestartDialogEx(long wstr long long) 1217 stub FOOBAR1217 # no joke! This is the real name!! @@ -329,14 +265,22 @@ @ stdcall Control_FillCache_RunDLLW(long long long long) @ stdcall Control_RunDLL(ptr ptr str long) Control_RunDLLA @ stdcall Control_RunDLLA(ptr ptr str long) +@ stub Control_RunDLLAsUserW @ stdcall Control_RunDLLW(ptr ptr wstr long) @ stdcall -private DllCanUnloadNow() SHELL32_DllCanUnloadNow +@ stdcall -private DllGetClassObject(long long ptr) SHELL32_DllGetClassObject @ stdcall DllInstall(long wstr)SHELL32_DllInstall @ stdcall -private DllRegisterServer() SHELL32_DllRegisterServer @ stdcall -private DllUnregisterServer() SHELL32_DllUnregisterServer @ stdcall DoEnvironmentSubstA(str str) @ stdcall DoEnvironmentSubstW(wstr wstr) +@ stdcall DragAcceptFiles(long long) +@ stdcall DragFinish(long) +@ stdcall DragQueryFile(long long ptr long) DragQueryFileA +@ stdcall DragQueryFileA(long long ptr long) @ stub DragQueryFileAorW +@ stdcall DragQueryFileW(long long ptr long) +@ stdcall DragQueryPoint(long ptr) @ stdcall DuplicateIcon(long long) @ stdcall ExtractAssociatedIconA(long str ptr) @ stdcall ExtractAssociatedIconExA(long str long long) @@ -353,9 +297,11 @@ @ stub FindExeDlgProc @ stdcall FindExecutableA(ptr ptr ptr) @ stdcall FindExecutableW(wstr wstr wstr) +@ stub FixupOptionalComponents @ stdcall FreeIconList(long) @ stub InternalExtractIconListA @ stub InternalExtractIconListW +@ stub OCInstall @ stub OpenAs_RunDLL @ stub OpenAs_RunDLLA @ stub OpenAs_RunDLLW @@ -373,16 +319,48 @@ @ stdcall SHBrowseForFolderA(ptr) @ stdcall SHBrowseForFolderW(ptr) @ stdcall SHChangeNotify (long long ptr ptr) +@ stub SHChangeNotifySuspendResume @ stdcall SHCreateDirectoryExA(long str ptr) @ stdcall SHCreateDirectoryExW(long wstr ptr) +@ stub SHCreateProcessAsUserW +@ stdcall SheChangeDirA(str) +@ stub SheChangeDirExA +@ stub SheChangeDirExW +@ stdcall SheChangeDirW(wstr) +@ stub SheConvertPathW +@ stub SheFullPathA +@ stub SheFullPathW +@ stub SheGetCurDrive +@ stdcall SheGetDirA(long long) +@ stub SheGetDirExW +@ stdcall SheGetDirW (long long) +@ stub SheGetPathOffsetW +@ stdcall ShellAboutA(long str str long) +@ stdcall ShellAboutW(long wstr wstr long) +@ stdcall ShellExecuteA(long str str str str long) +@ stdcall ShellExecuteEx (long) ShellExecuteExA +@ stdcall ShellExecuteExA (long) +@ stdcall ShellExecuteExW (long) +@ stdcall ShellExecuteW (long wstr wstr wstr wstr long) @ stub ShellHookProc +@ stdcall Shell_NotifyIcon(long ptr) Shell_NotifyIconA +@ stdcall Shell_NotifyIconA(long ptr) +@ stdcall Shell_NotifyIconW(long ptr) @ stdcall SHEmptyRecycleBinA(long str long) @ stdcall SHEmptyRecycleBinW(long wstr long) +@ stub SheRemoveQuotesA +@ stub SheRemoveQuotesW +@ stub SheSetCurDrive +@ stub SheShortenPathA +@ stub SheShortenPathW +@ stub SHExtractIconsW @ stdcall SHFileOperation(ptr) SHFileOperationA @ stdcall SHFileOperationA(ptr) @ stdcall SHFileOperationW(ptr) @ stdcall SHFormatDrive(long long long long) @ stdcall SHFreeNameMappings(ptr) +@ stdcall SHGetDataFromIDListA(ptr ptr long ptr long) +@ stdcall SHGetDataFromIDListW(ptr ptr long ptr long) @ stdcall SHGetDesktopFolder(ptr) @ stdcall SHGetFileInfo(ptr long ptr long long) SHGetFileInfoA @ stdcall SHGetFileInfoA(ptr long ptr long long) @@ -395,13 +373,47 @@ @ stdcall SHGetPathFromIDListW(ptr ptr) @ stdcall SHGetSettings(ptr long) @ stdcall SHGetSpecialFolderLocation(long long ptr) -@ stdcall SHHelpShortcuts_RunDLL(long long long long) -@ stub SHHelpShortcuts_RunDLLA -@ stub SHHelpShortcuts_RunDLLW +@ stdcall SHHelpShortcuts_RunDLL(long long long long) SHHelpShortcuts_RunDLLA +@ stdcall SHHelpShortcuts_RunDLLA(long long long long) +@ stdcall SHHelpShortcuts_RunDLLW(long long long long) +@ stub SHInvokePrinterCommandA +@ stub SHInvokePrinterCommandW +@ stub SHIsFileAvailableOffline @ stdcall SHLoadInProc(long) +@ stub SHLoadNonloadedIconOverlayIdentifiers +@ stub SHPathPrepareForWriteA +@ stub SHPathPrepareForWriteW @ stdcall SHQueryRecycleBinA(str ptr) @ stdcall SHQueryRecycleBinW(wstr ptr) @ stub SHUpdateRecycleBinIcon +@ stdcall StrChrA(str long) shlwapi.StrChrA +@ stdcall StrChrIA(str long) shlwapi.StrChrIA +@ stdcall StrChrIW(wstr long) shlwapi.StrChrIW +@ stdcall StrChrW(wstr long) shlwapi.StrChrW +@ stdcall StrCmpNA(str str long) shlwapi.StrCmpNA +@ stdcall StrCmpNIA(str str long) shlwapi.StrCmpNIA +@ stdcall StrCmpNIW(wstr wstr long) shlwapi.StrCmpNIW +@ stdcall StrCmpNW(wstr wstr long) shlwapi.StrCmpNW +@ stdcall StrCpyNA (ptr str long) kernel32.lstrcpynA +@ stdcall StrCpyNW(wstr wstr long) shlwapi.StrCpyNW +@ stdcall StrNCmpA(str str long) shlwapi.StrCmpNA +@ stdcall StrNCmpIA(str str long) shlwapi.StrCmpNIA +@ stdcall StrNCmpIW(wstr wstr long) shlwapi.StrCmpNIW +@ stdcall StrNCmpW(wstr wstr long) shlwapi.StrCmpNW +@ stdcall StrNCpyA (ptr str long) kernel32.lstrcpynA +@ stdcall StrNCpyW(wstr wstr long) shlwapi.StrCpyNW +@ stdcall StrRChrA(str str long) shlwapi.StrRChrA +@ stdcall StrRChrIA(str str long) shlwapi.StrRChrIA +@ stdcall StrRChrIW(str str long) shlwapi.StrRChrIW +@ stdcall StrRChrW(wstr wstr long) shlwapi.StrRChrW +@ stub StrRStrA +@ stdcall StrRStrIA(str str str) shlwapi.StrRStrIA +@ stdcall StrRStrIW(wstr wstr wstr) shlwapi.StrRStrIW +@ stub StrRStrW +@ stdcall StrStrA(str str) shlwapi.StrStrA +@ stdcall StrStrIA(str str) shlwapi.StrStrIA +@ stdcall StrStrIW(wstr wstr) shlwapi.StrStrIW +@ stdcall StrStrW(wstr wstr) shlwapi.StrStrW @ stub WOWShellExecute # @@ -427,6 +439,9 @@ # version 5.00 (Win2K) # _WIN32_IE >= 0x0500 # +@ stub ShellExec_RunDLL +@ stub ShellExec_RunDLLA +@ stub ShellExec_RunDLLW @ stdcall SHBindToParent(ptr ptr ptr ptr) @ stdcall SHGetDiskFreeSpaceA(str ptr ptr ptr) kernel32.GetDiskFreeSpaceExA @ stdcall SHGetDiskFreeSpaceExA(str ptr ptr ptr) kernel32.GetDiskFreeSpaceExA @@ -434,6 +449,8 @@ @ stdcall SHGetFolderPathA(long long long long ptr) @ stdcall SHGetFolderPathW(long long long long ptr) @ stdcall SHGetFolderLocation(long long long long ptr) +@ stub SHGetIconOverlayIndexA +@ stub SHGetIconOverlayIndexW # version 6.0 (WinXP) # _WIN32_IE >= 0x600 diff --git a/reactos/lib/shell32/shell32_Es.rc b/reactos/lib/shell32/shell32_Es.rc index ec7bd2d9cf7..3b4dbe8c630 100644 --- a/reactos/lib/shell32/shell32_Es.rc +++ b/reactos/lib/shell32/shell32_Es.rc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -LANGUAGE LANG_SPANISH, SUBLANG_DEFAULT +LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL MENU_001 MENU DISCARDABLE BEGIN diff --git a/reactos/lib/shell32/shell32_Pt.rc b/reactos/lib/shell32/shell32_Pt.rc index 3ebdf5c22ce..da1600677fd 100644 --- a/reactos/lib/shell32/shell32_Pt.rc +++ b/reactos/lib/shell32/shell32_Pt.rc @@ -188,3 +188,35 @@ STRINGTABLE DISCARDABLE IDS_SHUTDOWN_TITLE "Desligar" IDS_SHUTDOWN_PROMPT "Você quer finalizar a sessão no ReactOS?" } + +/* shell folder path default values - */ +STRINGTABLE DISCARDABLE +{ + IDS_PROGRAMS "Menu Iniciar\\Programas" + IDS_PERSONAL "Meus Documentos" + IDS_FAVORITES "Favoritos" + IDS_STARTUP "Menu Iniciar\\Programas\\Iniciar" + IDS_RECENT "Recent" + IDS_SENDTO "SendTo" + IDS_STARTMENU "Menu Iniciar" + IDS_MYMUSIC "Meus Documentos\\Minhas Músicas" + IDS_MYVIDEO "Meus Documentos\\Meus Vídeos" + IDS_DESKTOPDIRECTORY "Desktop" + IDS_NETHOOD "NetHood" + IDS_TEMPLATES "Templates" + IDS_APPDATA "Application Data" + IDS_PRINTHOOD "PrintHood" + IDS_LOCAL_APPDATA "Configurações locais\\Dados de aplicativos" + IDS_INTERNET_CACHE "Temporary Internet Files" + IDS_COOKIES "Cookies" + IDS_HISTORY "Histórico" + IDS_PROGRAM_FILES "Arquivos de programas" + IDS_MYPICTURES "Meus Documentos\\Minhas Imagens" + IDS_PROGRAM_FILES_COMMON "Arquivos de programas\\Arquivos comuns" + IDS_COMMON_DOCUMENTS "Documentos" + IDS_ADMINTOOLS "Menu Iniciar\\Programas\\Ferramentas Administrativas" + IDS_COMMON_MUSIC "Documentos\\Minhas Músicas" + IDS_COMMON_PICTURES "Documentos\\Minhas Imagens" + IDS_COMMON_VIDEO "Documentos\\Meus Vídeos" + IDS_CDBURN_AREA "Configurações locais\\Dados de aplicativos\\Microsoft\\CD Burning" +} diff --git a/reactos/lib/shell32/shell32_main.c b/reactos/lib/shell32/shell32_main.c index f107146a5ac..44d3e0139ea 100644 --- a/reactos/lib/shell32/shell32_main.c +++ b/reactos/lib/shell32/shell32_main.c @@ -1,5 +1,5 @@ /* - * Shell basics + * Shell basics * * Copyright 1998 Marcus Meissner * Copyright 1998 Juergen Schmied (jsch) * @@ -54,7 +54,7 @@ extern const char * const SHELL_Authors[]; #define MORE_DEBUG 1 /************************************************************************* - * CommandLineToArgvW [SHELL32.@] + * CommandLineToArgvW [SHELL32.@] * * We must interpret the quotes in the command line to rebuild the argv * array correctly: @@ -92,15 +92,18 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs) LPWSTR cmdline; int in_quotes,bcount; - if (*lpCmdline==0) { + if (*lpCmdline==0) + { /* Return the path to the executable */ DWORD len, size=16; hargv=GlobalAlloc(size, 0); - argv=GlobalLock(hargv); - for (;;) { + argv=GlobalLock(hargv); + for (;;) + { len = GetModuleFileNameW(0, (LPWSTR)(argv+1), size-sizeof(LPWSTR)); - if (!len) { + if (!len) + { GlobalFree(hargv); return NULL; } @@ -121,8 +124,10 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs) bcount=0; in_quotes=0; cs=lpCmdline; - while (1) { - if (*cs==0 || ((*cs==0x0009 || *cs==0x0020) && !in_quotes)) { + while (1) + { + if (*cs==0 || ((*cs==0x0009 || *cs==0x0020) && !in_quotes)) + { /* space */ argc++; /* skip the remaining spaces */ @@ -133,14 +138,20 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs) break; bcount=0; continue; - } else if (*cs==0x005c) { + } + else if (*cs==0x005c) + { /* '\', count them */ bcount++; - } else if ((*cs==0x0022) && ((bcount & 1)==0)) { + } + else if ((*cs==0x0022) && ((bcount & 1)==0)) + { /* unescaped '"' */ in_quotes=!in_quotes; bcount=0; - } else { + } + else + { /* a regular character */ bcount=0; } @@ -160,8 +171,10 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs) bcount=0; in_quotes=0; arg=d=s=cmdline; - while (*s) { - if ((*s==0x0009 || *s==0x0020) && !in_quotes) { + while (*s) + { + if ((*s==0x0009 || *s==0x0020) && !in_quotes) + { /* Close the argument and copy it */ *d=0; argv[argc++]=arg; @@ -174,21 +187,28 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs) /* Start with a new argument */ arg=d=s; bcount=0; - } else if (*s==0x005c) { + } + else if (*s==0x005c) + { /* '\\' */ *d++=*s++; bcount++; - } else if (*s==0x0022) { + } + else if (*s==0x0022) + { /* '"' */ - if ((bcount & 1)==0) { - /* Preceeded by an even number of '\', this is half that + if ((bcount & 1)==0) + { + /* Preceded by an even number of '\', this is half that * number of '\', plus a quote which we erase. */ d-=bcount/2; in_quotes=!in_quotes; s++; - } else { - /* Preceeded by an odd number of '\', this is half that + } + else + { + /* Preceded by an odd number of '\', this is half that * number of '\' followed by a '"' */ d=d-bcount/2-1; @@ -196,13 +216,16 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs) s++; } bcount=0; - } else { + } + else + { /* a regular character */ *d++=*s++; bcount=0; } } - if (*arg) { + if (*arg) + { *d='\0'; argv[argc++]=arg; } @@ -212,347 +235,426 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs) return argv; } +#define SHGFI_KNOWN_FLAGS \ + (SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \ + SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \ + SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \ + SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \ + SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED) + /************************************************************************* - * SHGetFileInfoA [SHELL32.@] + * SHGetFileInfoW [SHELL32.@] * */ - DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, - SHFILEINFOW *psfi, UINT sizeofpsfi, - UINT flags ) + SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags ) { - WCHAR szLocation[MAX_PATH], szFullPath[MAX_PATH]; - int iIndex; - DWORD ret = TRUE, dwAttributes = 0; - IShellFolder * psfParent = NULL; - IExtractIconW * pei = NULL; - LPITEMIDLIST pidlLast = NULL, pidl = NULL; - HRESULT hr = S_OK; - BOOL IconNotYetLoaded=TRUE; + WCHAR szLocation[MAX_PATH], szFullPath[MAX_PATH]; + int iIndex; + DWORD ret = TRUE, dwAttributes = 0; + IShellFolder * psfParent = NULL; + IExtractIconW * pei = NULL; + LPITEMIDLIST pidlLast = NULL, pidl = NULL; + HRESULT hr = S_OK; + BOOL IconNotYetLoaded=TRUE; - TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n", - (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags); + TRACE("%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x\n", + (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes, + psfi, psfi->dwAttributes, sizeofpsfi, flags); - if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL))) - return FALSE; + if ( (flags & SHGFI_USEFILEATTRIBUTES) && + (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL))) + return FALSE; - /* windows initializes this values regardless of the flags */ - if (psfi != NULL) { - psfi->szDisplayName[0] = '\0'; - psfi->szTypeName[0] = '\0'; - psfi->iIcon = 0; - } + /* windows initializes this values regardless of the flags */ + if (psfi != NULL) + { + psfi->szDisplayName[0] = '\0'; + psfi->szTypeName[0] = '\0'; + psfi->iIcon = 0; + } - if (!(flags & SHGFI_PIDL)){ - /* SHGitFileInfo should work with absolute and relative paths */ - if (PathIsRelativeW(path)){ - GetCurrentDirectoryW(MAX_PATH, szLocation); - PathCombineW(szFullPath, szLocation, path); - } else { - lstrcpynW(szFullPath, path, MAX_PATH); - } - } - - if (flags & SHGFI_EXETYPE) { - BOOL status = FALSE; - HANDLE hfile; - DWORD BinaryType; - IMAGE_DOS_HEADER mz_header; - IMAGE_NT_HEADERS nt; - DWORD len; - char magic[4]; - - if (flags != SHGFI_EXETYPE) return 0; - - status = GetBinaryTypeW (szFullPath, &BinaryType); - if (!status) return 0; - if ((BinaryType == SCS_DOS_BINARY) - || (BinaryType == SCS_PIF_BINARY)) return 0x4d5a; - - hfile = CreateFileW( szFullPath, GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, 0, 0 ); - if ( hfile == INVALID_HANDLE_VALUE ) return 0; - - /* The next section is adapted from MODULE_GetBinaryType, as we need - * to examine the image header to get OS and version information. We - * know from calling GetBinaryTypeA that the image is valid and either - * an NE or PE, so much error handling can be omitted. - * Seek to the start of the file and read the header information. - */ - - SetFilePointer( hfile, 0, NULL, SEEK_SET ); - ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL ); - - SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ); - ReadFile( hfile, magic, sizeof(magic), &len, NULL ); - if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE ) - { - SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ); - ReadFile( hfile, &nt, sizeof(nt), &len, NULL ); - CloseHandle( hfile ); - if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) { - return IMAGE_NT_SIGNATURE - | (nt.OptionalHeader.MajorSubsystemVersion << 24) - | (nt.OptionalHeader.MinorSubsystemVersion << 16); - } - return IMAGE_NT_SIGNATURE; - } - else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE ) - { - IMAGE_OS2_HEADER ne; - SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ); - ReadFile( hfile, &ne, sizeof(ne), &len, NULL ); - CloseHandle( hfile ); - if (ne.ne_exetyp == 2) return IMAGE_OS2_SIGNATURE - | (ne.ne_expver << 16); - return 0; - } - CloseHandle( hfile ); - return 0; - } - - /* psfi is NULL normally to query EXE type. If it is NULL, none of the - * below makes sense anyway. Windows allows this and just returns FALSE */ - if (psfi == NULL) return FALSE; - - /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES - * is not specified. - The pidl functions fail on not existing file names */ - - if (flags & SHGFI_PIDL) { - pidl = ILClone((LPCITEMIDLIST)path); - } else if (!(flags & SHGFI_USEFILEATTRIBUTES)) { - hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes); - } - - if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES)) + if (!(flags & SHGFI_PIDL)) + { + /* SHGitFileInfo should work with absolute and relative paths */ + if (PathIsRelativeW(path)) { - /* get the parent shellfolder */ - if (pidl) { - hr = SHBindToParent(pidl, &IID_IShellFolder, (LPVOID*)&psfParent, (LPCITEMIDLIST*)&pidlLast); - ILFree(pidl); - } else { - ERR("pidl is null!\n"); - return FALSE; - } + GetCurrentDirectoryW(MAX_PATH, szLocation); + PathCombineW(szFullPath, szLocation, path); } - - /* get the attributes of the child */ - if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES)) - { - if (!(flags & SHGFI_ATTR_SPECIFIED)) - { - psfi->dwAttributes = 0xffffffff; - } - IShellFolder_GetAttributesOf(psfParent, 1, (LPCITEMIDLIST*)&pidlLast, &(psfi->dwAttributes)); - } - - /* get the displayname */ - if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME)) - { - if (flags & SHGFI_USEFILEATTRIBUTES) - { - lstrcpyW (psfi->szDisplayName, PathFindFileNameW(szFullPath)); - } - else - { - STRRET str; - hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str); - StrRetToStrNW (psfi->szDisplayName, MAX_PATH, &str, pidlLast); - } - } - - /* get the type name */ - if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME)) + else { - static const WCHAR szFile[] = { 'F','i','l','e',0 }; - static const WCHAR szDashFile[] = { '-','f','i','l','e',0 }; - if (!(flags & SHGFI_USEFILEATTRIBUTES)) + lstrcpynW(szFullPath, path, MAX_PATH); + } + } + + if (flags & SHGFI_EXETYPE) + { + BOOL status = FALSE; + HANDLE hfile; + DWORD BinaryType; + IMAGE_DOS_HEADER mz_header; + IMAGE_NT_HEADERS nt; + DWORD len; + char magic[4]; + + if (flags != SHGFI_EXETYPE) + return 0; + + status = GetBinaryTypeW (szFullPath, &BinaryType); + if (!status) + return 0; + if ((BinaryType == SCS_DOS_BINARY) || (BinaryType == SCS_PIF_BINARY)) + return 0x4d5a; + + hfile = CreateFileW( szFullPath, GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_EXISTING, 0, 0 ); + if ( hfile == INVALID_HANDLE_VALUE ) + return 0; + + /* + * The next section is adapted from MODULE_GetBinaryType, as we need + * to examine the image header to get OS and version information. We + * know from calling GetBinaryTypeA that the image is valid and either + * an NE or PE, so much error handling can be omitted. + * Seek to the start of the file and read the header information. + */ + + SetFilePointer( hfile, 0, NULL, SEEK_SET ); + ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL ); + + SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ); + ReadFile( hfile, magic, sizeof(magic), &len, NULL ); + if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE ) + { + SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ); + ReadFile( hfile, &nt, sizeof(nt), &len, NULL ); + CloseHandle( hfile ); + if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) { - char ftype[80]; - _ILGetFileType(pidlLast, ftype, 80); - MultiByteToWideChar(CP_ACP, 0, ftype, -1, psfi->szTypeName, 80 ); + return IMAGE_NT_SIGNATURE | + (nt.OptionalHeader.MajorSubsystemVersion << 24) | + (nt.OptionalHeader.MinorSubsystemVersion << 16); } - else + return IMAGE_NT_SIGNATURE; + } + else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE ) + { + IMAGE_OS2_HEADER ne; + SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ); + ReadFile( hfile, &ne, sizeof(ne), &len, NULL ); + CloseHandle( hfile ); + if (ne.ne_exetyp == 2) + return IMAGE_OS2_SIGNATURE | (ne.ne_expver << 16); + return 0; + } + CloseHandle( hfile ); + return 0; + } + + /* + * psfi is NULL normally to query EXE type. If it is NULL, none of the + * below makes sense anyway. Windows allows this and just returns FALSE + */ + if (psfi == NULL) + return FALSE; + + /* + * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES + * is not specified. + * The pidl functions fail on not existing file names + */ + + if (flags & SHGFI_PIDL) + { + pidl = ILClone((LPCITEMIDLIST)path); + } + else if (!(flags & SHGFI_USEFILEATTRIBUTES)) + { + hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes); + } + + if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES)) + { + /* get the parent shellfolder */ + if (pidl) + { + hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, + (LPCITEMIDLIST*)&pidlLast ); + ILFree(pidl); + } + else + { + ERR("pidl is null!\n"); + return FALSE; + } + } + + /* get the attributes of the child */ + if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES)) + { + if (!(flags & SHGFI_ATTR_SPECIFIED)) + { + psfi->dwAttributes = 0xffffffff; + } + IShellFolder_GetAttributesOf( psfParent, 1, (LPCITEMIDLIST*)&pidlLast, + &(psfi->dwAttributes) ); + } + + /* get the displayname */ + if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME)) + { + if (flags & SHGFI_USEFILEATTRIBUTES) + { + lstrcpyW (psfi->szDisplayName, PathFindFileNameW(szFullPath)); + } + else + { + STRRET str; + hr = IShellFolder_GetDisplayNameOf( psfParent, pidlLast, + SHGDN_INFOLDER, &str); + StrRetToStrNW (psfi->szDisplayName, MAX_PATH, &str, pidlLast); + } + } + + /* get the type name */ + if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME)) + { + static const WCHAR szFile[] = { 'F','i','l','e',0 }; + static const WCHAR szDashFile[] = { '-','f','i','l','e',0 }; + + if (!(flags & SHGFI_USEFILEATTRIBUTES)) + { + char ftype[80]; + + _ILGetFileType(pidlLast, ftype, 80); + MultiByteToWideChar(CP_ACP, 0, ftype, -1, psfi->szTypeName, 80 ); + } + else + { + if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + strcatW (psfi->szTypeName, szFile); + else { - if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - strcatW (psfi->szTypeName, szFile); - else + WCHAR sTemp[64]; + + lstrcpyW(sTemp,PathFindExtensionW(szFullPath)); + if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE) && + HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE ))) { - WCHAR sTemp[64]; - lstrcpyW(sTemp,PathFindExtensionW(szFullPath)); - if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE) - && HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE ))) - { - lstrcpynW (psfi->szTypeName, sTemp, 64); - strcatW (psfi->szTypeName, szDashFile); - } + lstrcpynW (psfi->szTypeName, sTemp, 64); + strcatW (psfi->szTypeName, szDashFile); } } } + } - /* ### icons ###*/ - if (flags & SHGFI_LINKOVERLAY) - FIXME("set icon to link, stub\n"); + /* ### icons ###*/ + if (flags & SHGFI_ADDOVERLAYS) + FIXME("SHGFI_ADDOVERLAYS unhandled\n"); - if (flags & SHGFI_SELECTED) - FIXME("set icon to selected, stub\n"); + if (flags & SHGFI_OVERLAYINDEX) + FIXME("SHGFI_OVERLAYINDEX unhandled\n"); - if (flags & SHGFI_SHELLICONSIZE) - FIXME("set icon to shell size, stub\n"); + if (flags & SHGFI_LINKOVERLAY) + FIXME("set icon to link, stub\n"); - /* get the iconlocation */ - if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION )) - { - UINT uDummy,uFlags; - hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, (LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei); + if (flags & SHGFI_SELECTED) + FIXME("set icon to selected, stub\n"); - if (SUCCEEDED(hr)) - { - hr = IExtractIconW_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLocation, MAX_PATH, &iIndex, &uFlags); - psfi->iIcon = iIndex; + if (flags & SHGFI_SHELLICONSIZE) + FIXME("set icon to shell size, stub\n"); - if(uFlags != GIL_NOTFILENAME) - lstrcpyW (psfi->szDisplayName, szLocation); - else - ret = FALSE; + /* get the iconlocation */ + if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION )) + { + UINT uDummy,uFlags; - IExtractIconA_Release(pei); - } - } + hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, + (LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconA, + &uDummy, (LPVOID*)&pei); + if (SUCCEEDED(hr)) + { + hr = IExtractIconW_GetIconLocation(pei, + (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, + szLocation, MAX_PATH, &iIndex, &uFlags); + psfi->iIcon = iIndex; - /* get icon index (or load icon)*/ - if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX))) - { + if (uFlags != GIL_NOTFILENAME) + lstrcpyW (psfi->szDisplayName, szLocation); + else + ret = FALSE; - if (flags & SHGFI_USEFILEATTRIBUTES) - { - WCHAR sTemp [MAX_PATH]; - WCHAR * szExt; - DWORD dwNr=0; + IExtractIconA_Release(pei); + } + } - lstrcpynW(sTemp, szFullPath, MAX_PATH); + /* get icon index (or load icon)*/ + if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX))) + { + if (flags & SHGFI_USEFILEATTRIBUTES) + { + WCHAR sTemp [MAX_PATH]; + WCHAR * szExt; + DWORD dwNr=0; + + lstrcpynW(sTemp, szFullPath, MAX_PATH); if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - psfi->iIcon = 2; + psfi->iIcon = 2; else { - static const WCHAR p1W[] = {'%','1',0}; - psfi->iIcon = 0; - szExt = (LPWSTR) PathFindExtensionW(sTemp); - if ( szExt && HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) - && HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &dwNr)) - { - if (!lstrcmpW(p1W,sTemp)) /* icon is in the file */ - strcpyW(sTemp, szFullPath); + static const WCHAR p1W[] = {'%','1',0}; - if (flags & SHGFI_SYSICONINDEX) - { - psfi->iIcon = SIC_GetIconIndex(sTemp,dwNr); - if (psfi->iIcon == -1) psfi->iIcon = 0; - } - else - { - IconNotYetLoaded=FALSE; - PrivateExtractIconsW(sTemp,dwNr,(flags & SHGFI_SMALLICON) ? - GetSystemMetrics(SM_CXSMICON) : GetSystemMetrics(SM_CXICON), - (flags & SHGFI_SMALLICON) ? GetSystemMetrics(SM_CYSMICON) : - GetSystemMetrics(SM_CYICON), &psfi->hIcon,0,1,0); - psfi->iIcon = dwNr; - } - } + psfi->iIcon = 0; + szExt = (LPWSTR) PathFindExtensionW(sTemp); + if ( szExt && + HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) && + HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &dwNr)) + { + if (!lstrcmpW(p1W,sTemp)) /* icon is in the file */ + strcpyW(sTemp, szFullPath); + + if (flags & SHGFI_SYSICONINDEX) + { + psfi->iIcon = SIC_GetIconIndex(sTemp,dwNr); + if (psfi->iIcon == -1) + psfi->iIcon = 0; + } + else + { + IconNotYetLoaded=FALSE; + if (flags & SHGFI_SMALLICON) + PrivateExtractIconsW( sTemp,dwNr, + GetSystemMetrics( SM_CXSMICON ), + GetSystemMetrics( SM_CYSMICON ), + &psfi->hIcon, 0, 1, 0); + else + PrivateExtractIconsW( sTemp, dwNr, + GetSystemMetrics( SM_CXICON), + GetSystemMetrics( SM_CYICON), + &psfi->hIcon, 0, 1, 0); + psfi->iIcon = dwNr; + } + } } - } - else - { - if (!(PidlToSicIndex(psfParent, pidlLast, !(flags & SHGFI_SMALLICON), - (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon)))) - { - ret = FALSE; - } - } - if (ret) - { - ret = (DWORD) ((flags & SHGFI_SMALLICON) ? ShellSmallIconList : ShellBigIconList); - } - } + } + else + { + if (!(PidlToSicIndex(psfParent, pidlLast, !(flags & SHGFI_SMALLICON), + (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon)))) + { + ret = FALSE; + } + } + if (ret) + { + if (flags & SHGFI_SMALLICON) + ret = (DWORD) ShellSmallIconList; + else + ret = (DWORD) ShellBigIconList; + } + } - /* icon handle */ - if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded) - psfi->hIcon = ImageList_GetIcon((flags & SHGFI_SMALLICON) ? ShellSmallIconList:ShellBigIconList, psfi->iIcon, ILD_NORMAL); + /* icon handle */ + if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded) + { + if (flags & SHGFI_SMALLICON) + psfi->hIcon = ImageList_GetIcon( ShellSmallIconList, psfi->iIcon, ILD_NORMAL); + else + psfi->hIcon = ImageList_GetIcon( ShellBigIconList, psfi->iIcon, ILD_NORMAL); + } - if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3)) - FIXME("unknown attribute!\n"); + if (flags & ~SHGFI_KNOWN_FLAGS) + FIXME("unknown flags %08x\n", flags & ~SHGFI_KNOWN_FLAGS); - if (psfParent) - IShellFolder_Release(psfParent); + if (psfParent) + IShellFolder_Release(psfParent); - if (hr != S_OK) - ret = FALSE; + if (hr != S_OK) + ret = FALSE; + + if (pidlLast) + SHFree(pidlLast); - if(pidlLast) SHFree(pidlLast); #ifdef MORE_DEBUG - TRACE ("icon=%p index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n", - psfi->hIcon, psfi->iIcon, psfi->dwAttributes, debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret); + TRACE ("icon=%p index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n", + psfi->hIcon, psfi->iIcon, psfi->dwAttributes, + debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret); #endif - return ret; + + return ret; } /************************************************************************* - * SHGetFileInfoW [SHELL32.@] + * SHGetFileInfoA [SHELL32.@] */ - DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes, SHFILEINFOA *psfi, UINT sizeofpsfi, UINT flags ) { - INT len; - LPWSTR temppath; - DWORD ret; - SHFILEINFOW temppsfi; + INT len; + LPWSTR temppath; + DWORD ret; + SHFILEINFOW temppsfi; - if (flags & SHGFI_PIDL) { - /* path contains a pidl */ - temppath = (LPWSTR) path; - } else { - len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0); - temppath = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, path, -1, temppath, len); - } + if (flags & SHGFI_PIDL) + { + /* path contains a pidl */ + temppath = (LPWSTR) path; + } + else + { + len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0); + temppath = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, path, -1, temppath, len); + } - if(psfi && (flags & SHGFI_ATTR_SPECIFIED)) - temppsfi.dwAttributes=psfi->dwAttributes; + if (psfi && (flags & SHGFI_ATTR_SPECIFIED)) + temppsfi.dwAttributes=psfi->dwAttributes; - ret = SHGetFileInfoW(temppath, dwFileAttributes, (psfi == NULL)? NULL : &temppsfi, sizeof(temppsfi), flags); + if (psfi == NULL) + ret = SHGetFileInfoW(temppath, dwFileAttributes, NULL, sizeof(temppsfi), flags); + else + ret = SHGetFileInfoW(temppath, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags); - if (psfi) + if (psfi) + { + if(flags & SHGFI_ICON) + psfi->hIcon=temppsfi.hIcon; + if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION)) + psfi->iIcon=temppsfi.iIcon; + if(flags & SHGFI_ATTRIBUTES) + psfi->dwAttributes=temppsfi.dwAttributes; + if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION)) { - if(flags & SHGFI_ICON) - psfi->hIcon=temppsfi.hIcon; - if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION)) - psfi->iIcon=temppsfi.iIcon; - if(flags & SHGFI_ATTRIBUTES) - psfi->dwAttributes=temppsfi.dwAttributes; - if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION)) - WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1, psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL); - if(flags & SHGFI_TYPENAME) - WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1, psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1, + psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL); } - if(!(flags & SHGFI_PIDL)) HeapFree(GetProcessHeap(), 0, temppath); - return ret; + if(flags & SHGFI_TYPENAME) + { + WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1, + psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL); + } + } + + if (!(flags & SHGFI_PIDL)) + HeapFree(GetProcessHeap(), 0, temppath); + + return ret; } /************************************************************************* - * DuplicateIcon [SHELL32.@] + * DuplicateIcon [SHELL32.@] */ HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon) { ICONINFO IconInfo; HICON hDupIcon = 0; - TRACE("(%p, %p)\n", hInstance, hIcon); + TRACE("%p %p\n", hInstance, hIcon); - if(GetIconInfo(hIcon, &IconInfo)) + if (GetIconInfo(hIcon, &IconInfo)) { hDupIcon = CreateIconIndirect(&IconInfo); @@ -565,47 +667,50 @@ HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon) } /************************************************************************* - * ExtractIconA [SHELL32.@] + * ExtractIconA [SHELL32.@] */ HICON WINAPI ExtractIconA(HINSTANCE hInstance, LPCSTR lpszFile, UINT nIconIndex) { - HICON ret; - INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0); - LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + HICON ret; + INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0); + LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - TRACE("%p %s %d\n", hInstance, lpszFile, nIconIndex); + TRACE("%p %s %d\n", hInstance, lpszFile, nIconIndex); - MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len); - ret = ExtractIconW(hInstance, lpwstrFile, nIconIndex); - HeapFree(GetProcessHeap(), 0, lpwstrFile); - return ret; + MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len); + ret = ExtractIconW(hInstance, lpwstrFile, nIconIndex); + HeapFree(GetProcessHeap(), 0, lpwstrFile); + + return ret; } /************************************************************************* - * ExtractIconW [SHELL32.@] + * ExtractIconW [SHELL32.@] */ HICON WINAPI ExtractIconW(HINSTANCE hInstance, LPCWSTR lpszFile, UINT nIconIndex) { - HICON hIcon = NULL; - UINT ret; - UINT cx = GetSystemMetrics(SM_CXICON), cy = GetSystemMetrics(SM_CYICON); + HICON hIcon = NULL; + UINT ret; + UINT cx = GetSystemMetrics(SM_CXICON), cy = GetSystemMetrics(SM_CYICON); - TRACE("%p %s %d\n", hInstance, debugstr_w(lpszFile), nIconIndex); + TRACE("%p %s %d\n", hInstance, debugstr_w(lpszFile), nIconIndex); - if (nIconIndex == 0xFFFFFFFF) { - ret = PrivateExtractIconsW(lpszFile, 0, cx, cy, NULL, NULL, 0, LR_DEFAULTCOLOR); - if (ret != 0xFFFFFFFF && ret) - return (HICON)ret; - return NULL; - } - else - ret = PrivateExtractIconsW(lpszFile, nIconIndex, cx, cy, &hIcon, NULL, 1, LR_DEFAULTCOLOR); + if (nIconIndex == 0xFFFFFFFF) + { + ret = PrivateExtractIconsW(lpszFile, 0, cx, cy, NULL, NULL, 0, LR_DEFAULTCOLOR); + if (ret != 0xFFFFFFFF && ret) + return (HICON)ret; + return NULL; + } + else + ret = PrivateExtractIconsW(lpszFile, nIconIndex, cx, cy, &hIcon, NULL, 1, LR_DEFAULTCOLOR); - if (ret == 0xFFFFFFFF) - return (HICON)1; - else if (ret > 0 && hIcon) - return hIcon; - return NULL; + if (ret == 0xFFFFFFFF) + return (HICON)1; + else if (ret > 0 && hIcon) + return hIcon; + + return NULL; } typedef struct @@ -616,90 +721,103 @@ typedef struct HFONT hFont; } ABOUT_INFO; -#define IDC_STATIC_TEXT1 100 -#define IDC_STATIC_TEXT2 101 -#define IDC_LISTBOX 99 -#define IDC_WINE_TEXT 98 +#define IDC_STATIC_TEXT1 100 +#define IDC_STATIC_TEXT2 101 +#define IDC_LISTBOX 99 +#define IDC_WINE_TEXT 98 -#define DROP_FIELD_TOP (-15) -#define DROP_FIELD_HEIGHT 15 +#define DROP_FIELD_TOP (-15) +#define DROP_FIELD_HEIGHT 15 static BOOL __get_dropline( HWND hWnd, LPRECT lprect ) -{ HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT); +{ + HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT); + if( hWndCtl ) - { GetWindowRect( hWndCtl, lprect ); - MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 ); - lprect->bottom = (lprect->top += DROP_FIELD_TOP); - return TRUE; + { + GetWindowRect( hWndCtl, lprect ); + MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 ); + lprect->bottom = (lprect->top += DROP_FIELD_TOP); + return TRUE; } return FALSE; } /************************************************************************* - * SHAppBarMessage [SHELL32.@] + * SHAppBarMessage [SHELL32.@] */ UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data) { - int width=data->rc.right - data->rc.left; - int height=data->rc.bottom - data->rc.top; - RECT rec=data->rc; - switch (msg) - { case ABM_GETSTATE: - return ABS_ALWAYSONTOP | ABS_AUTOHIDE; - case ABM_GETTASKBARPOS: - GetWindowRect(data->hWnd, &rec); - data->rc=rec; - return TRUE; - case ABM_ACTIVATE: - SetActiveWindow(data->hWnd); - return TRUE; - case ABM_GETAUTOHIDEBAR: - data->hWnd=GetActiveWindow(); - return TRUE; - case ABM_NEW: - SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top, - width,height,SWP_SHOWWINDOW); - return TRUE; - case ABM_QUERYPOS: - GetWindowRect(data->hWnd, &(data->rc)); - return TRUE; - case ABM_REMOVE: - FIXME("ABM_REMOVE broken\n"); - /* FIXME: this is wrong; should it be DestroyWindow instead? */ - /*CloseHandle(data->hWnd);*/ - return TRUE; - case ABM_SETAUTOHIDEBAR: - SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top, - width,height,SWP_SHOWWINDOW); - return TRUE; - case ABM_SETPOS: - data->uEdge=(ABE_RIGHT | ABE_LEFT); - SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top, - width,height,SWP_SHOWWINDOW); - return TRUE; - case ABM_WINDOWPOSCHANGED: - return TRUE; - } - return FALSE; + int width=data->rc.right - data->rc.left; + int height=data->rc.bottom - data->rc.top; + RECT rec=data->rc; + + switch (msg) + { + case ABM_GETSTATE: + return ABS_ALWAYSONTOP | ABS_AUTOHIDE; + case ABM_GETTASKBARPOS: + GetWindowRect(data->hWnd, &rec); + data->rc=rec; + return TRUE; + case ABM_ACTIVATE: + SetActiveWindow(data->hWnd); + return TRUE; + case ABM_GETAUTOHIDEBAR: + data->hWnd=GetActiveWindow(); + return TRUE; + case ABM_NEW: + SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top, + width,height,SWP_SHOWWINDOW); + return TRUE; + case ABM_QUERYPOS: + GetWindowRect(data->hWnd, &(data->rc)); + return TRUE; + case ABM_REMOVE: + FIXME("ABM_REMOVE broken\n"); + /* FIXME: this is wrong; should it be DestroyWindow instead? */ + /*CloseHandle(data->hWnd);*/ + return TRUE; + case ABM_SETAUTOHIDEBAR: + SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top, + width,height,SWP_SHOWWINDOW); + return TRUE; + case ABM_SETPOS: + data->uEdge=(ABE_RIGHT | ABE_LEFT); + SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top, + width,height,SWP_SHOWWINDOW); + return TRUE; + case ABM_WINDOWPOSCHANGED: + return TRUE; + } + return FALSE; } /************************************************************************* - * SHHelpShortcuts_RunDLL [SHELL32.@] + * SHHelpShortcuts_RunDLLA [SHELL32.@] * */ -DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4) -{ FIXME("(%lx, %lx, %lx, %lx) empty stub!\n", - dwArg1, dwArg2, dwArg3, dwArg4); - - return 0; +DWORD WINAPI SHHelpShortcuts_RunDLLA(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4) +{ + FIXME("(%lx, %lx, %lx, %lx) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4); + return 0; } /************************************************************************* - * SHLoadInProc [SHELL32.@] + * SHHelpShortcuts_RunDLLA [SHELL32.@] + * + */ +DWORD WINAPI SHHelpShortcuts_RunDLLW(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4) +{ + FIXME("(%lx, %lx, %lx, %lx) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4); + return 0; +} + +/************************************************************************* + * SHLoadInProc [SHELL32.@] * Create an instance of specified object class from within * the shell process and release it immediately */ - HRESULT WINAPI SHLoadInProc (REFCLSID rclsid) { void *ptr = NULL; @@ -717,7 +835,7 @@ HRESULT WINAPI SHLoadInProc (REFCLSID rclsid) } /************************************************************************* - * AboutDlgProc (internal) + * AboutDlgProc (internal) */ INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) @@ -759,18 +877,20 @@ INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, return 1; case WM_PAINT: - { RECT rect; - PAINTSTRUCT ps; - HDC hDC = BeginPaint( hWnd, &ps ); + { + RECT rect; + PAINTSTRUCT ps; + HDC hDC = BeginPaint( hWnd, &ps ); - if( __get_dropline( hWnd, &rect ) ) { - SelectObject( hDC, GetStockObject( BLACK_PEN ) ); - MoveToEx( hDC, rect.left, rect.top, NULL ); - LineTo( hDC, rect.right, rect.bottom ); - } - EndPaint( hWnd, &ps ); - } - break; + if (__get_dropline( hWnd, &rect )) + { + SelectObject( hDC, GetStockObject( BLACK_PEN ) ); + MoveToEx( hDC, rect.left, rect.top, NULL ); + LineTo( hDC, rect.right, rect.bottom ); + } + EndPaint( hWnd, &ps ); + } + break; case WM_COMMAND: if (wParam == IDOK || wParam == IDCANCEL) @@ -789,7 +909,7 @@ INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, /************************************************************************* - * ShellAboutA [SHELL32.288] + * ShellAboutA [SHELL32.288] */ BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon ) { @@ -819,7 +939,7 @@ BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIc /************************************************************************* - * ShellAboutW [SHELL32.289] + * ShellAboutW [SHELL32.289] */ BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon ) @@ -855,7 +975,8 @@ BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, * FreeIconList (SHELL32.@) */ void WINAPI FreeIconList( DWORD dw ) -{ FIXME("(%lx): stub\n",dw); +{ + FIXME("%lx: stub\n",dw); } @@ -887,7 +1008,7 @@ HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi) { /* FIXME: shouldn't these values come from the version resource? */ if (pdvi->cbSize == sizeof(DLLVERSIONINFO) || - pdvi->cbSize == sizeof(DLLVERSIONINFO2)) + pdvi->cbSize == sizeof(DLLVERSIONINFO2)) { pdvi->dwMajorVersion = WINE_FILEVERSION_MAJOR; pdvi->dwMinorVersion = WINE_FILEVERSION_MINOR; @@ -904,24 +1025,25 @@ HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi) WINE_FILEVERSION_PLATFORMID); } TRACE("%lu.%lu.%lu.%lu\n", - pdvi->dwMajorVersion, pdvi->dwMinorVersion, - pdvi->dwBuildNumber, pdvi->dwPlatformID); + pdvi->dwMajorVersion, pdvi->dwMinorVersion, + pdvi->dwBuildNumber, pdvi->dwPlatformID); return S_OK; } else - { + { WARN("wrong DLLVERSIONINFO size from app\n"); return E_INVALIDARG; } } + /************************************************************************* * global variables of the shell32.dll * all are once per process * */ -HINSTANCE shell32_hInstance = 0; -HIMAGELIST ShellSmallIconList = 0; -HIMAGELIST ShellBigIconList = 0; +HINSTANCE shell32_hInstance = 0; +HIMAGELIST ShellSmallIconList = 0; +HIMAGELIST ShellBigIconList = 0; /************************************************************************* @@ -930,34 +1052,33 @@ HIMAGELIST ShellBigIconList = 0; * NOTES * calling oleinitialize here breaks sone apps. */ - BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) { - TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad); + TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad); - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - shell32_hInstance = hinstDLL; - DisableThreadLibraryCalls(shell32_hInstance); + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + shell32_hInstance = hinstDLL; + DisableThreadLibraryCalls(shell32_hInstance); - /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */ - GetModuleFileNameW(hinstDLL, swShell32Name, MAX_PATH); - swShell32Name[MAX_PATH - 1] = '\0'; + /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */ + GetModuleFileNameW(hinstDLL, swShell32Name, MAX_PATH); + swShell32Name[MAX_PATH - 1] = '\0'; - InitCommonControlsEx(NULL); + InitCommonControlsEx(NULL); - SIC_Initialize(); - InitChangeNotifications(); - break; + SIC_Initialize(); + InitChangeNotifications(); + break; - case DLL_PROCESS_DETACH: - shell32_hInstance = 0; - SIC_Destroy(); - FreeChangeNotifications(); - break; - } - return TRUE; + case DLL_PROCESS_DETACH: + shell32_hInstance = 0; + SIC_Destroy(); + FreeChangeNotifications(); + break; + } + return TRUE; } /************************************************************************* @@ -971,9 +1092,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline) { - FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline)); - - return S_OK; /* indicate success */ + FIXME("%s %s: stub\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline)); + return S_OK; /* indicate success */ } /*********************************************************************** @@ -981,7 +1101,6 @@ HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline) */ HRESULT WINAPI SHELL32_DllCanUnloadNow(void) { - FIXME("(void): stub\n"); - + FIXME("stub\n"); return S_FALSE; } diff --git a/reactos/lib/shell32/shell32_main.h b/reactos/lib/shell32/shell32_main.h index b5ae50c901a..97ba2dc003c 100644 --- a/reactos/lib/shell32/shell32_main.h +++ b/reactos/lib/shell32/shell32_main.h @@ -92,6 +92,7 @@ HRESULT WINAPI ISF_MyComputer_Constructor(IUnknown * pUnkOuter, REFIID riid, LPV HRESULT WINAPI IDropTargetHelper_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv); HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV); HRESULT WINAPI IControlPanel_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv); +HRESULT WINAPI UnixFolder_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv); HRESULT WINAPI CPanel_GetIconLocationA(LPITEMIDLIST pidl, LPSTR szIconFile, UINT cchMax, int* piIndex); HRESULT WINAPI CPanel_GetIconLocationW(LPITEMIDLIST pidl, LPWSTR szIconFile, UINT cchMax, int* piIndex); HRESULT WINAPI CPanel_ExtractIconA(LPITEMIDLIST pidl, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize); @@ -220,6 +221,8 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation, extern WCHAR swShell32Name[MAX_PATH]; +extern const GUID CLSID_UnixFolder; + /* Default shell folder value registration */ HRESULT SHELL_RegisterShellFolders(void); diff --git a/reactos/lib/shell32/shelllink.c b/reactos/lib/shell32/shelllink.c index b7b379f81c5..70f26907f40 100644 --- a/reactos/lib/shell32/shelllink.c +++ b/reactos/lib/shell32/shelllink.c @@ -1,7 +1,8 @@ /* * - * Copyright 1997 Marcus Meissner - * Copyright 1998 Juergen Schmied + * Copyright 1997 Marcus Meissner + * Copyright 1998 Juergen Schmied + * Copyright 2005 Mike McCormack * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,6 +22,14 @@ * Nearly complete informations about the binary formats * of .lnk files available at http://www.wotsit.org * + * You can use winedump to examine the contents of a link file: + * winedump lnk sc.lnk + * + * MSI advertised shortcuts are totally undocumented. They provide an + * icon for a program that is not yet installed, and invoke MSI to + * install the program when the shortcut is clicked on. They are + * created by passing a special string to SetPath, and the information + * in that string is parsed an stored. */ #include "config.h" @@ -58,19 +67,28 @@ #include "shlguid.h" #include "shlwapi.h" +#include "initguid.h" + WINE_DEFAULT_DEBUG_CHANNEL(shell); +DEFINE_GUID( SHELL32_AdvtShortcutProduct, + 0x9db1186f,0x40df,0x11d1,0xaa,0x8c,0x00,0xc0,0x4f,0xb6,0x78,0x63); +DEFINE_GUID( SHELL32_AdvtShortcutComponent, + 0x9db1186e,0x40df,0x11d1,0xaa,0x8c,0x00,0xc0,0x4f,0xb6,0x78,0x63); + /* link file formats */ /* flag1: lnk elements: simple link has 0x0B */ -#define SCF_PIDL 1 -#define SCF_NORMAL 2 +#define SCF_PIDL 1 +#define SCF_LOCATION 2 #define SCF_DESCRIPTION 4 #define SCF_RELATIVE 8 #define SCF_WORKDIR 0x10 #define SCF_ARGS 0x20 #define SCF_CUSTOMICON 0x40 #define SCF_UNICODE 0x80 +#define SCF_PRODUCT 0x800 +#define SCF_COMPONENT 0x1000 #include "pshpack1.h" @@ -113,6 +131,21 @@ typedef struct _LOCAL_VOLUME_INFO DWORD dwVolLabelOfs; } LOCAL_VOLUME_INFO; +typedef struct tagLINK_ADVERTISEINFO +{ + DWORD size; + DWORD magic; + CHAR bufA[MAX_PATH]; + WCHAR bufW[MAX_PATH]; +} LINK_ADVERTISEINFO; + +typedef struct volume_info_t +{ + DWORD type; + DWORD serial; + WCHAR label[12]; /* assume 8.3 */ +} volume_info; + #include "poppack.h" static IShellLinkAVtbl slvt; @@ -146,6 +179,9 @@ typedef struct LPWSTR sWorkDir; LPWSTR sDescription; LPWSTR sPathRel; + LPWSTR sProduct; + LPWSTR sComponent; + volume_info volume; BOOL bDirty; } IShellLinkImpl; @@ -172,7 +208,6 @@ inline static LPWSTR HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str) return p; } - /************************************************************************** * IPersistFile_QueryInterface */ @@ -251,8 +286,9 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFile static BOOL StartLinkProcessor( LPCOLESTR szLink ) { - static const WCHAR szFormat[] = {'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e', - ' ','-','r',' ','"','%','s','"',0 }; + static const WCHAR szFormat[] = { + 'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e', + ' ','-','r',' ','"','%','s','"',0 }; LONG len; LPWSTR buffer; STARTUPINFOW si; @@ -290,7 +326,7 @@ static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFile TRACE("(%p)->(%s)\n",This,debugstr_w(pszFileName)); - if (!pszFileName || !This->sPath) + if (!pszFileName) return E_FAIL; r = CreateStreamOnFile(pszFileName, STGM_READWRITE | STGM_CREATE, &stm); @@ -469,44 +505,175 @@ static HRESULT Stream_LoadString( IStream* stm, BOOL unicode, LPWSTR *pstr ) return S_OK; } -static HRESULT Stream_LoadLocation( IStream* stm ) +static HRESULT Stream_ReadChunk( IStream* stm, LPVOID *data ) { DWORD size; ULONG count; HRESULT r; - LOCATION_INFO *loc; + struct sized_chunk { + DWORD size; + unsigned char data[1]; + } *chunk; TRACE("%p\n",stm); r = IStream_Read( stm, &size, sizeof(size), &count ); - if( FAILED( r ) ) - return r; - if( count != sizeof(loc->dwTotalSize) ) + if( FAILED( r ) || count != sizeof(size) ) return E_FAIL; - loc = HeapAlloc( GetProcessHeap(), 0, size ); - if( ! loc ) + chunk = HeapAlloc( GetProcessHeap(), 0, size ); + if( !chunk ) return E_OUTOFMEMORY; - r = IStream_Read( stm, &loc->dwHeaderSize, size-sizeof(size), &count ); - if( FAILED( r ) ) - goto end; - if( count != (size - sizeof(size)) ) + chunk->size = size; + r = IStream_Read( stm, chunk->data, size - sizeof(size), &count ); + if( FAILED( r ) || count != (size - sizeof(size)) ) { - r = E_FAIL; - goto end; + HeapFree( GetProcessHeap(), 0, chunk ); + return E_FAIL; } - loc->dwTotalSize = size; - TRACE("Read %ld bytes\n",count); + TRACE("Read %ld bytes\n",chunk->size); - /* FIXME: do something useful with it */ - HeapFree( GetProcessHeap(), 0, loc ); + *data = (LPVOID) chunk; + + return S_OK; +} + +static BOOL Stream_LoadVolume( LOCAL_VOLUME_INFO *vol, volume_info *volume ) +{ + const int label_sz = sizeof volume->label/sizeof volume->label[0]; + LPSTR label; + int len; + + volume->serial = vol->dwVolSerial; + volume->type = vol->dwType; + + if( !vol->dwVolLabelOfs ) + return FALSE; + if( vol->dwSize <= vol->dwVolLabelOfs ) + return FALSE; + len = vol->dwSize - vol->dwVolLabelOfs; + + label = (LPSTR) vol; + label += vol->dwVolLabelOfs; + MultiByteToWideChar( CP_ACP, 0, label, len, volume->label, label_sz-1); + + return TRUE; +} + +static LPWSTR Stream_LoadPath( LPSTR p, DWORD maxlen ) +{ + int len = 0, wlen; + LPWSTR path; + + while( p[len] && (len < maxlen) ) + len++; + + wlen = MultiByteToWideChar(CP_ACP, 0, p, len, NULL, 0); + path = HeapAlloc(GetProcessHeap(), 0, (wlen+1)*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, p, len, path, wlen); + path[wlen] = 0; + + return path; +} + +static HRESULT Stream_LoadLocation( IStream *stm, + volume_info *volume, LPWSTR *path ) +{ + unsigned char *p = NULL; + LOCATION_INFO *loc; + HRESULT r; + int n; + + r = Stream_ReadChunk( stm, (LPVOID*) &p ); + if( FAILED(r) ) + return r; + + loc = (LOCATION_INFO*) p; + if (loc->dwTotalSize < sizeof(LOCATION_INFO) - sizeof(DWORD)) + { + HeapFree( GetProcessHeap(), 0, p ); + return E_FAIL; + } + + /* if there's valid local volume information, load it */ + if( loc->dwVolTableOfs && + ((loc->dwVolTableOfs + sizeof(LOCAL_VOLUME_INFO)) <= loc->dwTotalSize) ) + { + LOCAL_VOLUME_INFO *volume_info; + + volume_info = (LOCAL_VOLUME_INFO*) &p[loc->dwVolTableOfs]; + Stream_LoadVolume( volume_info, volume ); + } + + /* if there's a local path, load it */ + n = loc->dwLocalPathOfs; + if( n && (n < loc->dwTotalSize) ) + *path = Stream_LoadPath( &p[n], loc->dwTotalSize - n ); + + TRACE("type %ld serial %08lx name %s path %s\n", volume->type, + volume->serial, debugstr_w(volume->label), debugstr_w(*path)); + + HeapFree( GetProcessHeap(), 0, p ); + return S_OK; +} + +/* + * The format of the advertised shortcut info seems to be: + * + * Offset Description + * ------ ----------- + * + * 0 Length of the block (4 bytes, usually 0x314) + * 4 tag (dword) + * 8 string data in ASCII + * 8+0x104 string data in UNICODE + * + * In the original Win32 implementation the buffers are not initialized + * to zero, so data trailing the string is random garbage. + */ +static HRESULT Stream_LoadAdvertiseInfo( IStream* stm, LPWSTR *str ) +{ + DWORD size; + ULONG count; + HRESULT r; + LINK_ADVERTISEINFO buffer; + + TRACE("%p\n",stm); + + r = IStream_Read( stm, &buffer.size, sizeof (DWORD), &count ); + if( FAILED( r ) ) + return r; + + /* make sure that we read the size of the structure even on error */ + size = sizeof buffer - sizeof (DWORD); + if( buffer.size != sizeof buffer ) + { + ERR("Ooops. This structure is not as expected...\n"); + return E_FAIL; + } + + r = IStream_Read( stm, &buffer.magic, size, &count ); + if( FAILED( r ) ) + return r; + + if( count != size ) + return E_FAIL; + + TRACE("magic %08lx string = %s\n", buffer.magic, debugstr_w(buffer.bufW)); + + if( (buffer.magic&0xffff0000) != 0xa0000000 ) + { + ERR("Unknown magic number %08lx in advertised shortcut\n", buffer.magic); + return E_FAIL; + } + + *str = HeapAlloc( GetProcessHeap(), 0, + (strlenW(buffer.bufW)+1) * sizeof(WCHAR) ); + strcpyW( *str, buffer.bufW ); return S_OK; -end: - HeapFree( GetProcessHeap(), 0, loc ); - return r; } /************************************************************************ @@ -519,12 +686,12 @@ static HRESULT WINAPI IPersistStream_fnLoad( LINK_HEADER hdr; ULONG dwBytesRead; BOOL unicode; - WCHAR sTemp[MAX_PATH]; HRESULT r; + DWORD zero; _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface); - TRACE("(%p)(%p)\n", This, stm); + TRACE("%p %p\n", This, stm); if( !stm ) return STG_E_INVALIDPOINTER; @@ -541,30 +708,61 @@ static HRESULT WINAPI IPersistStream_fnLoad( if( !IsEqualIID(&hdr.MagicGuid, &CLSID_ShellLink) ) return E_FAIL; - /* if( hdr.dwFlags & SCF_PIDL ) */ /* FIXME: seems to always have a PIDL */ - { - r = ILLoadFromStream( stm, &This->pPidl ); - if( FAILED( r ) ) - return r; - } + /* free all the old stuff */ + ILFree(This->pPidl); + This->pPidl = NULL; + memset( &This->volume, 0, sizeof This->volume ); + HeapFree(GetProcessHeap(), 0, This->sPath); + This->sPath = NULL; + HeapFree(GetProcessHeap(), 0, This->sDescription); + This->sDescription = NULL; + HeapFree(GetProcessHeap(), 0, This->sPathRel); + This->sPathRel = NULL; + HeapFree(GetProcessHeap(), 0, This->sWorkDir); + This->sWorkDir = NULL; + HeapFree(GetProcessHeap(), 0, This->sArgs); + This->sArgs = NULL; + HeapFree(GetProcessHeap(), 0, This->sIcoPath); + This->sIcoPath = NULL; + HeapFree(GetProcessHeap(), 0, This->sProduct); + This->sProduct = NULL; + HeapFree(GetProcessHeap(), 0, This->sComponent); + This->sComponent = NULL; + This->wHotKey = (WORD)hdr.wHotKey; This->iIcoNdx = hdr.nIcon; FileTimeToSystemTime (&hdr.Time1, &This->time1); FileTimeToSystemTime (&hdr.Time2, &This->time2); FileTimeToSystemTime (&hdr.Time3, &This->time3); -#if 1 - GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time1, NULL, sTemp, 256); - TRACE("-- time1: %s\n", debugstr_w(sTemp) ); - GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time2, NULL, sTemp, 256); - TRACE("-- time1: %s\n", debugstr_w(sTemp) ); - GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time3, NULL, sTemp, 256); - TRACE("-- time1: %s\n", debugstr_w(sTemp) ); - pdump (This->pPidl); -#endif - if( hdr.dwFlags & SCF_NORMAL ) - r = Stream_LoadLocation( stm ); + if (TRACE_ON(shell)) + { + WCHAR sTemp[MAX_PATH]; + GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE, &This->time1, + NULL, sTemp, sizeof(sTemp)/sizeof(*sTemp)); + TRACE("-- time1: %s\n", debugstr_w(sTemp) ); + GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE, &This->time2, + NULL, sTemp, sizeof(sTemp)/sizeof(*sTemp)); + TRACE("-- time2: %s\n", debugstr_w(sTemp) ); + GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE, &This->time3, + NULL, sTemp, sizeof(sTemp)/sizeof(*sTemp)); + TRACE("-- time3: %s\n", debugstr_w(sTemp) ); + } + + /* load all the new stuff */ + if( hdr.dwFlags & SCF_PIDL ) + { + r = ILLoadFromStream( stm, &This->pPidl ); + if( FAILED( r ) ) + return r; + } + pdump(This->pPidl); + + /* load the location information */ + if( hdr.dwFlags & SCF_LOCATION ) + r = Stream_LoadLocation( stm, &This->volume, &This->sPath ); if( FAILED( r ) ) goto end; + unicode = hdr.dwFlags & SCF_UNICODE; if( hdr.dwFlags & SCF_DESCRIPTION ) { @@ -583,7 +781,7 @@ static HRESULT WINAPI IPersistStream_fnLoad( goto end; if( hdr.dwFlags & SCF_WORKDIR ) - { + { r = Stream_LoadString( stm, unicode, &This->sWorkDir ); TRACE("Working Dir -> %s\n",debugstr_w(This->sWorkDir)); } @@ -606,6 +804,26 @@ static HRESULT WINAPI IPersistStream_fnLoad( if( FAILED( r ) ) goto end; + if( hdr.dwFlags & SCF_PRODUCT ) + { + r = Stream_LoadAdvertiseInfo( stm, &This->sProduct ); + TRACE("Product -> %s\n",debugstr_w(This->sProduct)); + } + if( FAILED( r ) ) + goto end; + + if( hdr.dwFlags & SCF_COMPONENT ) + { + r = Stream_LoadAdvertiseInfo( stm, &This->sComponent ); + TRACE("Component -> %s\n",debugstr_w(This->sComponent)); + } + if( FAILED( r ) ) + goto end; + + r = IStream_Read(stm, &zero, sizeof zero, &dwBytesRead); + if( FAILED( r ) || zero || dwBytesRead != sizeof zero ) + ERR("Last word was not zero\n"); + TRACE("OK\n"); pdump (This->pPidl); @@ -640,19 +858,81 @@ static HRESULT Stream_WriteString( IStream* stm, LPCWSTR str ) return S_OK; } -static HRESULT Stream_WriteLocationInfo( IStream* stm, LPCWSTR filename ) +/************************************************************************ + * Stream_WriteLocationInfo + * + * Writes the location info to a stream + * + * FIXME: One day we might want to write the network volume information + * and the final path. + * Figure out how Windows deals with unicode paths here. + */ +static HRESULT Stream_WriteLocationInfo( IStream* stm, LPCWSTR path, + volume_info *volume ) +{ + DWORD total_size, path_size, volume_info_size, label_size, final_path_size; + LOCAL_VOLUME_INFO *vol; + LOCATION_INFO *loc; + LPSTR szLabel, szPath, szFinalPath; + ULONG count = 0; + + TRACE("%p %s %p\n", stm, debugstr_w(path), volume); + + /* figure out the size of everything */ + label_size = WideCharToMultiByte( CP_ACP, 0, volume->label, -1, + NULL, 0, NULL, NULL ); + path_size = WideCharToMultiByte( CP_ACP, 0, path, -1, + NULL, 0, NULL, NULL ); + volume_info_size = sizeof *vol + label_size; + final_path_size = 1; + total_size = sizeof *loc + volume_info_size + path_size + final_path_size; + + /* create pointers to everything */ + loc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, total_size); + vol = (LOCAL_VOLUME_INFO*) &loc[1]; + szLabel = (LPSTR) &vol[1]; + szPath = &szLabel[label_size]; + szFinalPath = &szPath[path_size]; + + /* fill in the location information header */ + loc->dwTotalSize = total_size; + loc->dwHeaderSize = sizeof (*loc); + loc->dwFlags = 1; + loc->dwVolTableOfs = sizeof (*loc); + loc->dwLocalPathOfs = sizeof (*loc) + volume_info_size; + loc->dwNetworkVolTableOfs = 0; + loc->dwFinalPathOfs = sizeof (*loc) + volume_info_size + path_size; + + /* fill in the volume information */ + vol->dwSize = volume_info_size; + vol->dwType = volume->type; + vol->dwVolSerial = volume->serial; + vol->dwVolLabelOfs = sizeof (*vol); + + /* copy in the strings */ + WideCharToMultiByte( CP_ACP, 0, volume->label, -1, + szLabel, label_size, NULL, NULL ); + WideCharToMultiByte( CP_ACP, 0, path, -1, + szPath, path_size, NULL, NULL ); + szFinalPath[0] = 0; + + return IStream_Write( stm, loc, total_size, &count ); +} + +static HRESULT Stream_WriteAdvertiseInfo( IStream* stm, LPCWSTR string, DWORD magic ) { - LOCATION_INFO loc; ULONG count; + LINK_ADVERTISEINFO buffer; + + TRACE("%p\n",stm); - FIXME("writing empty location info\n"); + memset( &buffer, 0, sizeof buffer ); + buffer.size = sizeof buffer; + buffer.magic = magic; + strncpyW( buffer.bufW, string, MAX_PATH ); + WideCharToMultiByte(CP_ACP, 0, string, -1, buffer.bufA, MAX_PATH, NULL, NULL ); - memset( &loc, 0, sizeof(loc) ); - loc.dwTotalSize = sizeof(loc) - sizeof(loc.dwTotalSize); - - /* FIXME: fill this in */ - - return IStream_Write( stm, &loc, loc.dwTotalSize, &count ); + return IStream_Write( stm, &buffer, buffer.size, &count ); } /************************************************************************ @@ -670,38 +950,39 @@ static HRESULT WINAPI IPersistStream_fnSave( LINK_HEADER header; WCHAR exePath[MAX_PATH]; ULONG count; + DWORD zero; HRESULT r; _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface); - TRACE("(%p) %p %x\n", This, stm, fClearDirty); + TRACE("%p %p %x\n", This, stm, fClearDirty); *exePath = '\0'; if (This->sPath) { - SHELL_FindExecutable(NULL, This->sPath, wOpen, exePath, MAX_PATH, NULL, NULL, NULL, NULL); + SHELL_FindExecutable(NULL, This->sPath, wOpen, exePath, MAX_PATH, + NULL, NULL, NULL, NULL); /* * windows can create lnk files to executables that do not exist yet * so if the executable does not exist the just trust the path they * gave us */ - if( !*exePath ) strcpyW(exePath,This->sPath); + if (!*exePath) strcpyW(exePath,This->sPath); } - /* if there's no PIDL, generate one */ - if( ! This->pPidl ) This->pPidl = ILCreateFromPathW(exePath); - memset(&header, 0, sizeof(header)); header.dwSize = sizeof(header); + header.fStartup = This->iShowCmd; memcpy(&header.MagicGuid, &CLSID_ShellLink, sizeof(header.MagicGuid) ); header.wHotKey = This->wHotKey; header.nIcon = This->iIcoNdx; header.dwFlags = SCF_UNICODE; /* strings are in unicode */ - header.dwFlags |= SCF_NORMAL; /* how do we determine this ? */ if( This->pPidl ) header.dwFlags |= SCF_PIDL; + if( This->sPath ) + header.dwFlags |= SCF_LOCATION; if( This->sDescription ) header.dwFlags |= SCF_DESCRIPTION; if( This->sWorkDir ) @@ -710,6 +991,10 @@ static HRESULT WINAPI IPersistStream_fnSave( header.dwFlags |= SCF_ARGS; if( This->sIcoPath ) header.dwFlags |= SCF_CUSTOMICON; + if( This->sProduct ) + header.dwFlags |= SCF_PRODUCT; + if( This->sComponent ) + header.dwFlags |= SCF_COMPONENT; SystemTimeToFileTime ( &This->time1, &header.Time1 ); SystemTimeToFileTime ( &This->time2, &header.Time2 ); @@ -736,9 +1021,9 @@ static HRESULT WINAPI IPersistStream_fnSave( } } - Stream_WriteLocationInfo( stm, exePath ); + if( This->sPath ) + Stream_WriteLocationInfo( stm, exePath, &This->volume ); - TRACE("Description = %s\n", debugstr_w(This->sDescription)); if( This->sDescription ) r = Stream_WriteString( stm, This->sDescription ); @@ -754,6 +1039,16 @@ static HRESULT WINAPI IPersistStream_fnSave( if( This->sIcoPath ) r = Stream_WriteString( stm, This->sIcoPath ); + if( This->sProduct ) + r = Stream_WriteAdvertiseInfo( stm, This->sProduct, 0xa0000007 ); + + if( This->sComponent ) + r = Stream_WriteAdvertiseInfo( stm, This->sComponent, 0xa0000006 ); + + /* the last field is a single zero dword */ + zero = 0; + r = IStream_Write( stm, &zero, sizeof zero, &count ); + return S_OK; } @@ -828,13 +1123,9 @@ HRESULT WINAPI IShellLink_Constructor ( static BOOL SHELL_ExistsFileW(LPCWSTR path) { - HANDLE hfile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); - - if (hfile != INVALID_HANDLE_VALUE) { - CloseHandle(hfile); - return TRUE; - } else + if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW(path)) return FALSE; + return TRUE; } /************************************************************************** @@ -1017,7 +1308,10 @@ static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA * iface, LPSTR pszFile, TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)(%s)\n", This, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(This->sPath)); - if( cchMaxPath ) + if (This->sComponent || This->sProduct) + return S_FALSE; + + if (cchMaxPath) pszFile[0] = 0; if (This->sPath) WideCharToMultiByte( CP_ACP, 0, This->sPath, -1, @@ -1025,18 +1319,16 @@ static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA * iface, LPSTR pszFile, if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This); - return NOERROR; + return S_OK; } static HRESULT WINAPI IShellLinkA_fnGetIDList(IShellLinkA * iface, LPITEMIDLIST * ppidl) { - IShellLinkImpl *This = (IShellLinkImpl *)iface; + IShellLinkImpl *This = (IShellLinkImpl *)iface; - TRACE("(%p)->(ppidl=%p)\n",This, ppidl); + TRACE("(%p)->(ppidl=%p)\n",This, ppidl); - *ppidl = ILClone(This->pPidl); - - return NOERROR; + return IShellLinkW_GetIDList((IShellLinkW*)&(This->lpvtblw), ppidl); } static HRESULT WINAPI IShellLinkA_fnSetIDList(IShellLinkA * iface, LPCITEMIDLIST pidl) @@ -1218,21 +1510,23 @@ static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR p TRACE("(%p)->(%p len=%u iicon=%p)\n", This, pszIconPath, cchIconPath, piIcon); - if (cchIconPath) - pszIconPath[0] = 0; + pszIconPath[0] = 0; + *piIcon = This->iIcoNdx; - if (This->sIcoPath) { + if (This->sIcoPath) + { WideCharToMultiByte(CP_ACP, 0, This->sIcoPath, -1, pszIconPath, cchIconPath, NULL, NULL); - *piIcon = This->iIcoNdx; return S_OK; } - if (This->pPidl || This->sPath) { + if (This->pPidl || This->sPath) + { IShellFolder* pdsk; HRESULT hr = SHGetDesktopFolder(&pdsk); - if (SUCCEEDED(hr)) { + if (SUCCEEDED(hr)) + { /* first look for an icon using the PIDL (if present) */ if (This->pPidl) hr = SHELL_PidlGeticonLocationA(pdsk, This->pPidl, pszIconPath, cchIconPath, piIcon); @@ -1240,7 +1534,8 @@ static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR p hr = E_FAIL; /* if we couldn't find an icon yet, look for it using the file system path */ - if (FAILED(hr) && This->sPath) { + if (FAILED(hr) && This->sPath) + { LPITEMIDLIST pidl; hr = IShellFolder_ParseDisplayName(pdsk, 0, NULL, This->sPath, NULL, &pidl, NULL); @@ -1256,8 +1551,8 @@ static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR p } return hr; - } else - return E_FAIL; + } + return S_OK; } static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA * iface, LPCSTR pszIconPath,INT iIcon) @@ -1281,7 +1576,7 @@ static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA * iface, LPCSTR { IShellLinkImpl *This = (IShellLinkImpl *)iface; - FIXME("(%p)->(path=%s %lx)\n",This, pszPathRel, dwReserved); + TRACE("(%p)->(path=%s %lx)\n",This, pszPathRel, dwReserved); HeapFree(GetProcessHeap(), 0, This->sPathRel); This->sPathRel = HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel); @@ -1296,7 +1591,7 @@ static HRESULT WINAPI IShellLinkA_fnResolve(IShellLinkA * iface, HWND hwnd, DWOR IShellLinkImpl *This = (IShellLinkImpl *)iface; - FIXME("(%p)->(hwnd=%p flags=%lx)\n",This, hwnd, fFlags); + TRACE("(%p)->(hwnd=%p flags=%lx)\n",This, hwnd, fFlags); /*FIXME: use IResolveShellLink interface */ @@ -1333,23 +1628,20 @@ static HRESULT WINAPI IShellLinkA_fnResolve(IShellLinkA * iface, HWND hwnd, DWOR static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA * iface, LPCSTR pszFile) { + HRESULT r; + LPWSTR str; IShellLinkImpl *This = (IShellLinkImpl *)iface; - char buffer[MAX_PATH]; - LPSTR fname; TRACE("(%p)->(path=%s)\n",This, pszFile); - if (!GetFullPathNameA(pszFile, MAX_PATH, buffer, &fname)) - return E_FAIL; - - HeapFree(GetProcessHeap(), 0, This->sPath); - This->sPath = HEAP_strdupAtoW(GetProcessHeap(), 0, buffer); - if( !This->sPath ) + str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile); + if( !str ) return E_OUTOFMEMORY; - This->bDirty = TRUE; + r = IShellLinkW_SetPath((IShellLinkW*)&(This->lpvtblw), str); + HeapFree( GetProcessHeap(), 0, str ); - return S_OK; + return r; } /************************************************************************** @@ -1421,17 +1713,20 @@ static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile, { _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface); - TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n", - This, pszFile, cchMaxPath, pfd, fFlags); + TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)(%s)\n", + This, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(This->sPath)); - if( cchMaxPath ) + if (This->sComponent || This->sProduct) + return S_FALSE; + + if (cchMaxPath) pszFile[0] = 0; - if( This->sPath ) + if (This->sPath) lstrcpynW( pszFile, This->sPath, cchMaxPath ); if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This); - return NOERROR; + return S_OK; } static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST * ppidl) @@ -1440,11 +1735,9 @@ static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST TRACE("(%p)->(ppidl=%p)\n",This, ppidl); - if( This->pPidl) - *ppidl = ILClone( This->pPidl ); - else - *ppidl = NULL; - + if (!This->pPidl) + return S_FALSE; + *ppidl = ILClone(This->pPidl); return S_OK; } @@ -1471,8 +1764,7 @@ static HRESULT WINAPI IShellLinkW_fnGetDescription(IShellLinkW * iface, LPWSTR p TRACE("(%p)->(%p len=%u)\n",This, pszName, cchMaxName); - if( cchMaxName ) - pszName[0] = 0; + pszName[0] = 0; if( This->sDescription ) lstrcpynW( pszName, This->sDescription, cchMaxName ); @@ -1632,21 +1924,23 @@ static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR TRACE("(%p)->(%p len=%u iicon=%p)\n", This, pszIconPath, cchIconPath, piIcon); - if (cchIconPath) - pszIconPath[0] = 0; + pszIconPath[0] = 0; + *piIcon = This->iIcoNdx; - if (This->sIcoPath) { + if (This->sIcoPath) + { lstrcpynW(pszIconPath, This->sIcoPath, cchIconPath); - *piIcon = This->iIcoNdx; return S_OK; } - if (This->pPidl || This->sPath) { + if (This->pPidl || This->sPath) + { IShellFolder* pdsk; HRESULT hr = SHGetDesktopFolder(&pdsk); - if (SUCCEEDED(hr)) { + if (SUCCEEDED(hr)) + { /* first look for an icon using the PIDL (if present) */ if (This->pPidl) hr = SHELL_PidlGeticonLocationW(pdsk, This->pPidl, pszIconPath, cchIconPath, piIcon); @@ -1654,12 +1948,14 @@ static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR hr = E_FAIL; /* if we couldn't find an icon yet, look for it using the file system path */ - if (FAILED(hr) && This->sPath) { + if (FAILED(hr) && This->sPath) + { LPITEMIDLIST pidl; hr = IShellFolder_ParseDisplayName(pdsk, 0, NULL, This->sPath, NULL, &pidl, NULL); - if (SUCCEEDED(hr)) { + if (SUCCEEDED(hr)) + { hr = SHELL_PidlGeticonLocationW(pdsk, pidl, pszIconPath, cchIconPath, piIcon); SHFree(pidl); @@ -1668,10 +1964,9 @@ static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR IShellFolder_Release(pdsk); } - return hr; - } else - return E_FAIL; + } + return S_OK; } static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath,INT iIcon) @@ -1716,7 +2011,7 @@ static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWOR _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface); - FIXME("(%p)->(hwnd=%p flags=%lx)\n",This, hwnd, fFlags); + TRACE("(%p)->(hwnd=%p flags=%lx)\n",This, hwnd, fFlags); /*FIXME: use IResolveShellLink interface */ @@ -1751,27 +2046,141 @@ static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWOR return hr; } +static LPWSTR ShellLink_GetAdvertisedArg(LPCWSTR str) +{ + LPWSTR ret; + LPCWSTR p; + DWORD len; + + p = strchrW( str, ':' ); + if( !p ) + return NULL; + len = p - str; + ret = HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR)*(len+1)); + if( !ret ) + return ret; + memcpy( ret, str, sizeof(WCHAR)*len ); + ret[len] = 0; + return ret; +} + +static HRESULT ShellLink_SetAdvertiseInfo(IShellLinkImpl *This, LPCWSTR str) +{ + LPCWSTR szComponent = NULL, szProduct = NULL, p; + WCHAR szGuid[39]; + HRESULT r; + GUID guid; + int len; + + while( str[0] ) + { + /* each segment must start with two colons */ + if( str[0] != ':' || str[1] != ':' ) + return E_FAIL; + + /* the last segment is just two colons */ + if( !str[2] ) + break; + str += 2; + + /* there must be a colon straight after a guid */ + p = strchrW( str, ':' ); + if( !p ) + return E_FAIL; + len = p - str; + if( len != 38 ) + return E_FAIL; + + /* get the guid, and check it's validly formatted */ + memcpy( szGuid, str, sizeof(WCHAR)*len ); + szGuid[len] = 0; + r = CLSIDFromString( szGuid, &guid ); + if( r != S_OK ) + return r; + str = p + 1; + + /* match it up to a guid that we care about */ + if( IsEqualGUID( &guid, &SHELL32_AdvtShortcutComponent ) && !szComponent ) + szComponent = str; + else if( IsEqualGUID( &guid, &SHELL32_AdvtShortcutProduct ) && !szProduct ) + szProduct = str; + else + return E_FAIL; + + /* skip to the next field */ + str = strchrW( str, ':' ); + if( !str ) + return E_FAIL; + } + + /* we have to have at least one of these two for an advertised shortcut */ + if( !szComponent && !szProduct ) + return E_FAIL; + + This->sComponent = ShellLink_GetAdvertisedArg( szComponent ); + This->sProduct = ShellLink_GetAdvertisedArg( szProduct ); + + TRACE("Component = %s\n", debugstr_w(This->sComponent)); + TRACE("Product = %s\n", debugstr_w(This->sProduct)); + + return S_OK; +} + +static BOOL ShellLink_GetVolumeInfo(LPWSTR path, volume_info *volume) +{ + const int label_sz = sizeof volume->label/sizeof volume->label[0]; + WCHAR drive[4] = { path[0], ':', '\\', 0 }; + BOOL r; + + volume->type = GetDriveTypeW(drive); + r = GetVolumeInformationW(drive, volume->label, label_sz, + &volume->serial, NULL, NULL, NULL, 0); + TRACE("r = %d type %ld serial %08lx name %s\n", r, + volume->type, volume->serial, debugstr_w(volume->label)); + return r; +} + static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile) { _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface); WCHAR buffer[MAX_PATH]; LPWSTR fname; + HRESULT hr = S_OK; TRACE("(%p)->(path=%s)\n",This, debugstr_w(pszFile)); - if (!GetFullPathNameW(pszFile, MAX_PATH, buffer, &fname)) - return E_FAIL; - HeapFree(GetProcessHeap(), 0, This->sPath); - This->sPath = HeapAlloc( GetProcessHeap(), 0, - (lstrlenW( buffer )+1) * sizeof (WCHAR) ); - if (!This->sPath) - return E_OUTOFMEMORY; + This->sPath = NULL; - lstrcpyW(This->sPath, buffer); + HeapFree(GetProcessHeap(), 0, This->sComponent); + This->sComponent = NULL; + + if (This->pPidl) + ILFree(This->pPidl); + This->pPidl = NULL; + + if (S_OK != ShellLink_SetAdvertiseInfo( This, pszFile )) + { + if (*pszFile == '\0') + *buffer = '\0'; + else if (!GetFullPathNameW(pszFile, MAX_PATH, buffer, &fname)) + return E_FAIL; + else if(!PathFileExistsW(buffer)) + hr = S_FALSE; + + This->pPidl = SHSimpleIDListFromPathW(pszFile); + ShellLink_GetVolumeInfo(buffer, &This->volume); + + This->sPath = HeapAlloc( GetProcessHeap(), 0, + (lstrlenW( buffer )+1) * sizeof (WCHAR) ); + if (!This->sPath) + return E_OUTOFMEMORY; + + lstrcpyW(This->sPath, buffer); + } This->bDirty = TRUE; - return S_OK; + return hr; } /************************************************************************** diff --git a/reactos/lib/shell32/shellpath.c b/reactos/lib/shell32/shellpath.c index 718bfc216e6..590b48b0a16 100644 --- a/reactos/lib/shell32/shellpath.c +++ b/reactos/lib/shell32/shellpath.c @@ -365,7 +365,7 @@ static BOOL PathIsExeA (LPCSTR lpszPath) TRACE("path=%s\n",lpszPath); for(i=0; lpszExtensions[i]; i++) - if (!strcasecmp(lpszExtension,lpszExtensions[i])) return TRUE; + if (!lstrcmpiA(lpszExtension,lpszExtensions[i])) return TRUE; return FALSE; } @@ -1267,7 +1267,7 @@ static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath) } else { - FIXME("LoadString failed, missing translation?\n"); + FIXME("(%d,%s), LoadString failed, missing translation?\n", folder, debugstr_w(pszPath)); hr = E_FAIL; } } diff --git a/reactos/lib/shell32/shfldr.h b/reactos/lib/shell32/shfldr.h index 5666f0d7cc3..bc35caf02e6 100644 --- a/reactos/lib/shell32/shfldr.h +++ b/reactos/lib/shell32/shfldr.h @@ -46,6 +46,7 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot, LPCSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut); HRESULT SHELL32_CompareIDs (IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2); +LPITEMIDLIST SHELL32_CreatePidlFromBindCtx(IBindCtx *pbc, LPCWSTR path); static inline int SHELL32_GUIDToStringA (REFGUID guid, LPSTR str) { @@ -55,4 +56,17 @@ static inline int SHELL32_GUIDToStringA (REFGUID guid, LPSTR str) guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]); } +static inline int SHELL32_GUIDToStringW (REFGUID guid, LPWSTR str) +{ + static const WCHAR fmtW[] = + { '{','%','0','8','l','x','-','%','0','4','x','-','%','0','4','x','-', + '%','0','2','x','%','0','2','x','-', + '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x', + '%','0','2','x','%','0','2','x','}',0 }; + return sprintfW(str, fmtW, + guid->Data1, guid->Data2, guid->Data3, + guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], + guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]); +} + void SHELL_FS_ProcessDisplayFilename(LPSTR szPath, DWORD dwFlags); diff --git a/reactos/lib/shell32/shfldr_desktop.c b/reactos/lib/shell32/shfldr_desktop.c index 4ea04ef8d48..5e8b13d696d 100644 --- a/reactos/lib/shell32/shfldr_desktop.c +++ b/reactos/lib/shell32/shfldr_desktop.c @@ -1,9 +1,9 @@ /* - * Virtual Desktop Folder + * Virtual Desktop Folder * - * Copyright 1997 Marcus Meissner - * Copyright 1998, 1999, 2002 Juergen Schmied + * Copyright 1997 Marcus Meissner + * Copyright 1998, 1999, 2002 Juergen Schmied * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -56,7 +56,7 @@ WINE_DEFAULT_DEBUG_CHANNEL (shell); /*********************************************************************** -* Desktopfolder implementation +* Desktopfolder implementation */ typedef struct { @@ -66,17 +66,17 @@ typedef struct { CLSID *pclsid; /* both paths are parsible from the desktop */ - LPSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */ - LPITEMIDLIST pidlRoot; /* absolute pidl */ + LPSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */ + LPITEMIDLIST pidlRoot; /* absolute pidl */ - int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */ + int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */ - UINT cfShellIDList; /* clipboardformat for IDropTarget */ - BOOL fAcceptFmt; /* flag for pending Drop */ + UINT cfShellIDList; /* clipboardformat for IDropTarget */ + BOOL fAcceptFmt; /* flag for pending Drop */ } IGenericSFImpl; -#define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl) -#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) +#define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl) +#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) static struct IShellFolder2Vtbl vt_MCFldr_ShellFolder2; @@ -91,9 +91,10 @@ static shvheader DesktopSFHeader[] = { #define DESKTOPSHELLVIEWCOLUMNS 5 /************************************************************************** -* ISF_Desktop_Constructor -*/ -HRESULT WINAPI ISF_Desktop_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) + * ISF_Desktop_Constructor + */ +HRESULT WINAPI ISF_Desktop_Constructor ( + IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) { IGenericSFImpl *sf; char szMyPath[MAX_PATH]; @@ -101,26 +102,27 @@ HRESULT WINAPI ISF_Desktop_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOI TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); if (!ppv) - return E_POINTER; + return E_POINTER; if (pUnkOuter) - return CLASS_E_NOAGGREGATION; + return CLASS_E_NOAGGREGATION; if (!SHGetSpecialFolderPathA (0, szMyPath, CSIDL_DESKTOPDIRECTORY, TRUE)) - return E_UNEXPECTED; + return E_UNEXPECTED; sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl)); if (!sf) - return E_OUTOFMEMORY; + return E_OUTOFMEMORY; sf->ref = 0; sf->lpVtbl = &vt_MCFldr_ShellFolder2; - sf->pidlRoot = _ILCreateDesktop (); /* my qualified pidl */ + sf->pidlRoot = _ILCreateDesktop (); /* my qualified pidl */ sf->sPathTarget = SHAlloc (strlen (szMyPath) + 1); lstrcpyA (sf->sPathTarget, szMyPath); - if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) { - IUnknown_Release (_IUnknown_ (sf)); - return E_NOINTERFACE; + if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) + { + IUnknown_Release (_IUnknown_ (sf)); + return E_NOINTERFACE; } TRACE ("--(%p)\n", sf); @@ -128,11 +130,12 @@ HRESULT WINAPI ISF_Desktop_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOI } /************************************************************************** - * ISF_Desktop_fnQueryInterface + * ISF_Desktop_fnQueryInterface * * NOTES supports not IPersist/IPersistFolder */ -static HRESULT WINAPI ISF_Desktop_fnQueryInterface (IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj) +static HRESULT WINAPI ISF_Desktop_fnQueryInterface( + IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj) { IGenericSFImpl *This = (IGenericSFImpl *)iface; @@ -140,15 +143,18 @@ static HRESULT WINAPI ISF_Desktop_fnQueryInterface (IShellFolder2 * iface, REFII *ppvObj = NULL; - if (IsEqualIID (riid, &IID_IUnknown) || IsEqualIID (riid, &IID_IShellFolder) - || IsEqualIID (riid, &IID_IShellFolder2)) { - *ppvObj = This; + if (IsEqualIID (riid, &IID_IUnknown) || + IsEqualIID (riid, &IID_IShellFolder) || + IsEqualIID (riid, &IID_IShellFolder2)) + { + *ppvObj = This; } - if (*ppvObj) { - IUnknown_AddRef ((IUnknown *) (*ppvObj)); - TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); - return S_OK; + if (*ppvObj) + { + IUnknown_AddRef ((IUnknown *) (*ppvObj)); + TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); + return S_OK; } TRACE ("-- Interface: E_NOINTERFACE\n"); return E_NOINTERFACE; @@ -171,89 +177,116 @@ static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface) TRACE ("(%p)->(count=%lu)\n", This, refCount + 1); - if (!refCount) { - TRACE ("-- destroying IShellFolder(%p)\n", This); - if (This->pidlRoot) - SHFree (This->pidlRoot); - if (This->sPathTarget) - SHFree (This->sPathTarget); - LocalFree ((HLOCAL) This); + if (!refCount) + { + TRACE ("-- destroying IShellFolder(%p)\n", This); + if (This->pidlRoot) + SHFree (This->pidlRoot); + if (This->sPathTarget) + SHFree (This->sPathTarget); + LocalFree ((HLOCAL) This); return 0; } return refCount; } /************************************************************************** -* ISF_Desktop_fnParseDisplayName -* -* NOTES -* "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds -* to MyComputer -*/ + * ISF_Desktop_fnParseDisplayName + * + * NOTES + * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds + * to MyComputer + */ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, - HWND hwndOwner, - LPBC pbc, - LPOLESTR lpszDisplayName, - DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) + HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, + DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - WCHAR szElement[MAX_PATH]; LPCWSTR szNext = NULL; LPITEMIDLIST pidlTemp = NULL; HRESULT hr = S_OK; - char szPath[MAX_PATH]; - DWORD len; CLSID clsid; TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", - This, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes); + This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), + pchEaten, ppidl, pdwAttributes); if (!lpszDisplayName || !ppidl) - return E_INVALIDARG; + return E_INVALIDARG; *ppidl = 0; if (pchEaten) - *pchEaten = 0; /* strange but like the original */ + *pchEaten = 0; /* strange but like the original */ - if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') { - szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); - TRACE ("-- element: %s\n", debugstr_w (szElement)); - SHCLSIDFromStringW (szElement + 2, &clsid); - pidlTemp = _ILCreateGuid (PT_GUID, &clsid); - } else if (PathGetDriveNumberW (lpszDisplayName) >= 0) { - /* it's a filesystem path with a drive. Let MyComputer parse it */ - pidlTemp = _ILCreateMyComputer (); - szNext = lpszDisplayName; - } else if (PathIsUNCW(lpszDisplayName)) { - pidlTemp = _ILCreateNetwork(); - szNext = lpszDisplayName; - } else { - /* it's a filesystem path on the desktop. Let a FSFolder parse it */ + if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') + { + szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); + TRACE ("-- element: %s\n", debugstr_w (szElement)); + SHCLSIDFromStringW (szElement + 2, &clsid); + pidlTemp = _ILCreateGuid (PT_GUID, &clsid); + } + else if (PathGetDriveNumberW (lpszDisplayName) >= 0) + { + /* it's a filesystem path with a drive. Let MyComputer parse it */ + pidlTemp = _ILCreateMyComputer (); + szNext = lpszDisplayName; + } + else if (PathIsUNCW(lpszDisplayName)) + { + pidlTemp = _ILCreateNetwork(); + szNext = lpszDisplayName; + } + else if( (pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName)) ) + { + *ppidl = pidlTemp; + return S_OK; + } + else + { + /* it's a filesystem path on the desktop. Let a FSFolder parse it */ - if (*lpszDisplayName) { - /* build a complete path to create a simple pidl */ - lstrcpyA(szPath, This->sPathTarget); - PathAddBackslashA(szPath); - len = lstrlenA(szPath); - WideCharToMultiByte(CP_ACP, 0, lpszDisplayName, -1, szPath + len, MAX_PATH - len, NULL, NULL); - hr = _ILCreateFromPathA(szPath, &pidlTemp); - } else { - pidlTemp = _ILCreateMyComputer(); - } + if (*lpszDisplayName) + { + WCHAR szPath[MAX_PATH]; + LPWSTR pathPtr; - szNext = NULL; + /* build a complete path to create a simple pidl */ + MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szPath, + sizeof(szPath) / sizeof(szPath[0])); + pathPtr = PathAddBackslashW(szPath); + if (pathPtr) + { + lstrcpynW(pathPtr, lpszDisplayName, + sizeof(szPath)/sizeof(szPath[0]) - (pathPtr - szPath)); + hr = _ILCreateFromPathW(szPath, &pidlTemp); + } + else + { + /* should never reach here, but for completeness */ + hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + } + } + else + pidlTemp = _ILCreateMyComputer(); + + szNext = NULL; } - if (SUCCEEDED(hr) && pidlTemp) { - if (szNext && *szNext) { - hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); - } else { - if (pdwAttributes && *pdwAttributes) { - hr = SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes); - } - } + if (SUCCEEDED(hr) && pidlTemp) + { + if (szNext && *szNext) + { + hr = SHELL32_ParseNextElement(iface, hwndOwner, pbc, + &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); + } + else + { + if (pdwAttributes && *pdwAttributes) + hr = SHELL32_GetItemAttributes(_IShellFolder_ (This), + pidlTemp, pdwAttributes); + } } *ppidl = pidlTemp; @@ -266,41 +299,48 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, /************************************************************************** * CreateDesktopEnumList() */ +static const WCHAR Desktop_NameSpaceW[] = { 'S','O','F','T','W','A','R','E', + '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', + 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l', + 'o','r','e','r','\\','D','e','s','k','t','o','p','\\','N','a','m','e','s','p', + 'a','c','e','\0' }; + static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags) { BOOL ret = TRUE; - char szPath[MAX_PATH]; + WCHAR szPath[MAX_PATH]; TRACE("(%p)->(flags=0x%08lx) \n",list,dwFlags); - /*enumerate the root folders */ - if(dwFlags & SHCONTF_FOLDERS) + /* enumerate the root folders */ + if (dwFlags & SHCONTF_FOLDERS) { HKEY hkey; + LONG r; - /*create the pidl for This item */ + /* create the pidl for This item */ ret = AddToEnumList(list, _ILCreateMyComputer()); - if (ret && !RegOpenKeyExA(HKEY_LOCAL_MACHINE, - "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\explorer\\desktop\\NameSpace", - 0, KEY_READ, &hkey)) + r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, Desktop_NameSpaceW, + 0, KEY_READ, &hkey); + if (ret && ERROR_SUCCESS == r) { - char iid[50]; + WCHAR iid[50]; int i=0; BOOL moreKeys = TRUE; while (ret && moreKeys) { - DWORD size = sizeof (iid); - LONG apiRet = RegEnumKeyExA(hkey, i, iid, &size, 0, NULL, NULL, - NULL); + DWORD size; - if (ERROR_SUCCESS == apiRet) + size = sizeof (iid); + r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL); + if (ERROR_SUCCESS == r) { - ret = AddToEnumList(list, _ILCreateGuidFromStrA(iid)); + ret = AddToEnumList(list, _ILCreateGuidFromStrW(iid)); i++; } - else if (ERROR_NO_MORE_ITEMS == apiRet) + else if (ERROR_NO_MORE_ITEMS == r) moreKeys = FALSE; else ret = FALSE; @@ -309,22 +349,23 @@ static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags) } } - /*enumerate the elements in %windir%\desktop */ - SHGetSpecialFolderPathA(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE); + /* enumerate the elements in %windir%\desktop */ + SHGetSpecialFolderPathW(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE); ret = ret && CreateFolderEnumList(list, szPath, dwFlags); return ret; } /************************************************************************** -* ISF_Desktop_fnEnumObjects -*/ + * ISF_Desktop_fnEnumObjects + */ static HRESULT WINAPI ISF_Desktop_fnEnumObjects (IShellFolder2 * iface, - HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) + HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList); + TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", + This, hwndOwner, dwFlags, ppEnumIDList); *ppEnumIDList = IEnumIDList_Constructor(); if (*ppEnumIDList) @@ -336,41 +377,41 @@ static HRESULT WINAPI ISF_Desktop_fnEnumObjects (IShellFolder2 * iface, } /************************************************************************** -* ISF_Desktop_fnBindToObject -*/ + * ISF_Desktop_fnBindToObject + */ static HRESULT WINAPI ISF_Desktop_fnBindToObject (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) + LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); + TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", + This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); return SHELL32_BindToChild (This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut); } /************************************************************************** -* ISF_Desktop_fnBindToStorage -*/ + * ISF_Desktop_fnBindToStorage + */ static HRESULT WINAPI ISF_Desktop_fnBindToStorage (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) + LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); + FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", + This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); *ppvOut = NULL; return E_NOTIMPL; } /************************************************************************** -* ISF_Desktop_fnCompareIDs -*/ - + * ISF_Desktop_fnCompareIDs + */ static HRESULT WINAPI ISF_Desktop_fnCompareIDs (IShellFolder2 * iface, - LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) + LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - int nReturn; TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2); @@ -380,62 +421,70 @@ static HRESULT WINAPI ISF_Desktop_fnCompareIDs (IShellFolder2 * iface, } /************************************************************************** -* ISF_Desktop_fnCreateViewObject -*/ + * ISF_Desktop_fnCreateViewObject + */ static HRESULT WINAPI ISF_Desktop_fnCreateViewObject (IShellFolder2 * iface, - HWND hwndOwner, REFIID riid, LPVOID * ppvOut) + HWND hwndOwner, REFIID riid, LPVOID * ppvOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - LPSHELLVIEW pShellView; HRESULT hr = E_INVALIDARG; - TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid (riid), ppvOut); + TRACE ("(%p)->(hwnd=%p,%s,%p)\n", + This, hwndOwner, shdebugstr_guid (riid), ppvOut); - if (ppvOut) { - *ppvOut = NULL; + if (!ppvOut) + return hr; - if (IsEqualIID (riid, &IID_IDropTarget)) { - WARN ("IDropTarget not implemented\n"); - hr = E_NOTIMPL; - } else if (IsEqualIID (riid, &IID_IContextMenu)) { - WARN ("IContextMenu not implemented\n"); - hr = E_NOTIMPL; - } else if (IsEqualIID (riid, &IID_IShellView)) { - pShellView = IShellView_Constructor ((IShellFolder *) iface); - if (pShellView) { - hr = IShellView_QueryInterface (pShellView, riid, ppvOut); - IShellView_Release (pShellView); - } - } + *ppvOut = NULL; + + if (IsEqualIID (riid, &IID_IDropTarget)) + { + WARN ("IDropTarget not implemented\n"); + hr = E_NOTIMPL; + } + else if (IsEqualIID (riid, &IID_IContextMenu)) + { + WARN ("IContextMenu not implemented\n"); + hr = E_NOTIMPL; + } + else if (IsEqualIID (riid, &IID_IShellView)) + { + pShellView = IShellView_Constructor ((IShellFolder *) iface); + if (pShellView) + { + hr = IShellView_QueryInterface (pShellView, riid, ppvOut); + IShellView_Release (pShellView); + } } TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut); return hr; } /************************************************************************** -* ISF_Desktop_fnGetAttributesOf -*/ + * ISF_Desktop_fnGetAttributesOf + */ static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface, - UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) + UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = S_OK; - TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, *rgfInOut); + TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", + This, cidl, apidl, *rgfInOut); - if ((!cidl) || (!apidl) || (!rgfInOut)) - return E_INVALIDARG; + if (!cidl || !apidl || !rgfInOut) + return E_INVALIDARG; if (*rgfInOut == 0) - *rgfInOut = ~0; + *rgfInOut = ~0; - while (cidl > 0 && *apidl) { - pdump (*apidl); - SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); - apidl++; - cidl--; + while (cidl > 0 && *apidl) + { + pdump (*apidl); + SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); + apidl++; + cidl--; } TRACE ("-- result=0x%08lx\n", *rgfInOut); @@ -444,22 +493,20 @@ static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface, } /************************************************************************** -* ISF_Desktop_fnGetUIObjectOf -* -* PARAMETERS -* HWND hwndOwner, //[in ] Parent window for any output -* UINT cidl, //[in ] array size -* LPCITEMIDLIST* apidl, //[in ] simple pidl array -* REFIID riid, //[in ] Requested Interface -* UINT* prgfInOut, //[ ] reserved -* LPVOID* ppvObject) //[out] Resulting Interface -* -*/ + * ISF_Desktop_fnGetUIObjectOf + * + * PARAMETERS + * HWND hwndOwner, //[in ] Parent window for any output + * UINT cidl, //[in ] array size + * LPCITEMIDLIST* apidl, //[in ] simple pidl array + * REFIID riid, //[in ] Requested Interface + * UINT* prgfInOut, //[ ] reserved + * LPVOID* ppvObject) //[out] Resulting Interface + * + */ static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface, - HWND hwndOwner, - UINT cidl, - LPCITEMIDLIST * apidl, - REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) + HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, + REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; @@ -468,10 +515,10 @@ static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface, HRESULT hr = E_INVALIDARG; TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", - This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); + This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); - if (ppvOut) { - *ppvOut = NULL; + if (!ppvOut) + return hr; if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) { @@ -516,26 +563,24 @@ static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface, else hr = E_NOINTERFACE; - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; + if (SUCCEEDED(hr) && !pObj) + hr = E_OUTOFMEMORY; - *ppvOut = pObj; - } + *ppvOut = pObj; TRACE ("(%p)->hr=0x%08lx\n", This, hr); return hr; } /************************************************************************** -* ISF_Desktop_fnGetDisplayNameOf -* -* NOTES -* special case: pidl = null gives desktop-name back -*/ + * ISF_Desktop_fnGetDisplayNameOf + * + * NOTES + * special case: pidl = null gives desktop-name back + */ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) + LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - CHAR szPath[MAX_PATH]; GUID const *clsid; HRESULT hr = S_OK; @@ -546,66 +591,103 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface, pdump (pidl); if (!strRet) - return E_INVALIDARG; + return E_INVALIDARG; - if (_ILIsDesktop (pidl)) { - if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING)) { - lstrcpyA (szPath, This->sPathTarget); - } else { - HCR_GetClassNameA(&CLSID_ShellDesktop, szPath, MAX_PATH); - } - } else if (_ILIsPidlSimple (pidl)) { - if ((clsid = _ILGetGUIDPointer (pidl))) { - if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) { - int bWantsForParsing; + if (_ILIsDesktop (pidl)) + { + if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && + (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING)) + { + lstrcpyA (szPath, This->sPathTarget); + } + else + HCR_GetClassNameA(&CLSID_ShellDesktop, szPath, MAX_PATH); + } + else if (_ILIsPidlSimple (pidl)) + { + if ((clsid = _ILGetGUIDPointer (pidl))) + { + if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) + { + int bWantsForParsing; - /* - * we can only get a filesystem path from a shellfolder if the value WantsFORPARSING in - * CLSID\\{...}\\shellfolder exists - * exception: the MyComputer folder has this keys not but like any filesystem backed - * folder it needs these behaviour - */ - if (IsEqualIID (clsid, &CLSID_MyComputer)) { - bWantsForParsing = 1; - } else { - /* get the "WantsFORPARSING" flag from the registry */ - char szRegPath[100]; + /* + * We can only get a filesystem path from a shellfolder if the + * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists. + * + * Exception: The MyComputer folder doesn't have this key, + * but any other filesystem backed folder it needs it. + */ + if (IsEqualIID (clsid, &CLSID_MyComputer)) + { + bWantsForParsing = 1; + } + else + { + /* get the "WantsFORPARSING" flag from the registry */ + static const WCHAR clsidW[] = + { 'C','L','S','I','D','\\',0 }; + static const WCHAR shellfolderW[] = + { '\\','s','h','e','l','l','f','o','l','d','e','r',0 }; + static const WCHAR wantsForParsingW[] = + { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n', + 'g',0 }; + WCHAR szRegPath[100]; + LONG r; - lstrcpyA (szRegPath, "CLSID\\"); - SHELL32_GUIDToStringA (clsid, &szRegPath[6]); - lstrcatA (szRegPath, "\\shellfolder"); - bWantsForParsing = - (ERROR_SUCCESS == - SHGetValueA (HKEY_CLASSES_ROOT, szRegPath, "WantsFORPARSING", NULL, NULL, NULL)); - } + lstrcpyW (szRegPath, clsidW); + SHELL32_GUIDToStringW (clsid, &szRegPath[6]); + lstrcatW (szRegPath, shellfolderW); + r = SHGetValueW(HKEY_CLASSES_ROOT, szRegPath, + wantsForParsingW, NULL, NULL, NULL); + if (r == ERROR_SUCCESS) + bWantsForParsing = TRUE; + else + bWantsForParsing = FALSE; + } - if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && bWantsForParsing) { - /* we need the filesystem path to the destination folder. Only the folder itself can know it */ - hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH); - } else { - /* parsing name like ::{...} */ - lstrcpyA (szPath, "::"); - SHELL32_GUIDToStringA (clsid, &szPath[2]); - } - } else { - /* user friendly name */ - HCR_GetClassNameA (clsid, szPath, MAX_PATH); - } - } else { - /* file system folder */ - _ILSimpleGetText (pidl, szPath, MAX_PATH); + if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && + bWantsForParsing) + { + /* + * we need the filesystem path to the destination folder. + * Only the folder itself can know it + */ + hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, + szPath, MAX_PATH); + } + else + { + /* parsing name like ::{...} */ + lstrcpyA (szPath, "::"); + SHELL32_GUIDToStringA (clsid, &szPath[2]); + } + } + else + { + /* user friendly name */ + HCR_GetClassNameA (clsid, szPath, MAX_PATH); + } + } + else + { + /* file system folder */ + _ILSimpleGetText (pidl, szPath, MAX_PATH); - if (!_ILIsFolder(pidl)) - SHELL_FS_ProcessDisplayFilename(szPath, dwFlags); - } - } else { - /* a complex pidl, let the subfolder do the work */ - hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH); + if (!_ILIsFolder(pidl)) + SHELL_FS_ProcessDisplayFilename(szPath, dwFlags); + } + } + else + { + /* a complex pidl, let the subfolder do the work */ + hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH); } - if (SUCCEEDED (hr)) { - strRet->uType = STRRET_CSTR; - lstrcpynA (strRet->u.cStr, szPath, MAX_PATH); + if (SUCCEEDED (hr)) + { + strRet->uType = STRRET_CSTR; + lstrcpynA (strRet->u.cStr, szPath, MAX_PATH); } TRACE ("-- (%p)->(%s,0x%08lx)\n", This, szPath, hr); @@ -613,77 +695,86 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface, } /************************************************************************** -* ISF_Desktop_fnSetNameOf -* Changes the name of a file object or subfolder, possibly changing its item -* identifier in the process. -* -* PARAMETERS -* HWND hwndOwner, //[in ] Owner window for output -* LPCITEMIDLIST pidl, //[in ] simple pidl of item to change -* LPCOLESTR lpszName, //[in ] the items new display name -* DWORD dwFlags, //[in ] SHGNO formatting flags -* LPITEMIDLIST* ppidlOut) //[out] simple pidl returned -*/ -static HRESULT WINAPI ISF_Desktop_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */ - LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) + * ISF_Desktop_fnSetNameOf + * Changes the name of a file object or subfolder, possibly changing its item + * identifier in the process. + * + * PARAMETERS + * HWND hwndOwner, //[in ] Owner window for output + * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change + * LPCOLESTR lpszName, //[in ] the items new display name + * DWORD dwFlags, //[in ] SHGNO formatting flags + * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned + */ +static HRESULT WINAPI ISF_Desktop_fnSetNameOf (IShellFolder2 * iface, + HWND hwndOwner, LPCITEMIDLIST pidl, /* simple pidl */ + LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut); + FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, + debugstr_w (lpName), dwFlags, pPidlOut); return E_FAIL; } -static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid) +static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID(IShellFolder2 *iface, + GUID * pguid) { IGenericSFImpl *This = (IGenericSFImpl *)iface; FIXME ("(%p)\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ISF_Desktop_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum) + +static HRESULT WINAPI ISF_Desktop_fnEnumSearches (IShellFolder2 *iface, + IEnumExtraSearch ** ppenum) { IGenericSFImpl *This = (IGenericSFImpl *)iface; FIXME ("(%p)\n", This); return E_NOTIMPL; } + static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumn (IShellFolder2 * iface, - DWORD dwRes, ULONG * pSort, ULONG * pDisplay) + DWORD dwRes, ULONG * pSort, ULONG * pDisplay) { IGenericSFImpl *This = (IGenericSFImpl *)iface; TRACE ("(%p)\n", This); if (pSort) - *pSort = 0; + *pSort = 0; if (pDisplay) - *pDisplay = 0; + *pDisplay = 0; return S_OK; } -static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) +static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState ( + IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) { IGenericSFImpl *This = (IGenericSFImpl *)iface; TRACE ("(%p)\n", This); if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS) - return E_INVALIDARG; + return E_INVALIDARG; *pcsFlags = DesktopSFHeader[iColumn].pcsFlags; return S_OK; } + static HRESULT WINAPI ISF_Desktop_fnGetDetailsEx (IShellFolder2 * iface, - LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) + LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) { IGenericSFImpl *This = (IGenericSFImpl *)iface; FIXME ("(%p)\n", This); return E_NOTIMPL; } + static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface, - LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) + LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) { IGenericSFImpl *This = (IGenericSFImpl *)iface; @@ -692,40 +783,46 @@ static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface, TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd); if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS) - return E_INVALIDARG; + return E_INVALIDARG; - if (!pidl) { - psd->fmt = DesktopSFHeader[iColumn].fmt; - psd->cxChar = DesktopSFHeader[iColumn].cxChar; - psd->str.uType = STRRET_CSTR; - LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH); - return S_OK; - } else { - /* the data from the pidl */ - switch (iColumn) { - case 0: /* name */ - hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); - break; - case 1: /* size */ - _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 2: /* type */ - _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 3: /* date */ - _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 4: /* attributes */ - _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH); - break; - } - hr = S_OK; - psd->str.uType = STRRET_CSTR; + if (!pidl) + { + psd->fmt = DesktopSFHeader[iColumn].fmt; + psd->cxChar = DesktopSFHeader[iColumn].cxChar; + psd->str.uType = STRRET_CSTR; + LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid, + psd->str.u.cStr, MAX_PATH); + return S_OK; } + /* the data from the pidl */ + switch (iColumn) + { + case 0: /* name */ + hr = IShellFolder_GetDisplayNameOf(iface, pidl, + SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); + break; + case 1: /* size */ + _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH); + break; + case 2: /* type */ + _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH); + break; + case 3: /* date */ + _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH); + break; + case 4: /* attributes */ + _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH); + break; + } + hr = S_OK; + psd->str.uType = STRRET_CSTR; + return hr; } -static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID (IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid) + +static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID ( + IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid) { IGenericSFImpl *This = (IGenericSFImpl *)iface; FIXME ("(%p)\n", This); @@ -734,24 +831,25 @@ static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID (IShellFolder2 * iface, UINT static IShellFolder2Vtbl vt_MCFldr_ShellFolder2 = { - ISF_Desktop_fnQueryInterface, - ISF_Desktop_fnAddRef, - ISF_Desktop_fnRelease, - ISF_Desktop_fnParseDisplayName, - ISF_Desktop_fnEnumObjects, - ISF_Desktop_fnBindToObject, - ISF_Desktop_fnBindToStorage, - ISF_Desktop_fnCompareIDs, - ISF_Desktop_fnCreateViewObject, - ISF_Desktop_fnGetAttributesOf, - ISF_Desktop_fnGetUIObjectOf, - ISF_Desktop_fnGetDisplayNameOf, - ISF_Desktop_fnSetNameOf, - /* ShellFolder2 */ - ISF_Desktop_fnGetDefaultSearchGUID, - ISF_Desktop_fnEnumSearches, - ISF_Desktop_fnGetDefaultColumn, - ISF_Desktop_fnGetDefaultColumnState, - ISF_Desktop_fnGetDetailsEx, - ISF_Desktop_fnGetDetailsOf, - ISF_Desktop_fnMapColumnToSCID}; + ISF_Desktop_fnQueryInterface, + ISF_Desktop_fnAddRef, + ISF_Desktop_fnRelease, + ISF_Desktop_fnParseDisplayName, + ISF_Desktop_fnEnumObjects, + ISF_Desktop_fnBindToObject, + ISF_Desktop_fnBindToStorage, + ISF_Desktop_fnCompareIDs, + ISF_Desktop_fnCreateViewObject, + ISF_Desktop_fnGetAttributesOf, + ISF_Desktop_fnGetUIObjectOf, + ISF_Desktop_fnGetDisplayNameOf, + ISF_Desktop_fnSetNameOf, + /* ShellFolder2 */ + ISF_Desktop_fnGetDefaultSearchGUID, + ISF_Desktop_fnEnumSearches, + ISF_Desktop_fnGetDefaultColumn, + ISF_Desktop_fnGetDefaultColumnState, + ISF_Desktop_fnGetDetailsEx, + ISF_Desktop_fnGetDetailsOf, + ISF_Desktop_fnMapColumnToSCID +}; diff --git a/reactos/lib/shell32/shfldr_fs.c b/reactos/lib/shell32/shfldr_fs.c index e8fdca78b38..41c6e1d543e 100644 --- a/reactos/lib/shell32/shfldr_fs.c +++ b/reactos/lib/shell32/shfldr_fs.c @@ -1,9 +1,9 @@ /* - * file system folder + * file system folder * - * Copyright 1997 Marcus Meissner - * Copyright 1998, 1999, 2002 Juergen Schmied + * Copyright 1997 Marcus Meissner + * Copyright 1998, 1999, 2002 Juergen Schmied * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -67,24 +67,24 @@ typedef struct { IDropTargetVtbl *lpvtblDropTarget; ISFHelperVtbl *lpvtblSFHelper; - IUnknown *pUnkOuter; /* used for aggregation */ + IUnknown *pUnkOuter; /* used for aggregation */ CLSID *pclsid; /* both paths are parsible from the desktop */ - LPSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */ + LPSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */ - LPITEMIDLIST pidlRoot; /* absolute pidl */ + LPITEMIDLIST pidlRoot; /* absolute pidl */ - int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */ + int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */ - UINT cfShellIDList; /* clipboardformat for IDropTarget */ - BOOL fAcceptFmt; /* flag for pending Drop */ + UINT cfShellIDList; /* clipboardformat for IDropTarget */ + BOOL fAcceptFmt; /* flag for pending Drop */ } IGenericSFImpl; static struct IUnknownVtbl unkvt; static struct IShellFolder2Vtbl sfvt; -static struct IPersistFolder3Vtbl vt_FSFldr_PersistFolder3; /* IPersistFolder3 for a FS_Folder */ +static struct IPersistFolder3Vtbl vt_FSFldr_PersistFolder3; /* IPersistFolder3 for a FS_Folder */ static struct IDropTargetVtbl dtvt; static struct ISFHelperVtbl shvt; @@ -106,31 +106,31 @@ static struct ISFHelperVtbl shvt; /* converts This to a interface pointer */ -#define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) -#define _IShellFolder_(This) (IShellFolder*)&(This->lpvtblShellFolder) -#define _IShellFolder2_(This) (IShellFolder2*)&(This->lpvtblShellFolder) -#define _IPersist_(This) (IPersist*)&(This->lpvtblPersistFolder3) -#define _IPersistFolder_(This) (IPersistFolder*)&(This->lpvtblPersistFolder3) -#define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpvtblPersistFolder3) -#define _IPersistFolder3_(This) (IPersistFolder3*)&(This->lpvtblPersistFolder3) -#define _IDropTarget_(This) (IDropTarget*)&(This->lpvtblDropTarget) -#define _ISFHelper_(This) (ISFHelper*)&(This->lpvtblSFHelper) +#define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) +#define _IShellFolder_(This) (IShellFolder*)&(This->lpvtblShellFolder) +#define _IShellFolder2_(This) (IShellFolder2*)&(This->lpvtblShellFolder) +#define _IPersist_(This) (IPersist*)&(This->lpvtblPersistFolder3) +#define _IPersistFolder_(This) (IPersistFolder*)&(This->lpvtblPersistFolder3) +#define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpvtblPersistFolder3) +#define _IPersistFolder3_(This) (IPersistFolder3*)&(This->lpvtblPersistFolder3) +#define _IDropTarget_(This) (IDropTarget*)&(This->lpvtblDropTarget) +#define _ISFHelper_(This) (ISFHelper*)&(This->lpvtblSFHelper) /************************************************************************** -* registers clipboardformat once +* registers clipboardformat once */ static void SF_RegisterClipFmt (IGenericSFImpl * This) { TRACE ("(%p)\n", This); if (!This->cfShellIDList) { - This->cfShellIDList = RegisterClipboardFormatA (CFSTR_SHELLIDLIST); + This->cfShellIDList = RegisterClipboardFormatA (CFSTR_SHELLIDLIST); } } /************************************************************************** -* we need a separate IUnknown to handle aggregation -* (inner IUnknown) +* we need a separate IUnknown to handle aggregation +* (inner IUnknown) */ static HRESULT WINAPI IUnknown_fnQueryInterface (IUnknown * iface, REFIID riid, LPVOID * ppvObj) { @@ -141,30 +141,30 @@ static HRESULT WINAPI IUnknown_fnQueryInterface (IUnknown * iface, REFIID riid, *ppvObj = NULL; if (IsEqualIID (riid, &IID_IUnknown)) - *ppvObj = _IUnknown_ (This); + *ppvObj = _IUnknown_ (This); else if (IsEqualIID (riid, &IID_IShellFolder)) - *ppvObj = _IShellFolder_ (This); + *ppvObj = _IShellFolder_ (This); else if (IsEqualIID (riid, &IID_IShellFolder2)) - *ppvObj = _IShellFolder_ (This); + *ppvObj = _IShellFolder_ (This); else if (IsEqualIID (riid, &IID_IPersist)) - *ppvObj = _IPersist_ (This); + *ppvObj = _IPersist_ (This); else if (IsEqualIID (riid, &IID_IPersistFolder)) - *ppvObj = _IPersistFolder_ (This); + *ppvObj = _IPersistFolder_ (This); else if (IsEqualIID (riid, &IID_IPersistFolder2)) - *ppvObj = _IPersistFolder2_ (This); + *ppvObj = _IPersistFolder2_ (This); else if (IsEqualIID (riid, &IID_IPersistFolder3)) - *ppvObj = _IPersistFolder3_ (This); + *ppvObj = _IPersistFolder3_ (This); else if (IsEqualIID (riid, &IID_ISFHelper)) - *ppvObj = _ISFHelper_ (This); + *ppvObj = _ISFHelper_ (This); else if (IsEqualIID (riid, &IID_IDropTarget)) { - *ppvObj = _IDropTarget_ (This); - SF_RegisterClipFmt (This); + *ppvObj = _IDropTarget_ (This); + SF_RegisterClipFmt (This); } if (*ppvObj) { - IUnknown_AddRef ((IUnknown *) (*ppvObj)); - TRACE ("-- Interface = %p\n", *ppvObj); - return S_OK; + IUnknown_AddRef ((IUnknown *) (*ppvObj)); + TRACE ("-- Interface = %p\n", *ppvObj); + return S_OK; } TRACE ("-- Interface: E_NOINTERFACE\n"); return E_NOINTERFACE; @@ -188,13 +188,13 @@ static ULONG WINAPI IUnknown_fnRelease (IUnknown * iface) TRACE ("(%p)->(count=%lu)\n", This, refCount + 1); if (!refCount) { - TRACE ("-- destroying IShellFolder(%p)\n", This); + TRACE ("-- destroying IShellFolder(%p)\n", This); - if (This->pidlRoot) - SHFree (This->pidlRoot); - if (This->sPathTarget) - SHFree (This->sPathTarget); - LocalFree ((HLOCAL) This); + if (This->pidlRoot) + SHFree (This->pidlRoot); + if (This->sPathTarget) + SHFree (This->sPathTarget); + LocalFree ((HLOCAL) This); } return refCount; } @@ -217,24 +217,25 @@ static shvheader GenericSFHeader[] = { #define GENERICSHELLVIEWCOLUMNS 5 /************************************************************************** -* IFSFolder_Constructor +* IFSFolder_Constructor * * NOTES * creating undocumented ShellFS_Folder as part of an aggregation * {F3364BA0-65B9-11CE-A9BA-00AA004AE837} * */ -HRESULT WINAPI IFSFolder_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) +HRESULT WINAPI +IFSFolder_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) { IGenericSFImpl *sf; TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown)) - return CLASS_E_NOAGGREGATION; + return CLASS_E_NOAGGREGATION; sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl)); if (!sf) - return E_OUTOFMEMORY; + return E_OUTOFMEMORY; sf->ref = 0; sf->lpVtbl = &unkvt; @@ -246,8 +247,8 @@ HRESULT WINAPI IFSFolder_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID sf->pUnkOuter = pUnkOuter ? pUnkOuter : _IUnknown_ (sf); if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) { - IUnknown_Release (_IUnknown_ (sf)); - return E_NOINTERFACE; + IUnknown_Release (_IUnknown_ (sf)); + return E_NOINTERFACE; } TRACE ("--%p\n", *ppv); @@ -258,14 +259,16 @@ HRESULT WINAPI IFSFolder_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * IShellFolder_fnQueryInterface * * PARAMETERS - * REFIID riid [in ] Requested InterfaceID - * LPVOID* ppvObject [out] Interface* to hold the result + * REFIID riid [in ] Requested InterfaceID + * LPVOID* ppvObject [out] Interface* to hold the result */ -static HRESULT WINAPI IShellFolder_fnQueryInterface (IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj) +static HRESULT WINAPI +IShellFolder_fnQueryInterface (IShellFolder2 * iface, REFIID riid, + LPVOID * ppvObj) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) - TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); + TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj); return IUnknown_QueryInterface (This->pUnkOuter, riid, ppvObj); } @@ -295,6 +298,50 @@ static ULONG WINAPI IShellFolder_fnRelease (IShellFolder2 * iface) return IUnknown_Release (This->pUnkOuter); } +/************************************************************************** + * SHELL32_CreatePidlFromBindCtx [internal] + * + * If the caller bound File System Bind Data, assume it is the + * find data for the path. + * This allows binding of paths that don't exist. + */ +LPITEMIDLIST SHELL32_CreatePidlFromBindCtx(IBindCtx *pbc, LPCWSTR path) +{ + static const WCHAR szfsbc[] = { + 'F','i','l','e',' ','S','y','s','t','e','m',' ', + 'B','i','n','d',' ','D','a','t','a',0 }; + IFileSystemBindData *fsbd = NULL; + LPITEMIDLIST pidl = NULL; + IUnknown *param = NULL; + WIN32_FIND_DATAW wfd; + HRESULT r; + + TRACE("%p %s\n", pbc, debugstr_w(path)); + + if (!pbc) + return NULL; + + /* see if the caller bound File System Bind Data */ + r = IBindCtx_GetObjectParam( pbc, (LPOLESTR) szfsbc, ¶m ); + if (FAILED(r)) + return NULL; + + r = IUnknown_QueryInterface( param, &IID_IFileSystemBindData, + (LPVOID*) &fsbd ); + if (SUCCEEDED(r)) + { + r = IFileSystemBindData_GetFindData( fsbd, &wfd ); + if (SUCCEEDED(r)) + { + lstrcpynW( &wfd.cFileName[0], path, MAX_PATH ); + pidl = _ILCreateFromFindDataW( &wfd ); + } + IFileSystemBindData_Release( fsbd ); + } + + return pidl; +} + /************************************************************************** * IShellFolder_ParseDisplayName {SHELL32} * @@ -313,8 +360,8 @@ static ULONG WINAPI IShellFolder_fnRelease (IShellFolder2 * iface) * subfolder to evaluate the remaining parts. * Now we can parse into namespaces implemented by shell extensions * -* Behaviour on win98: lpszDisplayName=NULL -> crash -* lpszDisplayName="" -> returns mycoputer-pidl +* Behaviour on win98: lpszDisplayName=NULL -> crash +* lpszDisplayName="" -> returns mycoputer-pidl * * FIXME * pdwAttributes is not set @@ -322,59 +369,66 @@ static ULONG WINAPI IShellFolder_fnRelease (IShellFolder2 * iface) */ static HRESULT WINAPI IShellFolder_fnParseDisplayName (IShellFolder2 * iface, - HWND hwndOwner, - LPBC pbc, - LPOLESTR lpszDisplayName, - DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) + HWND hwndOwner, + LPBC pbc, + LPOLESTR lpszDisplayName, + DWORD * pchEaten, LPITEMIDLIST * ppidl, + DWORD * pdwAttributes) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) HRESULT hr = E_INVALIDARG; LPCWSTR szNext = NULL; WCHAR szElement[MAX_PATH]; - CHAR szPath[MAX_PATH]; + WCHAR szPath[MAX_PATH]; LPITEMIDLIST pidlTemp = NULL; DWORD len; TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", - This, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes); + This, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), + pchEaten, ppidl, pdwAttributes); if (!lpszDisplayName || !ppidl) - return E_INVALIDARG; + return E_INVALIDARG; if (pchEaten) - *pchEaten = 0; /* strange but like the original */ + *pchEaten = 0; /* strange but like the original */ - if (*lpszDisplayName) { - /* get the next element */ - szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); + pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName); + if (!pidlTemp && *lpszDisplayName) + { + /* get the next element */ + szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); - /* build the full pathname to the element */ - lstrcpyA(szPath, This->sPathTarget); - PathAddBackslashA(szPath); - len = lstrlenA(szPath); - WideCharToMultiByte(CP_ACP, 0, szElement, -1, szPath + len, MAX_PATH - len, NULL, NULL); + /* build the full pathname to the element */ + /* lstrcpyW(szPath, This->sPathTarget); */ + MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szPath, MAX_PATH); + PathAddBackslashW(szPath); + len = lstrlenW(szPath); + lstrcpynW(szPath + len, szElement, MAX_PATH - len); - /* get the pidl */ - hr = _ILCreateFromPathA(szPath, &pidlTemp); + /* get the pidl */ + hr = _ILCreateFromPathW(szPath, &pidlTemp); - if (SUCCEEDED(hr)) { - if (szNext && *szNext) { - /* try to analyse the next element */ - hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); - } else { - /* it's the last element */ - if (pdwAttributes && *pdwAttributes) { - hr = SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes); - } - } - } + if (SUCCEEDED(hr)) { + if (szNext && *szNext) { + /* try to analyse the next element */ + hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, + &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); + } else { + /* it's the last element */ + if (pdwAttributes && *pdwAttributes) { + hr = SHELL32_GetItemAttributes (_IShellFolder_ (This), + pidlTemp, pdwAttributes); + } + } + } } if (SUCCEEDED(hr)) - *ppidl = pidlTemp; + *ppidl = pidlTemp; else - *ppidl = NULL; + *ppidl = NULL; TRACE ("(%p)->(-- pidl=%p ret=0x%08lx)\n", This, ppidl ? *ppidl : 0, hr); @@ -382,22 +436,28 @@ IShellFolder_fnParseDisplayName (IShellFolder2 * iface, } /************************************************************************** -* IShellFolder_fnEnumObjects +* IShellFolder_fnEnumObjects * PARAMETERS * HWND hwndOwner, //[in ] Parent Window * DWORD grfFlags, //[in ] SHCONTF enumeration mask * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface */ static HRESULT WINAPI -IShellFolder_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) +IShellFolder_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, + DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) - TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList); + TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, hwndOwner, + dwFlags, ppEnumIDList); *ppEnumIDList = IEnumIDList_Constructor(); if (*ppEnumIDList) - CreateFolderEnumList(*ppEnumIDList, This->sPathTarget, dwFlags); + { + WCHAR path[MAX_PATH]; + MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, path, MAX_PATH); + CreateFolderEnumList(*ppEnumIDList, path, dwFlags); + } TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList); @@ -405,7 +465,7 @@ IShellFolder_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags } /************************************************************************** -* IShellFolder_fnBindToObject +* IShellFolder_fnBindToObject * PARAMETERS * LPCITEMIDLIST pidl, //[in ] relative pidl to open * LPBC pbc, //[in ] optional FileSystemBindData context @@ -413,13 +473,16 @@ IShellFolder_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags * LPVOID* ppvObject //[out] Interface* */ static HRESULT WINAPI -IShellFolder_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, LPVOID * ppvOut) +IShellFolder_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl, + LPBC pbc, REFIID riid, LPVOID * ppvOut) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) - TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbc, shdebugstr_guid (riid), ppvOut); + TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbc, + shdebugstr_guid (riid), ppvOut); - return SHELL32_BindToChild (This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut); + return SHELL32_BindToChild (This->pidlRoot, This->sPathTarget, pidl, riid, + ppvOut); } /************************************************************************** @@ -431,11 +494,13 @@ IShellFolder_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl, LPBC pbc * LPVOID* ppvObject //[out] Interface* returned */ static HRESULT WINAPI -IShellFolder_fnBindToStorage (IShellFolder2 * iface, LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) +IShellFolder_fnBindToStorage (IShellFolder2 * iface, LPCITEMIDLIST pidl, + LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) - FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); + FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, + shdebugstr_guid (riid), ppvOut); *ppvOut = NULL; return E_NOTIMPL; @@ -446,7 +511,8 @@ IShellFolder_fnBindToStorage (IShellFolder2 * iface, LPCITEMIDLIST pidl, LPBC pb */ static HRESULT WINAPI -IShellFolder_fnCompareIDs (IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) +IShellFolder_fnCompareIDs (IShellFolder2 * iface, LPARAM lParam, + LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) @@ -459,33 +525,35 @@ IShellFolder_fnCompareIDs (IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST p } /************************************************************************** -* IShellFolder_fnCreateViewObject +* IShellFolder_fnCreateViewObject */ static HRESULT WINAPI -IShellFolder_fnCreateViewObject (IShellFolder2 * iface, HWND hwndOwner, REFIID riid, LPVOID * ppvOut) +IShellFolder_fnCreateViewObject (IShellFolder2 * iface, HWND hwndOwner, + REFIID riid, LPVOID * ppvOut) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) LPSHELLVIEW pShellView; HRESULT hr = E_INVALIDARG; - TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid (riid), ppvOut); + TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid (riid), + ppvOut); if (ppvOut) { - *ppvOut = NULL; + *ppvOut = NULL; - if (IsEqualIID (riid, &IID_IDropTarget)) { - hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, ppvOut); - } else if (IsEqualIID (riid, &IID_IContextMenu)) { - FIXME ("IContextMenu not implemented\n"); - hr = E_NOTIMPL; - } else if (IsEqualIID (riid, &IID_IShellView)) { - pShellView = IShellView_Constructor ((IShellFolder *) iface); - if (pShellView) { - hr = IShellView_QueryInterface (pShellView, riid, ppvOut); - IShellView_Release (pShellView); - } - } + if (IsEqualIID (riid, &IID_IDropTarget)) { + hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, ppvOut); + } else if (IsEqualIID (riid, &IID_IContextMenu)) { + FIXME ("IContextMenu not implemented\n"); + hr = E_NOTIMPL; + } else if (IsEqualIID (riid, &IID_IShellView)) { + pShellView = IShellView_Constructor ((IShellFolder *) iface); + if (pShellView) { + hr = IShellView_QueryInterface (pShellView, riid, ppvOut); + IShellView_Release (pShellView); + } + } } TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut); return hr; @@ -501,25 +569,27 @@ IShellFolder_fnCreateViewObject (IShellFolder2 * iface, HWND hwndOwner, REFIID r * */ static HRESULT WINAPI -IShellFolder_fnGetAttributesOf (IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) +IShellFolder_fnGetAttributesOf (IShellFolder2 * iface, UINT cidl, + LPCITEMIDLIST * apidl, DWORD * rgfInOut) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) HRESULT hr = S_OK; - TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, *rgfInOut); + TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, + *rgfInOut); if ((!cidl) || (!apidl) || (!rgfInOut)) - return E_INVALIDARG; + return E_INVALIDARG; if (*rgfInOut == 0) - *rgfInOut = ~0; + *rgfInOut = ~0; while (cidl > 0 && *apidl) { - pdump (*apidl); - SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); - apidl++; - cidl--; + pdump (*apidl); + SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); + apidl++; + cidl--; } TRACE ("-- result=0x%08lx\n", *rgfInOut); @@ -539,19 +609,22 @@ IShellFolder_fnGetAttributesOf (IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * LPVOID* ppvObject) //[out] Resulting Interface * * NOTES -* This function gets asked to return "view objects" for one or more (multiple select) -* items: -* The viewobject typically is an COM object with one of the following interfaces: +* This function gets asked to return "view objects" for one or more (multiple +* select) items: +* The viewobject typically is an COM object with one of the following +* interfaces: * IExtractIcon,IDataObject,IContextMenu * In order to support icon positions in the default Listview your DataObject -* must implement the SetData method (in addition to GetData :) - the shell passes -* a barely documented "Icon positions" structure to SetData when the drag starts, -* and GetData's it if the drop is in another explorer window that needs the positions. +* must implement the SetData method (in addition to GetData :) - the shell +* passes a barely documented "Icon positions" structure to SetData when the +* drag starts, and GetData's it if the drop is in another explorer window that +* needs the positions. */ static HRESULT WINAPI IShellFolder_fnGetUIObjectOf (IShellFolder2 * iface, - HWND hwndOwner, - UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) + HWND hwndOwner, + UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, + UINT * prgfInOut, LPVOID * ppvOut) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) @@ -560,86 +633,99 @@ IShellFolder_fnGetUIObjectOf (IShellFolder2 * iface, HRESULT hr = E_INVALIDARG; TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", - This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); + This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); if (ppvOut) { - *ppvOut = NULL; + *ppvOut = NULL; - if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) { - pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl); - hr = S_OK; - } else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) { - pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl); - hr = S_OK; - } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) { - hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj); - } else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA)) - && (cidl == 1)) { - pidl = ILCombine (This->pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj); - SHFree (pidl); - } else { - hr = E_NOINTERFACE; - } + if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) { + pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, + This->pidlRoot, apidl, cidl); + hr = S_OK; + } else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) { + pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, + This->pidlRoot, apidl, cidl); + hr = S_OK; + } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) { + pidl = ILCombine (This->pidlRoot, apidl[0]); + pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl); + SHFree (pidl); + hr = S_OK; + } else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) { + pidl = ILCombine (This->pidlRoot, apidl[0]); + pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl); + SHFree (pidl); + hr = S_OK; + } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) { + hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, + (LPVOID *) & pObj); + } else if ((IsEqualIID(riid,&IID_IShellLinkW) || + IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1)) { + pidl = ILCombine (This->pidlRoot, apidl[0]); + hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj); + SHFree (pidl); + } else { + hr = E_NOINTERFACE; + } - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; + if (SUCCEEDED(hr) && !pObj) + hr = E_OUTOFMEMORY; - *ppvOut = pObj; + *ppvOut = pObj; } TRACE ("(%p)->hr=0x%08lx\n", This, hr); return hr; } +static const WCHAR AdvancedW[] = { 'S','O','F','T','W','A','R','E', + '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', + 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l', + 'o','r','e','r','\\','A','d','v','a','n','c','e','d',0 }; +static const WCHAR HideFileExtW[] = { 'H','i','d','e','F','i','l','e','E','x', + 't',0 }; +static const WCHAR NeverShowExtW[] = { 'N','e','v','e','r','S','h','o','w','E', + 'x','t',0 }; + void SHELL_FS_ProcessDisplayFilename(LPSTR szPath, DWORD dwFlags) { /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */ if (!(dwFlags & SHGDN_FORPARSING) && - ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) { - HKEY hKey; - DWORD dwData; - DWORD dwDataSize = sizeof (DWORD); - BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */ + ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) { + HKEY hKey; + DWORD dwData; + DWORD dwDataSize = sizeof (DWORD); + BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */ - if (!RegCreateKeyExA (HKEY_CURRENT_USER, - "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", - 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) { - if (!RegQueryValueExA (hKey, "HideFileExt", 0, 0, (LPBYTE) & dwData, &dwDataSize)) - doHide = dwData; + if (!RegCreateKeyExW (HKEY_CURRENT_USER, AdvancedW, + 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) { + if (!RegQueryValueExW (hKey, HideFileExtW, 0, 0, (LPBYTE) &dwData, + &dwDataSize)) + doHide = dwData; - RegCloseKey (hKey); - } + RegCloseKey (hKey); + } - if (!doHide) { - LPSTR ext = PathFindExtensionA(szPath); + if (!doHide) { + LPSTR ext = PathFindExtensionA(szPath); - if (ext) { - HKEY hkey; - char classname[MAX_PATH]; - LONG classlen = MAX_PATH; + if (ext) { + char classname[MAX_PATH]; + LONG classlen = MAX_PATH; - if (!RegQueryValueA(HKEY_CLASSES_ROOT, ext, classname, &classlen)) - if (!RegOpenKeyA(HKEY_CLASSES_ROOT, classname, &hkey)) { - if (!RegQueryValueExA(hkey, "NeverShowExt", 0, NULL, NULL, NULL)) - doHide = TRUE; + if (!RegQueryValueA(HKEY_CLASSES_ROOT, ext, classname, + &classlen)) + if (!RegOpenKeyA(HKEY_CLASSES_ROOT, classname, &hKey)) { + if (!RegQueryValueExW(hKey, NeverShowExtW, 0, NULL, + NULL, NULL)) + doHide = TRUE; - RegCloseKey(hkey); - } - } - } + RegCloseKey(hKey); + } + } + } - if (doHide && szPath[0] != '.') - PathRemoveExtensionA (szPath); + if (doHide && szPath[0] != '.') + PathRemoveExtensionA (szPath); } } @@ -657,7 +743,8 @@ void SHELL_FS_ProcessDisplayFilename(LPSTR szPath, DWORD dwFlags) */ static HRESULT WINAPI -IShellFolder_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) +IShellFolder_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, + DWORD dwFlags, LPSTRRET strRet) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) @@ -671,36 +758,40 @@ IShellFolder_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, DWOR pdump (pidl); if (!pidl || !strRet) - return E_INVALIDARG; + return E_INVALIDARG; bSimplePidl = _ILIsPidlSimple (pidl); /* take names of special folders only if its only this folder */ if (_ILIsSpecialFolder (pidl)) { - if (bSimplePidl) { - _ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */ - } else { - FIXME ("special pidl\n"); - } + if (bSimplePidl) { + _ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */ + } else { + FIXME ("special pidl\n"); + } } else { - if (!(dwFlags & SHGDN_INFOLDER) && (dwFlags & SHGDN_FORPARSING) && This->sPathTarget) { - lstrcpyA (szPath, This->sPathTarget); /* get path to root */ - PathAddBackslashA (szPath); - len = lstrlenA (szPath); - } - _ILSimpleGetText (pidl, szPath + len, MAX_PATH - len); /* append my own path */ + if (!(dwFlags & SHGDN_INFOLDER) && (dwFlags & SHGDN_FORPARSING) && + This->sPathTarget) { + /* get path to root */ + lstrcpyA (szPath, This->sPathTarget); + PathAddBackslashA (szPath); + len = lstrlenA (szPath); + } + /* append my own path */ + _ILSimpleGetText (pidl, szPath + len, MAX_PATH - len); - if (!_ILIsFolder(pidl)) - SHELL_FS_ProcessDisplayFilename(szPath, dwFlags); + if (!_ILIsFolder(pidl)) + SHELL_FS_ProcessDisplayFilename(szPath, dwFlags); } - if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) { /* go deeper if needed */ - PathAddBackslashA (szPath); - len = lstrlenA (szPath); + /* go deeper if needed */ + if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) { + PathAddBackslashA (szPath); + len = lstrlenA (szPath); - if (!SUCCEEDED - (SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len))) - return E_OUTOFMEMORY; + if (!SUCCEEDED(SHELL32_GetDisplayNameOfChild (iface, pidl, + dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len))) + return E_OUTOFMEMORY; } strRet->uType = STRRET_CSTR; lstrcpynA (strRet->u.cStr, szPath, MAX_PATH); @@ -721,98 +812,113 @@ IShellFolder_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, DWOR * DWORD dwFlags, //[in ] SHGNO formatting flags * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned */ -static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */ - LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) +static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface, + HWND hwndOwner, + LPCITEMIDLIST pidl, + LPCOLESTR lpName, + DWORD dwFlags, + LPITEMIDLIST * pPidlOut) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) - char szSrc[MAX_PATH], - szDest[MAX_PATH]; - int len; + WCHAR szSrc[MAX_PATH], szDest[MAX_PATH]; + LPWSTR ptr; BOOL bIsFolder = _ILIsFolder (ILFindLastID (pidl)); - TRACE ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut); + TRACE ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, + debugstr_w (lpName), dwFlags, pPidlOut); /* build source path */ if (dwFlags & SHGDN_INFOLDER) { - strcpy (szSrc, This->sPathTarget); - PathAddBackslashA (szSrc); - len = strlen (szSrc); - _ILSimpleGetText (pidl, szSrc + len, MAX_PATH - len); + MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szSrc, MAX_PATH); + ptr = PathAddBackslashW (szSrc); + if (ptr) + _ILSimpleGetTextW (pidl, ptr, MAX_PATH - (ptr - szSrc)); } else { - /* FIXME: Can this work with a simple PIDL? */ - SHGetPathFromIDListA (pidl, szSrc); + /* FIXME: Can this work with a simple PIDL? */ + SHGetPathFromIDListW (pidl, szSrc); } /* build destination path */ - strcpy (szDest, This->sPathTarget); - PathAddBackslashA (szDest); - len = strlen (szDest); - WideCharToMultiByte (CP_ACP, 0, lpName, -1, szDest + len, MAX_PATH - len, NULL, NULL); - szDest[MAX_PATH - 1] = 0; - TRACE ("src=%s dest=%s\n", szSrc, szDest); - if (MoveFileA (szSrc, szDest)) { - HRESULT hr = S_OK; + MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szDest, MAX_PATH); + ptr = PathAddBackslashW (szDest); + if (ptr) + lstrcpynW(ptr, lpName, MAX_PATH - (ptr - szDest)); + TRACE ("src=%s dest=%s\n", debugstr_w(szSrc), debugstr_w(szDest)); + if (MoveFileW (szSrc, szDest)) { + HRESULT hr = S_OK; - if (pPidlOut) - hr = _ILCreateFromPathA(szDest, pPidlOut); + if (pPidlOut) + hr = _ILCreateFromPathW(szDest, pPidlOut); - SHChangeNotify (bIsFolder ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM, SHCNF_PATHA, szSrc, szDest); + SHChangeNotify (bIsFolder ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM, + SHCNF_PATHW, szSrc, szDest); - return hr; + return hr; } return E_FAIL; } -static HRESULT WINAPI IShellFolder_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid) +static HRESULT WINAPI IShellFolder_fnGetDefaultSearchGUID (IShellFolder2 *iface, + GUID * pguid) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) - FIXME ("(%p)\n", This); + FIXME ("(%p)\n", This); return E_NOTIMPL; } -static HRESULT WINAPI IShellFolder_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum) +static HRESULT WINAPI IShellFolder_fnEnumSearches (IShellFolder2 * iface, + IEnumExtraSearch ** ppenum) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) - FIXME ("(%p)\n", This); + FIXME ("(%p)\n", This); return E_NOTIMPL; } + static HRESULT WINAPI -IShellFolder_fnGetDefaultColumn (IShellFolder2 * iface, DWORD dwRes, ULONG * pSort, ULONG * pDisplay) +IShellFolder_fnGetDefaultColumn (IShellFolder2 * iface, DWORD dwRes, + ULONG * pSort, ULONG * pDisplay) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) - TRACE ("(%p)\n", This); + TRACE ("(%p)\n", This); if (pSort) - *pSort = 0; + *pSort = 0; if (pDisplay) - *pDisplay = 0; + *pDisplay = 0; return S_OK; } -static HRESULT WINAPI IShellFolder_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) + +static HRESULT WINAPI +IShellFolder_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, + DWORD * pcsFlags) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) - TRACE ("(%p)\n", This); + TRACE ("(%p)\n", This); if (!pcsFlags || iColumn >= GENERICSHELLVIEWCOLUMNS) - return E_INVALIDARG; + return E_INVALIDARG; *pcsFlags = GenericSFHeader[iColumn].pcsFlags; return S_OK; } + static HRESULT WINAPI -IShellFolder_fnGetDetailsEx (IShellFolder2 * iface, LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) +IShellFolder_fnGetDetailsEx (IShellFolder2 * iface, LPCITEMIDLIST pidl, + const SHCOLUMNID * pscid, VARIANT * pv) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) - FIXME ("(%p)\n", This); + FIXME ("(%p)\n", This); return E_NOTIMPL; } + static HRESULT WINAPI -IShellFolder_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) +IShellFolder_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, + UINT iColumn, SHELLDETAILS * psd) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) HRESULT hr = E_FAIL; @@ -820,41 +926,46 @@ IShellFolder_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iCo TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd); if (!psd || iColumn >= GENERICSHELLVIEWCOLUMNS) - return E_INVALIDARG; + return E_INVALIDARG; if (!pidl) { - /* the header titles */ - psd->fmt = GenericSFHeader[iColumn].fmt; - psd->cxChar = GenericSFHeader[iColumn].cxChar; - psd->str.uType = STRRET_CSTR; - LoadStringA (shell32_hInstance, GenericSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH); - return S_OK; + /* the header titles */ + psd->fmt = GenericSFHeader[iColumn].fmt; + psd->cxChar = GenericSFHeader[iColumn].cxChar; + psd->str.uType = STRRET_CSTR; + LoadStringA (shell32_hInstance, GenericSFHeader[iColumn].colnameid, + psd->str.u.cStr, MAX_PATH); + return S_OK; } else { - /* the data from the pidl */ - switch (iColumn) { - case 0: /* name */ - hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); - break; - case 1: /* size */ - _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 2: /* type */ - _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 3: /* date */ - _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 4: /* attributes */ - _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH); - break; - } - hr = S_OK; - psd->str.uType = STRRET_CSTR; + /* the data from the pidl */ + switch (iColumn) { + case 0: /* name */ + hr = IShellFolder_GetDisplayNameOf (iface, pidl, + SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); + break; + case 1: /* size */ + _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH); + break; + case 2: /* type */ + _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH); + break; + case 3: /* date */ + _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH); + break; + case 4: /* attributes */ + _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH); + break; + } + hr = S_OK; + psd->str.uType = STRRET_CSTR; } return hr; } -static HRESULT WINAPI IShellFolder_fnMapColumnToSCID (IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid) + +static HRESULT WINAPI +IShellFolder_fnMapColumnToSCID (IShellFolder2 * iface, UINT column, + SHCOLUMNID * pscid) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) FIXME ("(%p)\n", This); @@ -863,34 +974,35 @@ static HRESULT WINAPI IShellFolder_fnMapColumnToSCID (IShellFolder2 * iface, UIN static IShellFolder2Vtbl sfvt = { - IShellFolder_fnQueryInterface, - IShellFolder_fnAddRef, - IShellFolder_fnRelease, - IShellFolder_fnParseDisplayName, - IShellFolder_fnEnumObjects, - IShellFolder_fnBindToObject, - IShellFolder_fnBindToStorage, - IShellFolder_fnCompareIDs, - IShellFolder_fnCreateViewObject, - IShellFolder_fnGetAttributesOf, - IShellFolder_fnGetUIObjectOf, - IShellFolder_fnGetDisplayNameOf, - IShellFolder_fnSetNameOf, - /* ShellFolder2 */ - IShellFolder_fnGetDefaultSearchGUID, - IShellFolder_fnEnumSearches, - IShellFolder_fnGetDefaultColumn, - IShellFolder_fnGetDefaultColumnState, - IShellFolder_fnGetDetailsEx, - IShellFolder_fnGetDetailsOf, - IShellFolder_fnMapColumnToSCID + IShellFolder_fnQueryInterface, + IShellFolder_fnAddRef, + IShellFolder_fnRelease, + IShellFolder_fnParseDisplayName, + IShellFolder_fnEnumObjects, + IShellFolder_fnBindToObject, + IShellFolder_fnBindToStorage, + IShellFolder_fnCompareIDs, + IShellFolder_fnCreateViewObject, + IShellFolder_fnGetAttributesOf, + IShellFolder_fnGetUIObjectOf, + IShellFolder_fnGetDisplayNameOf, + IShellFolder_fnSetNameOf, + /* ShellFolder2 */ + IShellFolder_fnGetDefaultSearchGUID, + IShellFolder_fnEnumSearches, + IShellFolder_fnGetDefaultColumn, + IShellFolder_fnGetDefaultColumnState, + IShellFolder_fnGetDetailsEx, + IShellFolder_fnGetDetailsOf, + IShellFolder_fnMapColumnToSCID }; /**************************************************************************** * ISFHelper for IShellFolder implementation */ -static HRESULT WINAPI ISFHelper_fnQueryInterface (ISFHelper * iface, REFIID riid, LPVOID * ppvObj) +static HRESULT WINAPI +ISFHelper_fnQueryInterface (ISFHelper * iface, REFIID riid, LPVOID * ppvObj) { _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface); @@ -923,7 +1035,8 @@ static ULONG WINAPI ISFHelper_fnRelease (ISFHelper * iface) * creates a unique folder name */ -static HRESULT WINAPI ISFHelper_fnGetUniqueName (ISFHelper * iface, LPSTR lpName, UINT uLen) +static HRESULT WINAPI +ISFHelper_fnGetUniqueName (ISFHelper * iface, LPSTR lpName, UINT uLen) { _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface) IEnumIDList *penum; @@ -934,31 +1047,33 @@ static HRESULT WINAPI ISFHelper_fnGetUniqueName (ISFHelper * iface, LPSTR lpName TRACE ("(%p)(%s %u)\n", This, lpName, uLen); if (uLen < strlen (szNewFolder) + 4) - return E_POINTER; + return E_POINTER; strcpy (lpName, szNewFolder); hr = IShellFolder_fnEnumObjects (_IShellFolder2_ (This), 0, - SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penum); + SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penum); if (penum) { - LPITEMIDLIST pidl; - DWORD dwFetched; - int i = 1; + LPITEMIDLIST pidl; + DWORD dwFetched; + int i = 1; - next:IEnumIDList_Reset (penum); - while (S_OK == IEnumIDList_Next (penum, 1, &pidl, &dwFetched) && dwFetched) { - _ILSimpleGetText (pidl, szText, MAX_PATH); - if (0 == strcasecmp (szText, lpName)) { - sprintf (lpName, "%s %d", szNewFolder, i++); - if (i > 99) { - hr = E_FAIL; - break; - } - goto next; - } - } +next: + IEnumIDList_Reset (penum); + while (S_OK == IEnumIDList_Next (penum, 1, &pidl, &dwFetched) && + dwFetched) { + _ILSimpleGetText (pidl, szText, MAX_PATH); + if (0 == strcasecmp (szText, lpName)) { + sprintf (lpName, "%s %d", szNewFolder, i++); + if (i > 99) { + hr = E_FAIL; + break; + } + goto next; + } + } - IEnumIDList_Release (penum); + IEnumIDList_Release (penum); } return hr; } @@ -969,7 +1084,9 @@ static HRESULT WINAPI ISFHelper_fnGetUniqueName (ISFHelper * iface, LPSTR lpName * adds a new folder. */ -static HRESULT WINAPI ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCSTR lpName, LPITEMIDLIST * ppidlOut) +static HRESULT WINAPI +ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCSTR lpName, + LPITEMIDLIST * ppidlOut) { _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface) char lpstrNewDir[MAX_PATH]; @@ -983,22 +1100,24 @@ static HRESULT WINAPI ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCST bRes = CreateDirectoryA (lpstrNewDir, NULL); if (bRes) { - SHChangeNotify (SHCNE_MKDIR, SHCNF_PATHA, lpstrNewDir, NULL); + SHChangeNotify (SHCNE_MKDIR, SHCNF_PATHA, lpstrNewDir, NULL); - hres = S_OK; + hres = S_OK; - if (ppidlOut) - hres = _ILCreateFromPathA(lpstrNewDir, ppidlOut); + if (ppidlOut) + hres = _ILCreateFromPathA(lpstrNewDir, ppidlOut); } else { - char lpstrText[128 + MAX_PATH]; - char lpstrTempText[128]; - char lpstrCaption[256]; + char lpstrText[128 + MAX_PATH]; + char lpstrTempText[128]; + char lpstrCaption[256]; - /* Cannot Create folder because of permissions */ - LoadStringA (shell32_hInstance, IDS_CREATEFOLDER_DENIED, lpstrTempText, sizeof (lpstrTempText)); - LoadStringA (shell32_hInstance, IDS_CREATEFOLDER_CAPTION, lpstrCaption, sizeof (lpstrCaption)); - sprintf (lpstrText, lpstrTempText, lpstrNewDir); - MessageBoxA (hwnd, lpstrText, lpstrCaption, MB_OK | MB_ICONEXCLAMATION); + /* Cannot Create folder because of permissions */ + LoadStringA (shell32_hInstance, IDS_CREATEFOLDER_DENIED, lpstrTempText, + sizeof (lpstrTempText)); + LoadStringA (shell32_hInstance, IDS_CREATEFOLDER_CAPTION, lpstrCaption, + sizeof (lpstrCaption)); + sprintf (lpstrText, lpstrTempText, lpstrNewDir); + MessageBoxA (hwnd, lpstrText, lpstrCaption, MB_OK | MB_ICONEXCLAMATION); } return hres; @@ -1009,7 +1128,8 @@ static HRESULT WINAPI ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCST * * deletes items in folder */ -static HRESULT WINAPI ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPCITEMIDLIST * apidl) +static HRESULT WINAPI +ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPCITEMIDLIST * apidl) { _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface) UINT i; @@ -1020,42 +1140,42 @@ static HRESULT WINAPI ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPC /* deleting multiple items so give a slightly different warning */ if (cidl != 1) { - char tmp[8]; + char tmp[8]; - snprintf (tmp, sizeof (tmp), "%d", cidl); - if (!SHELL_ConfirmDialog(ASK_DELETE_MULTIPLE_ITEM, tmp)) - return E_FAIL; - bConfirm = FALSE; + snprintf (tmp, sizeof (tmp), "%d", cidl); + if (!SHELL_ConfirmDialog(ASK_DELETE_MULTIPLE_ITEM, tmp)) + return E_FAIL; + bConfirm = FALSE; } for (i = 0; i < cidl; i++) { - strcpy (szPath, This->sPathTarget); - PathAddBackslashA (szPath); - _ILSimpleGetText (apidl[i], szPath + strlen (szPath), MAX_PATH); + strcpy (szPath, This->sPathTarget); + PathAddBackslashA (szPath); + _ILSimpleGetText (apidl[i], szPath + strlen (szPath), MAX_PATH); - if (_ILIsFolder (apidl[i])) { - LPITEMIDLIST pidl; + if (_ILIsFolder (apidl[i])) { + LPITEMIDLIST pidl; - TRACE ("delete %s\n", szPath); - if (!SHELL_DeleteDirectoryA (szPath, bConfirm)) { - TRACE ("delete %s failed, bConfirm=%d\n", szPath, bConfirm); - return E_FAIL; - } - pidl = ILCombine (This->pidlRoot, apidl[i]); - SHChangeNotify (SHCNE_RMDIR, SHCNF_IDLIST, pidl, NULL); - SHFree (pidl); - } else if (_ILIsValue (apidl[i])) { - LPITEMIDLIST pidl; + TRACE ("delete %s\n", szPath); + if (!SHELL_DeleteDirectoryA (szPath, bConfirm)) { + TRACE ("delete %s failed, bConfirm=%d\n", szPath, bConfirm); + return E_FAIL; + } + pidl = ILCombine (This->pidlRoot, apidl[i]); + SHChangeNotify (SHCNE_RMDIR, SHCNF_IDLIST, pidl, NULL); + SHFree (pidl); + } else if (_ILIsValue (apidl[i])) { + LPITEMIDLIST pidl; - TRACE ("delete %s\n", szPath); - if (!SHELL_DeleteFileA (szPath, bConfirm)) { - TRACE ("delete %s failed, bConfirm=%d\n", szPath, bConfirm); - return E_FAIL; - } - pidl = ILCombine (This->pidlRoot, apidl[i]); - SHChangeNotify (SHCNE_DELETE, SHCNF_IDLIST, pidl, NULL); - SHFree (pidl); - } + TRACE ("delete %s\n", szPath); + if (!SHELL_DeleteFileA (szPath, bConfirm)) { + TRACE ("delete %s failed, bConfirm=%d\n", szPath, bConfirm); + return E_FAIL; + } + pidl = ILCombine (This->pidlRoot, apidl[i]); + SHChangeNotify (SHCNE_DELETE, SHCNF_IDLIST, pidl, NULL); + SHFree (pidl); + } } return S_OK; @@ -1067,7 +1187,8 @@ static HRESULT WINAPI ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPC * copies items to this folder */ static HRESULT WINAPI -ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl, LPCITEMIDLIST * apidl) +ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl, + LPCITEMIDLIST * apidl) { UINT i; IPersistFolder2 *ppf2 = NULL; @@ -1078,44 +1199,49 @@ ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl, LPC TRACE ("(%p)->(%p,%u,%p)\n", This, pSFFrom, cidl, apidl); - IShellFolder_QueryInterface (pSFFrom, &IID_IPersistFolder2, (LPVOID *) & ppf2); + IShellFolder_QueryInterface (pSFFrom, &IID_IPersistFolder2, + (LPVOID *) & ppf2); if (ppf2) { - LPITEMIDLIST pidl; + LPITEMIDLIST pidl; - if (SUCCEEDED (IPersistFolder2_GetCurFolder (ppf2, &pidl))) { - for (i = 0; i < cidl; i++) { - SHGetPathFromIDListA (pidl, szSrcPath); - PathAddBackslashA (szSrcPath); - _ILSimpleGetText (apidl[i], szSrcPath + strlen (szSrcPath), MAX_PATH); + if (SUCCEEDED (IPersistFolder2_GetCurFolder (ppf2, &pidl))) { + for (i = 0; i < cidl; i++) { + SHGetPathFromIDListA (pidl, szSrcPath); + PathAddBackslashA (szSrcPath); + _ILSimpleGetText (apidl[i], szSrcPath + strlen (szSrcPath), + MAX_PATH); - strcpy (szDstPath, This->sPathTarget); - PathAddBackslashA (szDstPath); - _ILSimpleGetText (apidl[i], szDstPath + strlen (szDstPath), MAX_PATH); - MESSAGE ("would copy %s to %s\n", szSrcPath, szDstPath); - } - SHFree (pidl); - } - IPersistFolder2_Release (ppf2); + strcpy (szDstPath, This->sPathTarget); + PathAddBackslashA (szDstPath); + _ILSimpleGetText (apidl[i], szDstPath + strlen (szDstPath), + MAX_PATH); + MESSAGE ("would copy %s to %s\n", szSrcPath, szDstPath); + } + SHFree (pidl); + } + IPersistFolder2_Release (ppf2); } return S_OK; } static ISFHelperVtbl shvt = { - ISFHelper_fnQueryInterface, - ISFHelper_fnAddRef, - ISFHelper_fnRelease, - ISFHelper_fnGetUniqueName, - ISFHelper_fnAddFolder, - ISFHelper_fnDeleteItems, - ISFHelper_fnCopyItems + ISFHelper_fnQueryInterface, + ISFHelper_fnAddRef, + ISFHelper_fnRelease, + ISFHelper_fnGetUniqueName, + ISFHelper_fnAddFolder, + ISFHelper_fnDeleteItems, + ISFHelper_fnCopyItems }; /************************************************************************ - * IFSFldr_PersistFolder3_QueryInterface + * IFSFldr_PersistFolder3_QueryInterface * */ -static HRESULT WINAPI IFSFldr_PersistFolder3_QueryInterface (IPersistFolder3 * iface, REFIID iid, LPVOID * ppvObj) +static HRESULT WINAPI +IFSFldr_PersistFolder3_QueryInterface (IPersistFolder3 * iface, REFIID iid, + LPVOID * ppvObj) { _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface); @@ -1125,10 +1251,11 @@ static HRESULT WINAPI IFSFldr_PersistFolder3_QueryInterface (IPersistFolder3 * i } /************************************************************************ - * IFSFldr_PersistFolder3_AddRef + * IFSFldr_PersistFolder3_AddRef * */ -static ULONG WINAPI IFSFldr_PersistFolder3_AddRef (IPersistFolder3 * iface) +static ULONG WINAPI +IFSFldr_PersistFolder3_AddRef (IPersistFolder3 * iface) { _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface); @@ -1138,10 +1265,11 @@ static ULONG WINAPI IFSFldr_PersistFolder3_AddRef (IPersistFolder3 * iface) } /************************************************************************ - * IFSFldr_PersistFolder3_Release + * IFSFldr_PersistFolder3_Release * */ -static ULONG WINAPI IFSFldr_PersistFolder3_Release (IPersistFolder3 * iface) +static ULONG WINAPI +IFSFldr_PersistFolder3_Release (IPersistFolder3 * iface) { _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface); @@ -1151,28 +1279,30 @@ static ULONG WINAPI IFSFldr_PersistFolder3_Release (IPersistFolder3 * iface) } /************************************************************************ - * IFSFldr_PersistFolder3_GetClassID + * IFSFldr_PersistFolder3_GetClassID */ -static HRESULT WINAPI IFSFldr_PersistFolder3_GetClassID (IPersistFolder3 * iface, CLSID * lpClassId) +static HRESULT WINAPI +IFSFldr_PersistFolder3_GetClassID (IPersistFolder3 * iface, CLSID * lpClassId) { _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface); TRACE ("(%p)\n", This); if (!lpClassId) - return E_POINTER; + return E_POINTER; *lpClassId = *This->pclsid; return S_OK; } /************************************************************************ - * IFSFldr_PersistFolder3_Initialize + * IFSFldr_PersistFolder3_Initialize * * NOTES * sPathTarget is not set. Don't know how to handle in a non rooted environment. */ -static HRESULT WINAPI IFSFldr_PersistFolder3_Initialize (IPersistFolder3 * iface, LPCITEMIDLIST pidl) +static HRESULT WINAPI +IFSFldr_PersistFolder3_Initialize (IPersistFolder3 * iface, LPCITEMIDLIST pidl) { char sTemp[MAX_PATH]; @@ -1181,16 +1311,16 @@ static HRESULT WINAPI IFSFldr_PersistFolder3_Initialize (IPersistFolder3 * iface TRACE ("(%p)->(%p)\n", This, pidl); if (This->pidlRoot) - SHFree (This->pidlRoot); /* free the old pidl */ - This->pidlRoot = ILClone (pidl); /* set my pidl */ + SHFree (This->pidlRoot); /* free the old pidl */ + This->pidlRoot = ILClone (pidl); /* set my pidl */ if (This->sPathTarget) - SHFree (This->sPathTarget); + SHFree (This->sPathTarget); /* set my path */ if (SHGetPathFromIDListA (pidl, sTemp)) { - This->sPathTarget = SHAlloc (strlen (sTemp) + 1); - strcpy (This->sPathTarget, sTemp); + This->sPathTarget = SHAlloc (strlen (sTemp) + 1); + strcpy (This->sPathTarget, sTemp); } TRACE ("--(%p)->(%s)\n", This, This->sPathTarget); @@ -1198,9 +1328,11 @@ static HRESULT WINAPI IFSFldr_PersistFolder3_Initialize (IPersistFolder3 * iface } /************************************************************************** - * IFSFldr_PersistFolder3_GetCurFolder + * IFSFldr_PersistFolder3_GetCurFolder */ -static HRESULT WINAPI IFSFldr_PersistFolder3_fnGetCurFolder (IPersistFolder3 * iface, LPITEMIDLIST * pidl) +static HRESULT WINAPI +IFSFldr_PersistFolder3_fnGetCurFolder (IPersistFolder3 * iface, + LPITEMIDLIST * pidl) { _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface); @@ -1212,13 +1344,14 @@ static HRESULT WINAPI IFSFldr_PersistFolder3_fnGetCurFolder (IPersistFolder3 * i } /************************************************************************** - * IFSFldr_PersistFolder3_InitializeEx + * IFSFldr_PersistFolder3_InitializeEx * - * FIXME: errorhandling + * FIXME: error handling */ static HRESULT WINAPI IFSFldr_PersistFolder3_InitializeEx (IPersistFolder3 * iface, - IBindCtx * pbc, LPCITEMIDLIST pidlRoot, const PERSIST_FOLDER_TARGET_INFO * ppfti) + IBindCtx * pbc, LPCITEMIDLIST pidlRoot, + const PERSIST_FOLDER_TARGET_INFO * ppfti) { char sTemp[MAX_PATH]; @@ -1226,18 +1359,19 @@ IFSFldr_PersistFolder3_InitializeEx (IPersistFolder3 * iface, TRACE ("(%p)->(%p,%p,%p)\n", This, pbc, pidlRoot, ppfti); if (ppfti) - TRACE ("--%p %s %s 0x%08lx 0x%08x\n", - ppfti->pidlTargetFolder, debugstr_w (ppfti->szTargetParsingName), - debugstr_w (ppfti->szNetworkProvider), ppfti->dwAttributes, ppfti->csidl); + TRACE ("--%p %s %s 0x%08lx 0x%08x\n", + ppfti->pidlTargetFolder, debugstr_w (ppfti->szTargetParsingName), + debugstr_w (ppfti->szNetworkProvider), ppfti->dwAttributes, + ppfti->csidl); pdump (pidlRoot); if (ppfti && ppfti->pidlTargetFolder) - pdump (ppfti->pidlTargetFolder); + pdump (ppfti->pidlTargetFolder); if (This->pidlRoot) - __SHFreeAndNil (&This->pidlRoot); /* free the old */ + __SHFreeAndNil (&This->pidlRoot); /* free the old */ if (This->sPathTarget) - __SHFreeAndNil (&This->sPathTarget); + __SHFreeAndNil (&This->sPathTarget); /* * Root path and pidl @@ -1245,20 +1379,22 @@ IFSFldr_PersistFolder3_InitializeEx (IPersistFolder3 * iface, This->pidlRoot = ILClone (pidlRoot); /* - * the target folder is spezified in csidl OR pidlTargetFolder OR szTargetParsingName + * the target folder is spezified in csidl OR pidlTargetFolder OR + * szTargetParsingName */ if (ppfti) { - if (ppfti->csidl != -1) { - if (SHGetSpecialFolderPathA (0, sTemp, ppfti->csidl, ppfti->csidl & CSIDL_FLAG_CREATE)) { - __SHCloneStrA (&This->sPathTarget, sTemp); - } - } else if (ppfti->szTargetParsingName[0]) { - __SHCloneStrWtoA (&This->sPathTarget, ppfti->szTargetParsingName); - } else if (ppfti->pidlTargetFolder) { - if (SHGetPathFromIDListA (ppfti->pidlTargetFolder, sTemp)) { - __SHCloneStrA (&This->sPathTarget, sTemp); - } - } + if (ppfti->csidl != -1) { + if (SHGetSpecialFolderPathA (0, sTemp, ppfti->csidl, + ppfti->csidl & CSIDL_FLAG_CREATE)) { + __SHCloneStrA (&This->sPathTarget, sTemp); + } + } else if (ppfti->szTargetParsingName[0]) { + __SHCloneStrWtoA (&This->sPathTarget, ppfti->szTargetParsingName); + } else if (ppfti->pidlTargetFolder) { + if (SHGetPathFromIDListA (ppfti->pidlTargetFolder, sTemp)) { + __SHCloneStrA (&This->sPathTarget, sTemp); + } + } } TRACE ("--(%p)->(target=%s)\n", This, debugstr_a (This->sPathTarget)); @@ -1267,7 +1403,8 @@ IFSFldr_PersistFolder3_InitializeEx (IPersistFolder3 * iface, } static HRESULT WINAPI -IFSFldr_PersistFolder3_GetFolderTargetInfo (IPersistFolder3 * iface, PERSIST_FOLDER_TARGET_INFO * ppfti) +IFSFldr_PersistFolder3_GetFolderTargetInfo (IPersistFolder3 * iface, + PERSIST_FOLDER_TARGET_INFO * ppfti) { _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface); FIXME ("(%p)->(%p)\n", This, ppfti); @@ -1277,20 +1414,22 @@ IFSFldr_PersistFolder3_GetFolderTargetInfo (IPersistFolder3 * iface, PERSIST_FOL static IPersistFolder3Vtbl vt_FSFldr_PersistFolder3 = { - IFSFldr_PersistFolder3_QueryInterface, - IFSFldr_PersistFolder3_AddRef, - IFSFldr_PersistFolder3_Release, - IFSFldr_PersistFolder3_GetClassID, - IFSFldr_PersistFolder3_Initialize, - IFSFldr_PersistFolder3_fnGetCurFolder, - IFSFldr_PersistFolder3_InitializeEx, - IFSFldr_PersistFolder3_GetFolderTargetInfo + IFSFldr_PersistFolder3_QueryInterface, + IFSFldr_PersistFolder3_AddRef, + IFSFldr_PersistFolder3_Release, + IFSFldr_PersistFolder3_GetClassID, + IFSFldr_PersistFolder3_Initialize, + IFSFldr_PersistFolder3_fnGetCurFolder, + IFSFldr_PersistFolder3_InitializeEx, + IFSFldr_PersistFolder3_GetFolderTargetInfo }; /**************************************************************************** * ISFDropTarget implementation */ -static BOOL ISFDropTarget_QueryDrop (IDropTarget * iface, DWORD dwKeyState, LPDWORD pdwEffect) +static BOOL +ISFDropTarget_QueryDrop (IDropTarget * iface, DWORD dwKeyState, + LPDWORD pdwEffect) { DWORD dwEffect = *pdwEffect; @@ -1298,18 +1437,19 @@ static BOOL ISFDropTarget_QueryDrop (IDropTarget * iface, DWORD dwKeyState, LPDW *pdwEffect = DROPEFFECT_NONE; - if (This->fAcceptFmt) { /* Does our interpretation of the keystate ... */ - *pdwEffect = KeyStateToDropEffect (dwKeyState); + if (This->fAcceptFmt) { /* Does our interpretation of the keystate ... */ + *pdwEffect = KeyStateToDropEffect (dwKeyState); - /* ... matches the desired effect ? */ - if (dwEffect & *pdwEffect) { - return TRUE; - } + /* ... matches the desired effect ? */ + if (dwEffect & *pdwEffect) { + return TRUE; + } } return FALSE; } -static HRESULT WINAPI ISFDropTarget_QueryInterface (IDropTarget * iface, REFIID riid, LPVOID * ppvObj) +static HRESULT WINAPI +ISFDropTarget_QueryInterface (IDropTarget * iface, REFIID riid, LPVOID * ppvObj) { _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface); @@ -1337,7 +1477,8 @@ static ULONG WINAPI ISFDropTarget_Release (IDropTarget * iface) } static HRESULT WINAPI -ISFDropTarget_DragEnter (IDropTarget * iface, IDataObject * pDataObject, DWORD dwKeyState, POINTL pt, DWORD * pdwEffect) +ISFDropTarget_DragEnter (IDropTarget * iface, IDataObject * pDataObject, + DWORD dwKeyState, POINTL pt, DWORD * pdwEffect) { FORMATETC fmt; @@ -1347,21 +1488,24 @@ ISFDropTarget_DragEnter (IDropTarget * iface, IDataObject * pDataObject, DWORD d InitFormatEtc (fmt, This->cfShellIDList, TYMED_HGLOBAL); - This->fAcceptFmt = (S_OK == IDataObject_QueryGetData (pDataObject, &fmt)) ? TRUE : FALSE; + This->fAcceptFmt = (S_OK == IDataObject_QueryGetData (pDataObject, &fmt)) ? + TRUE : FALSE; ISFDropTarget_QueryDrop (iface, dwKeyState, pdwEffect); return S_OK; } -static HRESULT WINAPI ISFDropTarget_DragOver (IDropTarget * iface, DWORD dwKeyState, POINTL pt, DWORD * pdwEffect) +static HRESULT WINAPI +ISFDropTarget_DragOver (IDropTarget * iface, DWORD dwKeyState, POINTL pt, + DWORD * pdwEffect) { _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface); TRACE ("(%p)\n", This); if (!pdwEffect) - return E_INVALIDARG; + return E_INVALIDARG; ISFDropTarget_QueryDrop (iface, dwKeyState, pdwEffect); @@ -1380,7 +1524,8 @@ static HRESULT WINAPI ISFDropTarget_DragLeave (IDropTarget * iface) } static HRESULT WINAPI -ISFDropTarget_Drop (IDropTarget * iface, IDataObject * pDataObject, DWORD dwKeyState, POINTL pt, DWORD * pdwEffect) +ISFDropTarget_Drop (IDropTarget * iface, IDataObject * pDataObject, + DWORD dwKeyState, POINTL pt, DWORD * pdwEffect) { _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface); @@ -1390,11 +1535,11 @@ ISFDropTarget_Drop (IDropTarget * iface, IDataObject * pDataObject, DWORD dwKeyS } static struct IDropTargetVtbl dtvt = { - ISFDropTarget_QueryInterface, - ISFDropTarget_AddRef, - ISFDropTarget_Release, - ISFDropTarget_DragEnter, - ISFDropTarget_DragOver, - ISFDropTarget_DragLeave, - ISFDropTarget_Drop + ISFDropTarget_QueryInterface, + ISFDropTarget_AddRef, + ISFDropTarget_Release, + ISFDropTarget_DragEnter, + ISFDropTarget_DragOver, + ISFDropTarget_DragLeave, + ISFDropTarget_Drop }; diff --git a/reactos/lib/shell32/shfldr_mycomp.c b/reactos/lib/shell32/shfldr_mycomp.c index cacfcfbd68c..ef6a23eb206 100644 --- a/reactos/lib/shell32/shfldr_mycomp.c +++ b/reactos/lib/shell32/shfldr_mycomp.c @@ -1,9 +1,8 @@ - /* - * Virtual Workplace folder + * Virtual Workplace folder * - * Copyright 1997 Marcus Meissner - * Copyright 1998, 1999, 2002 Juergen Schmied + * Copyright 1997 Marcus Meissner + * Copyright 1998, 1999, 2002 Juergen Schmied * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -61,8 +60,8 @@ typedef struct { IPersistFolder2Vtbl *lpVtblPersistFolder2; /* both paths are parsible from the desktop */ - LPITEMIDLIST pidlRoot; /* absolute pidl */ - int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */ + LPITEMIDLIST pidlRoot; /* absolute pidl */ + int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */ } IGenericSFImpl; static struct IShellFolder2Vtbl vt_ShellFolder2; @@ -74,13 +73,13 @@ static struct IPersistFolder2Vtbl vt_PersistFolder2; /* converts This to a interface pointer */ -#define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) -#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) -#define _IShellFolder2_(This) (IShellFolder2*)&(This->lpVtbl) +#define _IUnknown_(This) (IUnknown*)&(This->lpVtbl) +#define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl) +#define _IShellFolder2_(This) (IShellFolder2*)&(This->lpVtbl) -#define _IPersist_(This) (IPersist*)&(This->lpVtblPersistFolder2) -#define _IPersistFolder_(This) (IPersistFolder*)&(This->lpVtblPersistFolder2) -#define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2) +#define _IPersist_(This) (IPersist*)&(This->lpVtblPersistFolder2) +#define _IPersistFolder_(This) (IPersistFolder*)&(This->lpVtblPersistFolder2) +#define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2) /*********************************************************************** * IShellFolder [MyComputer] implementation @@ -96,7 +95,7 @@ static shvheader MyComputerSFHeader[] = { #define MYCOMPUTERSHELLVIEWCOLUMNS 4 /************************************************************************** -* ISF_MyComputer_Constructor +* ISF_MyComputer_Constructor */ HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) { @@ -105,22 +104,23 @@ HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LP TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid)); if (!ppv) - return E_POINTER; + return E_POINTER; if (pUnkOuter) - return CLASS_E_NOAGGREGATION; + return CLASS_E_NOAGGREGATION; - sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl)); + sf = LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl)); if (!sf) - return E_OUTOFMEMORY; + return E_OUTOFMEMORY; sf->ref = 0; sf->lpVtbl = &vt_ShellFolder2; sf->lpVtblPersistFolder2 = &vt_PersistFolder2; - sf->pidlRoot = _ILCreateMyComputer (); /* my qualified pidl */ + sf->pidlRoot = _ILCreateMyComputer (); /* my qualified pidl */ - if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) { - IUnknown_Release (_IUnknown_ (sf)); - return E_NOINTERFACE; + if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) + { + IUnknown_Release (_IUnknown_ (sf)); + return E_NOINTERFACE; } TRACE ("--(%p)\n", sf); @@ -128,11 +128,12 @@ HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LP } /************************************************************************** - * ISF_MyComputer_fnQueryInterface + * ISF_MyComputer_fnQueryInterface * * NOTES supports not IPersist/IPersistFolder */ -static HRESULT WINAPI ISF_MyComputer_fnQueryInterface (IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj) +static HRESULT WINAPI ISF_MyComputer_fnQueryInterface (IShellFolder2 *iface, + REFIID riid, LPVOID *ppvObj) { IGenericSFImpl *This = (IGenericSFImpl *)iface; @@ -141,17 +142,23 @@ static HRESULT WINAPI ISF_MyComputer_fnQueryInterface (IShellFolder2 * iface, RE *ppvObj = NULL; if (IsEqualIID (riid, &IID_IUnknown) || - IsEqualIID (riid, &IID_IShellFolder) || IsEqualIID (riid, &IID_IShellFolder2)) { - *ppvObj = This; - } else if (IsEqualIID (riid, &IID_IPersist) || - IsEqualIID (riid, &IID_IPersistFolder) || IsEqualIID (riid, &IID_IPersistFolder2)) { - *ppvObj = _IPersistFolder2_ (This); + IsEqualIID (riid, &IID_IShellFolder) || + IsEqualIID (riid, &IID_IShellFolder2)) + { + *ppvObj = This; + } + else if (IsEqualIID (riid, &IID_IPersist) || + IsEqualIID (riid, &IID_IPersistFolder) || + IsEqualIID (riid, &IID_IPersistFolder2)) + { + *ppvObj = _IPersistFolder2_ (This); } - if (*ppvObj) { - IUnknown_AddRef ((IUnknown *) (*ppvObj)); - TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); - return S_OK; + if (*ppvObj) + { + IUnknown_AddRef ((IUnknown *) (*ppvObj)); + TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj); + return S_OK; } TRACE ("-- Interface: E_NOINTERFACE\n"); return E_NOINTERFACE; @@ -174,7 +181,8 @@ static ULONG WINAPI ISF_MyComputer_fnRelease (IShellFolder2 * iface) TRACE ("(%p)->(count=%lu)\n", This, refCount + 1); - if (!refCount) { + if (!refCount) + { TRACE ("-- destroying IShellFolder(%p)\n", This); if (This->pidlRoot) SHFree (This->pidlRoot); @@ -184,51 +192,56 @@ static ULONG WINAPI ISF_MyComputer_fnRelease (IShellFolder2 * iface) } /************************************************************************** -* ISF_MyComputer_fnParseDisplayName +* ISF_MyComputer_fnParseDisplayName */ -static HRESULT WINAPI -ISF_MyComputer_fnParseDisplayName (IShellFolder2 * iface, - HWND hwndOwner, - LPBC pbc, - LPOLESTR lpszDisplayName, - DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) +static HRESULT WINAPI ISF_MyComputer_fnParseDisplayName (IShellFolder2 *iface, + HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, + DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = E_INVALIDARG; LPCWSTR szNext = NULL; WCHAR szElement[MAX_PATH]; LPITEMIDLIST pidlTemp = NULL; CLSID clsid; - TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", - This, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes); + TRACE("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", This, + hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), + pchEaten, ppidl, pdwAttributes); *ppidl = 0; if (pchEaten) - *pchEaten = 0; /* strange but like the original */ + *pchEaten = 0; /* strange but like the original */ /* handle CLSID paths */ - if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') { - szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); - TRACE ("-- element: %s\n", debugstr_w (szElement)); - SHCLSIDFromStringW (szElement + 2, &clsid); - pidlTemp = _ILCreateGuid (PT_GUID, &clsid); + if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') + { + szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); + TRACE ("-- element: %s\n", debugstr_w (szElement)); + SHCLSIDFromStringW (szElement + 2, &clsid); + pidlTemp = _ILCreateGuid (PT_GUID, &clsid); } /* do we have an absolute path name ? */ - else if (PathGetDriveNumberW (lpszDisplayName) >= 0 && lpszDisplayName[2] == (WCHAR) '\\') { - szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); - szElement[0] = toupper(szElement[0]); /* make drive letter uppercase to enable PIDL comparison */ - pidlTemp = _ILCreateDrive (szElement); + else if (PathGetDriveNumberW (lpszDisplayName) >= 0 && + lpszDisplayName[2] == (WCHAR) '\\') + { + szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH); + /* make drive letter uppercase to enable PIDL comparison */ + szElement[0] = toupper(szElement[0]); + pidlTemp = _ILCreateDrive (szElement); } - if (szNext && *szNext) { - hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); - } else { - if (pdwAttributes && *pdwAttributes) { - SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes); - } - hr = S_OK; + if (szNext && *szNext) + { + hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, + (LPOLESTR) szNext, pchEaten, pdwAttributes); + } + else + { + if (pdwAttributes && *pdwAttributes) + SHELL32_GetItemAttributes (_IShellFolder_ (This), + pidlTemp, pdwAttributes); + hr = S_OK; } *ppidl = pidlTemp; @@ -241,14 +254,20 @@ ISF_MyComputer_fnParseDisplayName (IShellFolder2 * iface, /************************************************************************** * CreateMyCompEnumList() */ +static const WCHAR MyComputer_NameSpaceW[] = { 'S','O','F','T','W','A','R','E', + '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', + 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l', + 'o','r','e','r','\\','M','y','C','o','m','p','u','t','e','r','\\','N','a','m', + 'e','s','p','a','c','e','\0' }; + static BOOL CreateMyCompEnumList(IEnumIDList *list, DWORD dwFlags) { BOOL ret = TRUE; TRACE("(%p)->(flags=0x%08lx) \n",list,dwFlags); - /*enumerate the folders*/ - if(dwFlags & SHCONTF_FOLDERS) + /* enumerate the folders */ + if (dwFlags & SHCONTF_FOLDERS) { WCHAR wszDriveName[] = {'A', ':', '\\', '\0'}; DWORD dwDrivemap = GetLogicalDrives(); @@ -263,27 +282,27 @@ static BOOL CreateMyCompEnumList(IEnumIDList *list, DWORD dwFlags) } TRACE("-- (%p)-> enumerate (mycomputer shell extensions)\n",list); - if (ret && !RegOpenKeyExA(HKEY_LOCAL_MACHINE, - "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\explorer\\mycomputer\\NameSpace", + if (ret && !RegOpenKeyExW(HKEY_LOCAL_MACHINE, MyComputer_NameSpaceW, 0, KEY_READ, &hkey)) { - char iid[50]; + WCHAR iid[50]; int i=0; while (ret) { - DWORD size = sizeof (iid); - LONG apiRet = RegEnumKeyExA(hkey, i, iid, &size, 0, NULL, NULL, - NULL); + DWORD size; + LONG r; - if (ERROR_SUCCESS == apiRet) + size = sizeof(iid) / sizeof(iid[0]); + r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL); + if (ERROR_SUCCESS == r) { /* FIXME: shell extensions, shouldn't the type be * PT_SHELLEXT? */ - ret = AddToEnumList(list, _ILCreateGuidFromStrA(iid)); + ret = AddToEnumList(list, _ILCreateGuidFromStrW(iid)); i++; } - else if (ERROR_NO_MORE_ITEMS == apiRet) + else if (ERROR_NO_MORE_ITEMS == r) break; else ret = FALSE; @@ -295,14 +314,15 @@ static BOOL CreateMyCompEnumList(IEnumIDList *list, DWORD dwFlags) } /************************************************************************** -* ISF_MyComputer_fnEnumObjects +* ISF_MyComputer_fnEnumObjects */ -static HRESULT WINAPI -ISF_MyComputer_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList) +static HRESULT WINAPI ISF_MyComputer_fnEnumObjects (IShellFolder2 *iface, + HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList); + TRACE("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, + hwndOwner, dwFlags, ppEnumIDList); *ppEnumIDList = IEnumIDList_Constructor(); if (*ppEnumIDList) @@ -314,43 +334,42 @@ ISF_MyComputer_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFla } /************************************************************************** -* ISF_MyComputer_fnBindToObject +* ISF_MyComputer_fnBindToObject */ -static HRESULT WINAPI -ISF_MyComputer_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl, - LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) +static HRESULT WINAPI ISF_MyComputer_fnBindToObject (IShellFolder2 *iface, + LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); + TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This, + pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut); } /************************************************************************** -* ISF_MyComputer_fnBindToStorage +* ISF_MyComputer_fnBindToStorage */ -static HRESULT WINAPI -ISF_MyComputer_fnBindToStorage (IShellFolder2 * iface, - LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) +static HRESULT WINAPI ISF_MyComputer_fnBindToStorage (IShellFolder2 * iface, + LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); + FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, + pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); *ppvOut = NULL; return E_NOTIMPL; } /************************************************************************** -* ISF_MyComputer_fnCompareIDs +* ISF_MyComputer_fnCompareIDs */ -static HRESULT WINAPI -ISF_MyComputer_fnCompareIDs (IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) +static HRESULT WINAPI ISF_MyComputer_fnCompareIDs (IShellFolder2 *iface, + LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - int nReturn; TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2); @@ -360,34 +379,41 @@ ISF_MyComputer_fnCompareIDs (IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST } /************************************************************************** -* ISF_MyComputer_fnCreateViewObject +* ISF_MyComputer_fnCreateViewObject */ -static HRESULT WINAPI -ISF_MyComputer_fnCreateViewObject (IShellFolder2 * iface, HWND hwndOwner, REFIID riid, LPVOID * ppvOut) +static HRESULT WINAPI ISF_MyComputer_fnCreateViewObject (IShellFolder2 *iface, + HWND hwndOwner, REFIID riid, LPVOID * ppvOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - LPSHELLVIEW pShellView; HRESULT hr = E_INVALIDARG; - TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid (riid), ppvOut); + TRACE("(%p)->(hwnd=%p,%s,%p)\n", This, + hwndOwner, shdebugstr_guid (riid), ppvOut); - if (ppvOut) { - *ppvOut = NULL; + if (!ppvOut) + return hr; - if (IsEqualIID (riid, &IID_IDropTarget)) { - WARN ("IDropTarget not implemented\n"); - hr = E_NOTIMPL; - } else if (IsEqualIID (riid, &IID_IContextMenu)) { - WARN ("IContextMenu not implemented\n"); - hr = E_NOTIMPL; - } else if (IsEqualIID (riid, &IID_IShellView)) { - pShellView = IShellView_Constructor ((IShellFolder *) iface); - if (pShellView) { - hr = IShellView_QueryInterface (pShellView, riid, ppvOut); - IShellView_Release (pShellView); - } - } + *ppvOut = NULL; + + if (IsEqualIID (riid, &IID_IDropTarget)) + { + WARN ("IDropTarget not implemented\n"); + hr = E_NOTIMPL; + } + else if (IsEqualIID (riid, &IID_IContextMenu)) + { + WARN ("IContextMenu not implemented\n"); + hr = E_NOTIMPL; + } + else if (IsEqualIID (riid, &IID_IShellView)) + { + pShellView = IShellView_Constructor ((IShellFolder *) iface); + if (pShellView) + { + hr = IShellView_QueryInterface (pShellView, riid, ppvOut); + IShellView_Release (pShellView); + } } TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut); return hr; @@ -396,26 +422,26 @@ ISF_MyComputer_fnCreateViewObject (IShellFolder2 * iface, HWND hwndOwner, REFIID /************************************************************************** * ISF_MyComputer_fnGetAttributesOf */ -static HRESULT WINAPI -ISF_MyComputer_fnGetAttributesOf (IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) +static HRESULT WINAPI ISF_MyComputer_fnGetAttributesOf (IShellFolder2 * iface, + UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - HRESULT hr = S_OK; TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, *rgfInOut); - if ((!cidl) || (!apidl) || (!rgfInOut)) - return E_INVALIDARG; + if (!cidl || !apidl || !rgfInOut) + return E_INVALIDARG; if (*rgfInOut == 0) - *rgfInOut = ~0; + *rgfInOut = ~0; - while (cidl > 0 && *apidl) { - pdump (*apidl); - SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); - apidl++; - cidl--; + while (cidl > 0 && *apidl) + { + pdump (*apidl); + SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); + apidl++; + cidl--; } TRACE ("-- result=0x%08lx\n", *rgfInOut); @@ -423,21 +449,20 @@ ISF_MyComputer_fnGetAttributesOf (IShellFolder2 * iface, UINT cidl, LPCITEMIDLIS } /************************************************************************** -* ISF_MyComputer_fnGetUIObjectOf +* ISF_MyComputer_fnGetUIObjectOf * * PARAMETERS -* HWND hwndOwner, //[in ] Parent window for any output -* UINT cidl, //[in ] array size -* LPCITEMIDLIST* apidl, //[in ] simple pidl array -* REFIID riid, //[in ] Requested Interface -* UINT* prgfInOut, //[ ] reserved -* LPVOID* ppvObject) //[out] Resulting Interface +* hwndOwner [in] Parent window for any output +* cidl [in] array size +* apidl [in] simple pidl array +* riid [in] Requested Interface +* prgfInOut [ ] reserved +* ppvObject [out] Resulting Interface * */ -static HRESULT WINAPI -ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface, - HWND hwndOwner, - UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) +static HRESULT WINAPI ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface, + HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, + UINT * prgfInOut, LPVOID * ppvOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; @@ -445,57 +470,72 @@ ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface, IUnknown *pObj = NULL; HRESULT hr = E_INVALIDARG; - TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", - This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); + TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", This, + hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut); - if (ppvOut) { - *ppvOut = NULL; + if (!ppvOut) + return hr; - if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) { - pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl); - hr = S_OK; - } else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) { - pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl); - hr = S_OK; - } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) { - pidl = ILCombine (This->pidlRoot, apidl[0]); - pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl); - SHFree (pidl); - hr = S_OK; - } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) { - hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj); - } else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA)) - && (cidl == 1)) { - pidl = ILCombine (This->pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj); - SHFree (pidl); - } else { - hr = E_NOINTERFACE; - } + *ppvOut = NULL; - if (SUCCEEDED(hr) && !pObj) - hr = E_OUTOFMEMORY; - - *ppvOut = pObj; + if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) + { + pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, + This->pidlRoot, apidl, cidl); + hr = S_OK; } + else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) + { + pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, + This->pidlRoot, apidl, cidl); + hr = S_OK; + } + else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) + { + pidl = ILCombine (This->pidlRoot, apidl[0]); + pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl); + SHFree (pidl); + hr = S_OK; + } + else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) + { + pidl = ILCombine (This->pidlRoot, apidl[0]); + pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl); + SHFree (pidl); + hr = S_OK; + } + else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) + { + hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, + (LPVOID *) &pObj); + } + else if ((IsEqualIID(riid,&IID_IShellLinkW) || + IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1)) + { + pidl = ILCombine (This->pidlRoot, apidl[0]); + hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*) &pObj); + SHFree (pidl); + } + else + hr = E_NOINTERFACE; + + if (SUCCEEDED(hr) && !pObj) + hr = E_OUTOFMEMORY; + + *ppvOut = pObj; TRACE ("(%p)->hr=0x%08lx\n", This, hr); return hr; } /************************************************************************** -* ISF_MyComputer_fnGetDisplayNameOf +* ISF_MyComputer_fnGetDisplayNameOf */ -static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) +static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface, + LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - char szPath[MAX_PATH], - szDrive[18]; + char szPath[MAX_PATH], szDrive[18]; int len = 0; BOOL bSimplePidl; HRESULT hr = S_OK; @@ -504,98 +544,138 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 * iface, pdump (pidl); if (!strRet) - return E_INVALIDARG; + return E_INVALIDARG; szPath[0] = 0x00; szDrive[0] = 0x00; bSimplePidl = _ILIsPidlSimple (pidl); - if (!pidl->mkid.cb) { - /* parsing name like ::{...} */ - lstrcpyA (szPath, "::"); - SHELL32_GUIDToStringA(&CLSID_MyComputer, &szPath[2]); - } else if (_ILIsSpecialFolder (pidl)) { - /* take names of special folders only if its only this folder */ - if (bSimplePidl) { - GUID const *clsid; + if (!pidl->mkid.cb) + { + /* parsing name like ::{...} */ + lstrcpyA (szPath, "::"); + SHELL32_GUIDToStringA(&CLSID_MyComputer, &szPath[2]); + } + else if (_ILIsSpecialFolder (pidl)) + { + /* take names of special folders only if its only this folder */ + if (bSimplePidl) + { + GUID const *clsid; - if ((clsid = _ILGetGUIDPointer (pidl))) { - if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) { - int bWantsForParsing; + clsid = _ILGetGUIDPointer (pidl); + if (clsid) + { + if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) + { + static const WCHAR clsidW[] = + { 'C','L','S','I','D','\\',0 }; + static const WCHAR shellfolderW[] = + { '\\','s','h','e','l','l','f','o','l','d','e','r',0 }; + static const WCHAR wantsForParsingW[] = + { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n', + 'g',0 }; + int bWantsForParsing = FALSE; + WCHAR szRegPath[100]; + LONG r; - /* - * we can only get a filesystem path from a shellfolder if the value WantsFORPARSING in - * CLSID\\{...}\\shellfolder exists - * exception: the MyComputer folder has this keys not but like any filesystem backed - * folder it needs these behaviour - */ - /* get the "WantsFORPARSING" flag from the registry */ - char szRegPath[100]; + /* + * We can only get a filesystem path from a shellfolder + * if the value WantsFORPARSING exists in + * CLSID\\{...}\\shellfolder + * exception: the MyComputer folder has this keys not + * but like any filesystem backed + * folder it needs these behaviour + * + * Get the "WantsFORPARSING" flag from the registry + */ - lstrcpyA (szRegPath, "CLSID\\"); - SHELL32_GUIDToStringA (clsid, &szRegPath[6]); - lstrcatA (szRegPath, "\\shellfolder"); - bWantsForParsing = - (ERROR_SUCCESS == - SHGetValueA (HKEY_CLASSES_ROOT, szRegPath, "WantsFORPARSING", NULL, NULL, NULL)); + lstrcpyW (szRegPath, clsidW); + SHELL32_GUIDToStringW (clsid, &szRegPath[6]); + lstrcatW (szRegPath, shellfolderW); + r = SHGetValueW (HKEY_CLASSES_ROOT, szRegPath, + wantsForParsingW, NULL, NULL, NULL); + if (r == ERROR_SUCCESS) + bWantsForParsing = TRUE; - if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && bWantsForParsing) { - /* we need the filesystem path to the destination folder. Only the folder itself can know it */ - hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH); - } else { - LPSTR p; + if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && + bWantsForParsing) + { + /* + * We need the filesystem path to the destination folder + * Only the folder itself can know it + */ + hr = SHELL32_GetDisplayNameOfChild (iface, pidl, + dwFlags, szPath, MAX_PATH); + } + else + { + LPSTR p; - /* parsing name like ::{...} */ - p = lstrcpyA(szPath, "::") + 2; - p += SHELL32_GUIDToStringA(&CLSID_MyComputer, p); + /* parsing name like ::{...} */ + p = lstrcpyA(szPath, "::") + 2; + p += SHELL32_GUIDToStringA(&CLSID_MyComputer, p); - lstrcatA(p, "\\::"); - p += 3; - SHELL32_GUIDToStringA(clsid, p); - } - } else { - /* user friendly name */ - HCR_GetClassNameA (clsid, szPath, MAX_PATH); - } - } else - _ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */ - } else { - FIXME ("special folder\n"); - } - } else { - if (!_ILIsDrive (pidl)) { - ERR ("Wrong pidl type\n"); - return E_INVALIDARG; - } + lstrcatA(p, "\\::"); + p += 3; + SHELL32_GUIDToStringA(clsid, p); + } + } + else + { + /* user friendly name */ + HCR_GetClassNameA (clsid, szPath, MAX_PATH); + } + } + else + { + /* append my own path */ + _ILSimpleGetText (pidl, szPath, MAX_PATH); + } + } + else + FIXME ("special folder\n"); + } + else + { + if (!_ILIsDrive (pidl)) + { + ERR ("Wrong pidl type\n"); + return E_INVALIDARG; + } - _ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */ + _ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */ - /* long view "lw_name (C:)" */ - if (bSimplePidl && !(dwFlags & SHGDN_FORPARSING)) { - DWORD dwVolumeSerialNumber, - dwMaximumComponetLength, - dwFileSystemFlags; + /* long view "lw_name (C:)" */ + if (bSimplePidl && !(dwFlags & SHGDN_FORPARSING)) + { + DWORD dwVolumeSerialNumber, dwMaximumComponetLength, dwFileSystemFlags; - GetVolumeInformationA (szPath, szDrive, sizeof (szDrive) - 6, &dwVolumeSerialNumber, - &dwMaximumComponetLength, &dwFileSystemFlags, NULL, 0); - strcat (szDrive, " ("); - strncat (szDrive, szPath, 2); - strcat (szDrive, ")"); - strcpy (szPath, szDrive); - } + GetVolumeInformationA (szPath, szDrive, sizeof (szDrive) - 6, + &dwVolumeSerialNumber, + &dwMaximumComponetLength, &dwFileSystemFlags, NULL, 0); + strcat (szDrive, " ("); + strncat (szDrive, szPath, 2); + strcat (szDrive, ")"); + strcpy (szPath, szDrive); + } } - if (!bSimplePidl) { /* go deeper if needed */ - PathAddBackslashA (szPath); - len = strlen (szPath); + if (!bSimplePidl) + { + /* go deeper if needed */ + PathAddBackslashA (szPath); + len = strlen (szPath); - hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len); + hr = SHELL32_GetDisplayNameOfChild (iface, pidl, + dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len); } - if (SUCCEEDED (hr)) { - strRet->uType = STRRET_CSTR; - lstrcpynA (strRet->u.cStr, szPath, MAX_PATH); + if (SUCCEEDED (hr)) + { + strRet->uType = STRRET_CSTR; + lstrcpynA (strRet->u.cStr, szPath, MAX_PATH); } TRACE ("-- (%p)->(%s)\n", This, szPath); @@ -608,53 +688,64 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 * iface, * identifier in the process. * * PARAMETERS -* HWND hwndOwner, //[in ] Owner window for output -* LPCITEMIDLIST pidl, //[in ] simple pidl of item to change -* LPCOLESTR lpszName, //[in ] the items new display name -* DWORD dwFlags, //[in ] SHGNO formatting flags -* LPITEMIDLIST* ppidlOut) //[out] simple pidl returned +* hwndOwner [in] Owner window for output +* pidl [in] simple pidl of item to change +* lpszName [in] the items new display name +* dwFlags [in] SHGNO formatting flags +* ppidlOut [out] simple pidl returned */ -static HRESULT WINAPI ISF_MyComputer_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */ - LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) +static HRESULT WINAPI ISF_MyComputer_fnSetNameOf ( + IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, + LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut); + FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, + hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut); return E_FAIL; } -static HRESULT WINAPI ISF_MyComputer_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid) +static HRESULT WINAPI ISF_MyComputer_fnGetDefaultSearchGUID ( + IShellFolder2 * iface, GUID * pguid) { IGenericSFImpl *This = (IGenericSFImpl *)iface; FIXME ("(%p)\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ISF_MyComputer_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum) +static HRESULT WINAPI ISF_MyComputer_fnEnumSearches ( + IShellFolder2 * iface, IEnumExtraSearch ** ppenum) { IGenericSFImpl *This = (IGenericSFImpl *)iface; FIXME ("(%p)\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumn (IShellFolder2 * iface, DWORD dwRes, ULONG * pSort, ULONG * pDisplay) +static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumn ( + IShellFolder2 *iface, DWORD dwRes, ULONG *pSort, ULONG *pDisplay) { IGenericSFImpl *This = (IGenericSFImpl *)iface; TRACE ("(%p)\n", This); - if (pSort) *pSort = 0; - if (pDisplay) *pDisplay = 0; + if (pSort) + *pSort = 0; + if (pDisplay) + *pDisplay = 0; return S_OK; } -static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) +static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumnState ( + IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags) { IGenericSFImpl *This = (IGenericSFImpl *)iface; TRACE ("(%p)\n", This); - if (!pcsFlags || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS) return E_INVALIDARG; + if (!pcsFlags || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS) + return E_INVALIDARG; *pcsFlags = MyComputerSFHeader[iColumn].pcsFlags; return S_OK; } -static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx (IShellFolder2 * iface, LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) + +static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx (IShellFolder2 * iface, + LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv) { IGenericSFImpl *This = (IGenericSFImpl *)iface; FIXME ("(%p)\n", This); @@ -662,7 +753,8 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx (IShellFolder2 * iface, LPCI } /* FIXME: drive size >4GB is rolling over */ -static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) +static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 * iface, + LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) { IGenericSFImpl *This = (IGenericSFImpl *)iface; HRESULT hr; @@ -670,48 +762,58 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 * iface, LPCI TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd); if (!psd || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS) - return E_INVALIDARG; + return E_INVALIDARG; - if (!pidl) { - psd->fmt = MyComputerSFHeader[iColumn].fmt; - psd->cxChar = MyComputerSFHeader[iColumn].cxChar; - psd->str.uType = STRRET_CSTR; - LoadStringA (shell32_hInstance, MyComputerSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH); - return S_OK; - } else { - char szPath[MAX_PATH]; - ULARGE_INTEGER ulBytes; + if (!pidl) + { + psd->fmt = MyComputerSFHeader[iColumn].fmt; + psd->cxChar = MyComputerSFHeader[iColumn].cxChar; + psd->str.uType = STRRET_CSTR; + LoadStringA (shell32_hInstance, MyComputerSFHeader[iColumn].colnameid, + psd->str.u.cStr, MAX_PATH); + return S_OK; + } + else + { + char szPath[MAX_PATH]; + ULARGE_INTEGER ulBytes; - psd->str.u.cStr[0] = 0x00; - psd->str.uType = STRRET_CSTR; - switch (iColumn) { - case 0: /* name */ - hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); - break; - case 1: /* type */ - _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH); - break; - case 2: /* total size */ - if (_ILIsDrive (pidl)) { - _ILSimpleGetText (pidl, szPath, MAX_PATH); - GetDiskFreeSpaceExA (szPath, NULL, &ulBytes, NULL); - StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH); - } - break; - case 3: /* free size */ - if (_ILIsDrive (pidl)) { - _ILSimpleGetText (pidl, szPath, MAX_PATH); - GetDiskFreeSpaceExA (szPath, &ulBytes, NULL, NULL); - StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH); - } - break; - } - hr = S_OK; + psd->str.u.cStr[0] = 0x00; + psd->str.uType = STRRET_CSTR; + switch (iColumn) + { + case 0: /* name */ + hr = IShellFolder_GetDisplayNameOf (iface, pidl, + SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); + break; + case 1: /* type */ + _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH); + break; + case 2: /* total size */ + if (_ILIsDrive (pidl)) + { + _ILSimpleGetText (pidl, szPath, MAX_PATH); + GetDiskFreeSpaceExA (szPath, NULL, &ulBytes, NULL); + StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH); + } + break; + case 3: /* free size */ + if (_ILIsDrive (pidl)) + { + _ILSimpleGetText (pidl, szPath, MAX_PATH); + GetDiskFreeSpaceExA (szPath, &ulBytes, NULL, NULL); + StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH); + } + break; + } + hr = S_OK; } return hr; } -static HRESULT WINAPI ISF_MyComputer_fnMapColumnToSCID (IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid) + +static HRESULT WINAPI ISF_MyComputer_fnMapColumnToSCID ( + IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid) { IGenericSFImpl *This = (IGenericSFImpl *)iface; FIXME ("(%p)\n", This); @@ -720,33 +822,34 @@ static HRESULT WINAPI ISF_MyComputer_fnMapColumnToSCID (IShellFolder2 * iface, U static IShellFolder2Vtbl vt_ShellFolder2 = { - ISF_MyComputer_fnQueryInterface, - ISF_MyComputer_fnAddRef, - ISF_MyComputer_fnRelease, - ISF_MyComputer_fnParseDisplayName, - ISF_MyComputer_fnEnumObjects, - ISF_MyComputer_fnBindToObject, - ISF_MyComputer_fnBindToStorage, - ISF_MyComputer_fnCompareIDs, - ISF_MyComputer_fnCreateViewObject, - ISF_MyComputer_fnGetAttributesOf, - ISF_MyComputer_fnGetUIObjectOf, - ISF_MyComputer_fnGetDisplayNameOf, - ISF_MyComputer_fnSetNameOf, - /* ShellFolder2 */ - ISF_MyComputer_fnGetDefaultSearchGUID, - ISF_MyComputer_fnEnumSearches, - ISF_MyComputer_fnGetDefaultColumn, - ISF_MyComputer_fnGetDefaultColumnState, - ISF_MyComputer_fnGetDetailsEx, - ISF_MyComputer_fnGetDetailsOf, - ISF_MyComputer_fnMapColumnToSCID + ISF_MyComputer_fnQueryInterface, + ISF_MyComputer_fnAddRef, + ISF_MyComputer_fnRelease, + ISF_MyComputer_fnParseDisplayName, + ISF_MyComputer_fnEnumObjects, + ISF_MyComputer_fnBindToObject, + ISF_MyComputer_fnBindToStorage, + ISF_MyComputer_fnCompareIDs, + ISF_MyComputer_fnCreateViewObject, + ISF_MyComputer_fnGetAttributesOf, + ISF_MyComputer_fnGetUIObjectOf, + ISF_MyComputer_fnGetDisplayNameOf, + ISF_MyComputer_fnSetNameOf, + /* ShellFolder2 */ + ISF_MyComputer_fnGetDefaultSearchGUID, + ISF_MyComputer_fnEnumSearches, + ISF_MyComputer_fnGetDefaultColumn, + ISF_MyComputer_fnGetDefaultColumnState, + ISF_MyComputer_fnGetDetailsEx, + ISF_MyComputer_fnGetDetailsOf, + ISF_MyComputer_fnMapColumnToSCID }; /************************************************************************ - * IMCFldr_PersistFolder2_QueryInterface + * IMCFldr_PersistFolder2_QueryInterface */ -static HRESULT WINAPI IMCFldr_PersistFolder2_QueryInterface (IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObj) +static HRESULT WINAPI IMCFldr_PersistFolder2_QueryInterface ( + IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObj) { _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); @@ -756,7 +859,7 @@ static HRESULT WINAPI IMCFldr_PersistFolder2_QueryInterface (IPersistFolder2 * i } /************************************************************************ - * IMCFldr_PersistFolder2_AddRef + * IMCFldr_PersistFolder2_AddRef */ static ULONG WINAPI IMCFldr_PersistFolder2_AddRef (IPersistFolder2 * iface) { @@ -768,7 +871,7 @@ static ULONG WINAPI IMCFldr_PersistFolder2_AddRef (IPersistFolder2 * iface) } /************************************************************************ - * ISFPersistFolder_Release + * ISFPersistFolder_Release */ static ULONG WINAPI IMCFldr_PersistFolder2_Release (IPersistFolder2 * iface) { @@ -780,27 +883,29 @@ static ULONG WINAPI IMCFldr_PersistFolder2_Release (IPersistFolder2 * iface) } /************************************************************************ - * IMCFldr_PersistFolder2_GetClassID + * IMCFldr_PersistFolder2_GetClassID */ -static HRESULT WINAPI IMCFldr_PersistFolder2_GetClassID (IPersistFolder2 * iface, CLSID * lpClassId) +static HRESULT WINAPI IMCFldr_PersistFolder2_GetClassID ( + IPersistFolder2 * iface, CLSID * lpClassId) { _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); TRACE ("(%p)\n", This); if (!lpClassId) - return E_POINTER; + return E_POINTER; *lpClassId = CLSID_MyComputer; return S_OK; } /************************************************************************ - * IMCFldr_PersistFolder2_Initialize + * IMCFldr_PersistFolder2_Initialize * * NOTES: it makes no sense to change the pidl */ -static HRESULT WINAPI IMCFldr_PersistFolder2_Initialize (IPersistFolder2 * iface, LPCITEMIDLIST pidl) +static HRESULT WINAPI IMCFldr_PersistFolder2_Initialize ( + IPersistFolder2 * iface, LPCITEMIDLIST pidl) { _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); TRACE ("(%p)->(%p)\n", This, pidl); @@ -808,26 +913,27 @@ static HRESULT WINAPI IMCFldr_PersistFolder2_Initialize (IPersistFolder2 * iface } /************************************************************************** - * IPersistFolder2_fnGetCurFolder + * IPersistFolder2_fnGetCurFolder */ -static HRESULT WINAPI IMCFldr_PersistFolder2_GetCurFolder (IPersistFolder2 * iface, LPITEMIDLIST * pidl) +static HRESULT WINAPI IMCFldr_PersistFolder2_GetCurFolder ( + IPersistFolder2 * iface, LPITEMIDLIST * pidl) { _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface); TRACE ("(%p)->(%p)\n", This, pidl); if (!pidl) - return E_POINTER; + return E_POINTER; *pidl = ILClone (This->pidlRoot); return S_OK; } static IPersistFolder2Vtbl vt_PersistFolder2 = { - IMCFldr_PersistFolder2_QueryInterface, - IMCFldr_PersistFolder2_AddRef, - IMCFldr_PersistFolder2_Release, - IMCFldr_PersistFolder2_GetClassID, - IMCFldr_PersistFolder2_Initialize, - IMCFldr_PersistFolder2_GetCurFolder + IMCFldr_PersistFolder2_QueryInterface, + IMCFldr_PersistFolder2_AddRef, + IMCFldr_PersistFolder2_Release, + IMCFldr_PersistFolder2_GetClassID, + IMCFldr_PersistFolder2_Initialize, + IMCFldr_PersistFolder2_GetCurFolder }; diff --git a/reactos/lib/shell32/shfldr_unixfs.c b/reactos/lib/shell32/shfldr_unixfs.c new file mode 100644 index 00000000000..7a49b5e5e68 --- /dev/null +++ b/reactos/lib/shell32/shfldr_unixfs.c @@ -0,0 +1,21 @@ +/* + * UNIXFS - Shell namespace extension for the unix filesystem + * + * Copyright (C) 2005 Michael Jung + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* Placeholder in ReactOS, we don't need this */ diff --git a/reactos/lib/shell32/shlexec.c b/reactos/lib/shell32/shlexec.c index 14bab166d5f..8385b12d886 100644 --- a/reactos/lib/shell32/shlexec.c +++ b/reactos/lib/shell32/shlexec.c @@ -365,7 +365,7 @@ static UINT SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait, } else if ((retval = GetLastError()) >= 32) { - FIXME("Strange error set by CreateProcess: %d\n", retval); + TRACE("CreateProcess returned error %d\n", retval); retval = ERROR_BAD_FORMAT; } diff --git a/reactos/lib/shell32/shlfileop.c b/reactos/lib/shell32/shlfileop.c index 811a5a9b854..dfa6fb30863 100644 --- a/reactos/lib/shell32/shlfileop.c +++ b/reactos/lib/shell32/shlfileop.c @@ -861,7 +861,8 @@ static const char * debug_shfileops_action( DWORD op ) #define ERROR_SHELL_INTERNAL_FILE_NOT_FOUND 1026 #define HIGH_ADR (LPWSTR)0xffffffff -static int file_operation_delete( WIN32_FIND_DATAW *wfd,SHFILEOPSTRUCTW nFileOp, LPWSTR pFromFile,LPWSTR pTempFrom,HANDLE *hFind) +/* handle the complete deletion of `pTempFrom` */ +static int shfileops_delete(WIN32_FIND_DATAW *wfd,SHFILEOPSTRUCTW nFileOp, LPWSTR pFromFile,LPWSTR pTempFrom,HANDLE *hFind) { LPWSTR lpFileName; @@ -914,7 +915,7 @@ static int file_operation_delete( WIN32_FIND_DATAW *wfd,SHFILEOPSTRUCTW nFileOp, * FOF_ALLOWUNDO, FOF_WANTMAPPINGHANDLE */ -static int file_operation_checkFlags(SHFILEOPSTRUCTW nFileOp) +static int shfileops_check_flags(SHFILEOPSTRUCTW nFileOp) { FILEOP_FLAGS OFl = ((FILEOP_FLAGS)nFileOp.fFlags & 0xfff); long FuncSwitch = (nFileOp.wFunc & FO_MASK); @@ -945,6 +946,53 @@ static int file_operation_checkFlags(SHFILEOPSTRUCTW nFileOp) return 0; } +static int shfileops_do_operation(WIN32_FIND_DATAW wfd,SHFILEOPSTRUCTW *nFileOp, LPWSTR pToFile, LPWSTR pFromFile) +{ + LPWSTR lpFileName = wfd.cAlternateFileName; + if (!lpFileName[0]) + lpFileName = wfd.cFileName; + if (IsDotDir(lpFileName) || + (IsAttribDir(wfd.dwFileAttributes) && (nFileOp->fFlags & FOF_FILESONLY))) + return 0; /* next name in pTempFrom(dir) */ + SHFileStrCpyCatW(&pToFile[1], lpFileName, NULL); + SHFileStrCpyCatW(&pFromFile[1], lpFileName, NULL); + return SHFileOperationW (nFileOp); +} + +/* get attributes of the parent dir of pTemp and create the directory if it does not exists */ +static DWORD shfileops_get_parent_attr2(LPWSTR pFile,LPWSTR pTemp,int flag,int *retCode) +{ + DWORD PathAttr; + pFile[0] = '\0'; + PathAttr = GetFileAttributesW(pTemp); + if ((PathAttr == INVALID_FILE_ATTRIBUTES) && flag) + { + /* create dir must be here, sample target D:\y\ *.* create with RC=10003 */ + if (SHNotifyCreateDirectoryW(pTemp, NULL)) + { + *retCode = 0x73;/* value unknown */ + /*goto shfileop_end;*/ + return PathAttr; + } + PathAttr = GetFileAttributesW(pTemp); + } + pFile[0] = '\\'; + return PathAttr; +} + +/* get attributes of the parent dir of pTemp without creating the directory if it does not exists */ +static DWORD shfileops_get_parent_attr(LPWSTR pFile,LPWSTR pTemp) +{ + /* less efficient: + return shfileops_get_parent_attr2(pFile,pTemp,0,NULL); + */ + DWORD PathAttr; + pFile[0] = '\0'; + PathAttr = GetFileAttributesW(pTemp); + pFile[0] = '\\'; + return PathAttr; +} + /************************************************************************* * SHFileOperationW [SHELL32.@] * @@ -964,7 +1012,6 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) LPWSTR pTempTo = NULL; LPWSTR pFromFile; LPWSTR pToFile = NULL; - LPWSTR lpFileName; int retCode = 0; DWORD ToAttr; DWORD ToPathAttr; @@ -986,8 +1033,6 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) long FuncSwitch = (nFileOp.wFunc & FO_MASK); long level= nFileOp.wFunc>>4; - int ret; - /* default no error */ nFileOp.fAnyOperationsAborted = FALSE; @@ -1016,12 +1061,9 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) * create dir 0 0 0 0 0 0 1 0 */ - ret = file_operation_checkFlags(nFileOp); - if (ret != 0) - { - retCode = ret; + retCode = shfileops_check_flags(nFileOp); + if (retCode) goto shfileop_end; - } if ((pNextFrom) && (!(b_MultiTo) || (pNextTo))) { @@ -1108,17 +1150,10 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) hFind = FindFirstFileW(pFrom, &wfd); if (INVALID_HANDLE_VALUE == hFind) { - if ((FO_DELETE == FuncSwitch) && (b_Mask)) + if ((FO_DELETE == FuncSwitch) && (b_Mask) && IsAttribDir(shfileops_get_parent_attr(pFromFile,pTempFrom))) { - DWORD FromPathAttr; - pFromFile[0] = '\0'; - FromPathAttr = GetFileAttributesW(pTempFrom); - pFromFile[0] = '\\'; - if (IsAttribDir(FromPathAttr)) - { - /* FO_DELETE with mask and without found is valid */ - goto shfileop_end; - } + /* FO_DELETE with mask and without found is valid */ + goto shfileop_end; } /* root (without mask) is also not allowed as source, tested in W98 */ retCode = ERROR_SHELL_INTERNAL_FILE_NOT_FOUND; @@ -1130,13 +1165,8 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) /* ??? b_Mask = (!SHFileStrICmpA(&pFromFile[1], &wfd.cFileName[0], HIGH_ADR, HIGH_ADR)); */ if (!pTo) /* FO_DELETE */ { - ret = file_operation_delete(&wfd,nFileOp,pFromFile,pTempFrom,&hFind); - /* if ret is not 0, nFileOp.fAnyOperationsAborted is TRUE */ - if (ret != 0) - { - retCode = ret; - goto shfileop_end; - } + retCode = shfileops_delete(&wfd,nFileOp,pFromFile,pTempFrom,&hFind); + /* if ret is not 0, nFileOp.fAnyOperationsAborted is TRUE and the loop will end */ continue; } /* FO_DELETE ends, pTo must be always valid from here */ @@ -1146,9 +1176,7 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) ToPathAttr = ToAttr = GetFileAttributesW(pTempTo); if (!b_Mask && (ToAttr == INVALID_FILE_ATTRIBUTES) && (pToFile)) { - pToFile[0] = '\0'; - ToPathAttr = GetFileAttributesW(pTempTo); - pToFile[0] = '\\'; + ToPathAttr = shfileops_get_parent_attr(pToFile,pTempTo); } if (FO_RENAME == FuncSwitch) @@ -1202,15 +1230,7 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) nFileOp.fFlags = (nFileOp.fFlags | FOF_MULTIDESTFILES); do { - lpFileName = wfd.cAlternateFileName; - if (!lpFileName[0]) - lpFileName = wfd.cFileName; - if (IsDotDir(lpFileName) || - (IsAttribDir(wfd.dwFileAttributes) && (nFileOp.fFlags & FOF_FILESONLY))) - continue; /* next name in pTempFrom(dir) */ - SHFileStrCpyCatW(&pToFile[1], lpFileName, NULL); - SHFileStrCpyCatW(&pFromFile[1], lpFileName, NULL); - retCode = SHFileOperationW (&nFileOp); + retCode = shfileops_do_operation(wfd,&nFileOp,pToFile,pFromFile); } while(!nFileOp.fAnyOperationsAborted && FindNextFileW(hFind, &wfd)); } FindClose(hFind); @@ -1224,19 +1244,9 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) { if (pToFile) { - pToFile[0] = '\0'; - ToPathAttr = GetFileAttributesW(pTempTo); - if ((ToPathAttr == INVALID_FILE_ATTRIBUTES) && b_ToValid) - { - /* create dir must be here, sample target D:\y\ *.* create with RC=10003 */ - if (SHNotifyCreateDirectoryW(pTempTo, NULL)) - { - retCode = 0x73;/* value unknown */ - goto shfileop_end; - } - ToPathAttr = GetFileAttributesW(pTempTo); - } - pToFile[0] = '\\'; + ToPathAttr = shfileops_get_parent_attr2(pToFile,pTempTo,b_ToValid,&retCode); + if (retCode) + goto shfileop_end; if (b_ToInvalidTail) { retCode = 0x10003; @@ -1270,9 +1280,7 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) } else { - pToFile[0] = '\0'; - ToPathAttr = GetFileAttributesW(pTempTo); - pToFile[0] = '\\'; + ToPathAttr = shfileops_get_parent_attr(pToFile,pTempTo); if (IsAttribFile(ToPathAttr)) { /* error, is this tested ? */ @@ -1403,7 +1411,16 @@ void WINAPI SHFreeNameMappings(HANDLE hNameMapping) } /************************************************************************* - * SheGetDirW [SHELL32.281] + * SheGetDirA [SHELL32.@] + * + */ +HRESULT WINAPI SheGetDirA(LPSTR u, LPSTR v) +{ FIXME("%p %p stub\n",u,v); + return 0; +} + +/************************************************************************* + * SheGetDirW [SHELL32.@] * */ HRESULT WINAPI SheGetDirW(LPWSTR u, LPWSTR v) @@ -1412,7 +1429,16 @@ HRESULT WINAPI SheGetDirW(LPWSTR u, LPWSTR v) } /************************************************************************* - * SheChangeDirW [SHELL32.274] + * SheChangeDirA [SHELL32.@] + * + */ +HRESULT WINAPI SheChangeDirA(LPSTR u) +{ FIXME("(%s),stub\n",debugstr_a(u)); + return 0; +} + +/************************************************************************* + * SheChangeDirW [SHELL32.@] * */ HRESULT WINAPI SheChangeDirW(LPWSTR u) diff --git a/reactos/lib/shell32/shlfolder.c b/reactos/lib/shell32/shlfolder.c index 1f5841906d6..e6734ebcc60 100644 --- a/reactos/lib/shell32/shlfolder.c +++ b/reactos/lib/shell32/shlfolder.c @@ -422,7 +422,7 @@ HRESULT SHELL32_GetItemAttributes (IShellFolder * psf, LPCITEMIDLIST pidl, LPDWO if (SFGAO_LINK & *pdwAttributes) { char ext[MAX_PATH]; - if (!_ILGetExtension(pidl, ext, MAX_PATH) || strcasecmp(ext, "lnk")) + if (!_ILGetExtension(pidl, ext, MAX_PATH) || lstrcmpiA(ext, "lnk")) *pdwAttributes &= ~SFGAO_LINK; } } else { @@ -469,7 +469,7 @@ HRESULT SHELL32_CompareIDs (IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST p /* test for name of pidl */ _ILSimpleGetText (pidl1, szTemp1, MAX_PATH); _ILSimpleGetText (pidl2, szTemp2, MAX_PATH); - nReturn = strcasecmp (szTemp1, szTemp2); + nReturn = lstrcmpiA (szTemp1, szTemp2); if (nReturn < 0) return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 ); else if (nReturn > 0) diff --git a/reactos/lib/shell32/shlfsbind.c b/reactos/lib/shell32/shlfsbind.c index b558aeab3e1..17ff2301948 100644 --- a/reactos/lib/shell32/shlfsbind.c +++ b/reactos/lib/shell32/shlfsbind.c @@ -42,16 +42,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(pidl); */ typedef struct { - IFileSystemBindDataVtbl *lpVtbl; - DWORD ref; - WIN32_FIND_DATAW findFile; + IFileSystemBindDataVtbl *lpVtbl; + DWORD ref; + WIN32_FIND_DATAW findFile; } IFileSystemBindDataImpl; -static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(IFileSystemBindData *iface, REFIID riid, LPVOID* ppvObj); -static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *iface); -static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *iface); -static HRESULT WINAPI IFileSystemBindData_fnGetFindData(IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd); -static HRESULT WINAPI IFileSystemBindData_fnSetFindData(IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd); +static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(IFileSystemBindData *, REFIID, LPVOID*); +static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *); +static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *); +static HRESULT WINAPI IFileSystemBindData_fnGetFindData(IFileSystemBindData *, WIN32_FIND_DATAW *); +static HRESULT WINAPI IFileSystemBindData_fnSetFindData(IFileSystemBindData *, const WIN32_FIND_DATAW *); static struct IFileSystemBindDataVtbl sbvt = { @@ -62,165 +62,165 @@ static struct IFileSystemBindDataVtbl sbvt = IFileSystemBindData_fnGetFindData, }; -static const WCHAR wFileSystemBindData[] = {'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d','D','a','t','a',0}; +static const WCHAR wFileSystemBindData[] = { + 'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d','D','a','t','a',0}; HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV) { - IFileSystemBindDataImpl *sb; - HRESULT ret = E_OUTOFMEMORY; + IFileSystemBindDataImpl *sb; + HRESULT ret = E_OUTOFMEMORY; - TRACE("%p, %p\n", pfd, ppV); + TRACE("%p, %p\n", pfd, ppV); - if (!ppV) - return E_INVALIDARG; + if (!ppV) + return E_INVALIDARG; - *ppV = NULL; + *ppV = NULL; - sb = (IFileSystemBindDataImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IFileSystemBindDataImpl)); - if (!sb) - return ret; + sb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IFileSystemBindDataImpl)); + if (!sb) + return ret; - sb->lpVtbl = &sbvt; - sb->ref = 1; - IFileSystemBindData_fnSetFindData((IFileSystemBindData*)sb, pfd); + sb->lpVtbl = &sbvt; + sb->ref = 1; + IFileSystemBindData_fnSetFindData((IFileSystemBindData*)sb, pfd); - ret = CreateBindCtx(0, ppV); - if (SUCCEEDED(ret)) - { - BIND_OPTS bindOpts; - bindOpts.cbStruct = sizeof(BIND_OPTS); - bindOpts.grfFlags = 0; - bindOpts.grfMode = STGM_CREATE; - bindOpts.dwTickCountDeadline = 0; - IBindCtx_SetBindOptions(*ppV, &bindOpts); - IBindCtx_RegisterObjectParam(*ppV, (LPOLESTR)wFileSystemBindData, (LPUNKNOWN)sb); + ret = CreateBindCtx(0, ppV); + if (SUCCEEDED(ret)) + { + BIND_OPTS bindOpts; - IFileSystemBindData_Release((IFileSystemBindData*)sb); - } - else - HeapFree(GetProcessHeap(), 0, sb); - return ret; + bindOpts.cbStruct = sizeof(BIND_OPTS); + bindOpts.grfFlags = 0; + bindOpts.grfMode = STGM_CREATE; + bindOpts.dwTickCountDeadline = 0; + IBindCtx_SetBindOptions(*ppV, &bindOpts); + IBindCtx_RegisterObjectParam(*ppV, (LPOLESTR)wFileSystemBindData, (LPUNKNOWN)sb); + + IFileSystemBindData_Release((IFileSystemBindData*)sb); + } + else + HeapFree(GetProcessHeap(), 0, sb); + return ret; } HRESULT WINAPI FileSystemBindData_GetFindData(LPBC pbc, WIN32_FIND_DATAW *pfd) { - LPUNKNOWN pUnk; - IFileSystemBindData *pfsbd = NULL; - HRESULT ret; + LPUNKNOWN pUnk; + IFileSystemBindData *pfsbd = NULL; + HRESULT ret; - TRACE("%p, %p\n", pbc, pfd); + TRACE("%p, %p\n", pbc, pfd); - if (!pfd) - return E_INVALIDARG; + if (!pfd) + return E_INVALIDARG; - ret = IBindCtx_GetObjectParam(pbc, (LPOLESTR)wFileSystemBindData, &pUnk); - if (SUCCEEDED(ret)) - { - ret = IUnknown_QueryInterface(pUnk, &IID_IFileSystemBindData, (LPVOID *)&pfsbd); - if (SUCCEEDED(ret)) - { - ret = IFileSystemBindData_GetFindData(pfsbd, pfd); - IFileSystemBindData_Release(pfsbd); - } - IUnknown_Release(pUnk); - } - return ret; + ret = IBindCtx_GetObjectParam(pbc, (LPOLESTR)wFileSystemBindData, &pUnk); + if (SUCCEEDED(ret)) + { + ret = IUnknown_QueryInterface(pUnk, &IID_IFileSystemBindData, (LPVOID *)&pfsbd); + if (SUCCEEDED(ret)) + { + ret = IFileSystemBindData_GetFindData(pfsbd, pfd); + IFileSystemBindData_Release(pfsbd); + } + IUnknown_Release(pUnk); + } + return ret; } HRESULT WINAPI FileSystemBindData_SetFindData(LPBC pbc, const WIN32_FIND_DATAW *pfd) { - LPUNKNOWN pUnk; - IFileSystemBindData *pfsbd = NULL; - HRESULT ret; - - TRACE("%p, %p\n", pbc, pfd); + LPUNKNOWN pUnk; + IFileSystemBindData *pfsbd = NULL; + HRESULT ret; + + TRACE("%p, %p\n", pbc, pfd); - ret = IBindCtx_GetObjectParam(pbc, (LPOLESTR)wFileSystemBindData, &pUnk); - if (SUCCEEDED(ret)) - { - ret = IUnknown_QueryInterface(pUnk, &IID_IFileSystemBindData, (LPVOID *)&pfsbd); - if (SUCCEEDED(ret)) - { - ret = IFileSystemBindData_SetFindData(pfsbd, pfd); - IFileSystemBindData_Release(pfsbd); - } - IUnknown_Release(pUnk); - } - return ret;} + ret = IBindCtx_GetObjectParam(pbc, (LPOLESTR)wFileSystemBindData, &pUnk); + if (SUCCEEDED(ret)) + { + ret = IUnknown_QueryInterface(pUnk, &IID_IFileSystemBindData, (LPVOID *)&pfsbd); + if (SUCCEEDED(ret)) + { + ret = IFileSystemBindData_SetFindData(pfsbd, pfd); + IFileSystemBindData_Release(pfsbd); + } + IUnknown_Release(pUnk); + } + return ret; +} - - -static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(IFileSystemBindData *iface, REFIID riid, LPVOID *ppV) +static HRESULT WINAPI IFileSystemBindData_fnQueryInterface( + IFileSystemBindData *iface, REFIID riid, LPVOID *ppV) { - IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; - TRACE("(%p)->(\n\tIID:\t%s, %p)\n", This, debugstr_guid(riid), ppV); + IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; + TRACE("(%p)->(\n\tIID:\t%s, %p)\n", This, debugstr_guid(riid), ppV); - *ppV = NULL; + *ppV = NULL; - if (IsEqualIID(riid, &IID_IUnknown)) - { - *ppV = This; - } - else if (IsEqualIID(riid, &IID_IFileSystemBindData)) - { - *ppV = (IFileSystemBindData*)This; - } + if (IsEqualIID(riid, &IID_IUnknown)) + *ppV = This; + else if (IsEqualIID(riid, &IID_IFileSystemBindData)) + *ppV = (IFileSystemBindData*)This; - if (*ppV) - { - IUnknown_AddRef((IUnknown*)(*ppV)); - TRACE("-- Interface: (%p)->(%p)\n", ppV, *ppV); - return S_OK; - } - TRACE("-- Interface: E_NOINTERFACE\n"); - return E_NOINTERFACE; + if (*ppV) + { + IUnknown_AddRef((IUnknown*)(*ppV)); + TRACE("-- Interface: (%p)->(%p)\n", ppV, *ppV); + return S_OK; + } + TRACE("-- Interface: E_NOINTERFACE\n"); + return E_NOINTERFACE; } static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *iface) { - IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; - ULONG refCount = InterlockedIncrement(&This->ref); + IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("(%p)->(count=%li)\n", This, refCount - 1); + TRACE("(%p)->(count=%li)\n", This, refCount - 1); - return refCount; + return refCount; } static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *iface) { - IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; - ULONG refCount = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(count=%li)\n", This, refCount + 1); + IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(count=%li)\n", This, refCount + 1); - if (!refCount) - { - TRACE(" destroying ISFBindPidl(%p)\n",This); - HeapFree(GetProcessHeap(), 0, This); - } - return refCount; + if (!refCount) + { + TRACE(" destroying ISFBindPidl(%p)\n",This); + HeapFree(GetProcessHeap(), 0, This); + } + return refCount; } -static HRESULT WINAPI IFileSystemBindData_fnGetFindData(IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd) +static HRESULT WINAPI IFileSystemBindData_fnGetFindData( + IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd) { - IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; - TRACE("(%p), %p\n", This, pfd); + IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; + TRACE("(%p), %p\n", This, pfd); - if (!pfd) - return E_INVALIDARG; + if (!pfd) + return E_INVALIDARG; - memcpy(pfd, &This->findFile, sizeof(WIN32_FIND_DATAW)); - return NOERROR; + memcpy(pfd, &This->findFile, sizeof(WIN32_FIND_DATAW)); + return NOERROR; } -static HRESULT WINAPI IFileSystemBindData_fnSetFindData(IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd) +static HRESULT WINAPI IFileSystemBindData_fnSetFindData( + IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd) { - IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; - TRACE("(%p), %p\n", This, pfd); + IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; + TRACE("(%p), %p\n", This, pfd); - if (pfd) - memcpy(&This->findFile, pfd, sizeof(WIN32_FIND_DATAW)); - else - memset(&This->findFile, 0, sizeof(WIN32_FIND_DATAW)); - return NOERROR; + if (pfd) + memcpy(&This->findFile, pfd, sizeof(WIN32_FIND_DATAW)); + else + memset(&This->findFile, 0, sizeof(WIN32_FIND_DATAW)); + return NOERROR; } diff --git a/reactos/lib/shell32/shlview.c b/reactos/lib/shell32/shlview.c index 4bf77e64698..06f30c6c7b1 100644 --- a/reactos/lib/shell32/shlview.c +++ b/reactos/lib/shell32/shlview.c @@ -454,7 +454,7 @@ static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam { _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH); _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH); - nDiff = strcasecmp(strName1, strName2); + nDiff = lstrcmpiA(strName1, strName2); } /* Sort by FileName: Folder or Files can be sorted */ else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder) @@ -462,7 +462,7 @@ static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam /* Sort by Text */ _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH); _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH); - nDiff = strcasecmp(strName1, strName2); + nDiff = lstrcmpiA(strName1, strName2); } /* Sort by File Size, Only valid for Files */ else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE) @@ -475,7 +475,7 @@ static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam /* Sort by Type */ _ILGetFileType(pItemIdList1, strName1, MAX_PATH); _ILGetFileType(pItemIdList2, strName2, MAX_PATH); - nDiff = strcasecmp(strName1, strName2); + nDiff = lstrcmpiA(strName1, strName2); } } /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */ @@ -484,7 +484,7 @@ static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam { _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH); _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH); - nDiff = strcasecmp(strName1, strName2); + nDiff = lstrcmpiA(strName1, strName2); } if(!pSortInfo->bIsAscending)