David Hedberg : shell32: Implement SHCreateItemFromParsingName.

Alexandre Julliard julliard at winehq.org
Fri Jul 23 10:05:46 CDT 2010


Module: wine
Branch: master
Commit: 5b0b56fac404bf0d2b6523de29a48a5a3e917779
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5b0b56fac404bf0d2b6523de29a48a5a3e917779

Author: David Hedberg <david.hedberg at gmail.com>
Date:   Thu Jul 22 20:17:03 2010 +0200

shell32: Implement SHCreateItemFromParsingName.

---

 dlls/shell32/shell32.spec      |    1 +
 dlls/shell32/shellitem.c       |   27 ++++++++++++++++++++++++
 dlls/shell32/tests/shlfolder.c |   44 ++++++++++++++++++++++++++++++++++++++++
 include/shobjidl.idl           |    1 +
 4 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/dlls/shell32/shell32.spec b/dlls/shell32/shell32.spec
index 07f97af..bb1796d 100644
--- a/dlls/shell32/shell32.spec
+++ b/dlls/shell32/shell32.spec
@@ -330,6 +330,7 @@
 @ stub SHChangeNotifySuspendResume
 @ stdcall SHCreateDirectoryExA(long str ptr)
 @ stdcall SHCreateDirectoryExW(long wstr ptr)
+@ stdcall SHCreateItemFromParsingName(wstr ptr ptr ptr)
 @ stub SHCreateProcessAsUserW
 @ stdcall SHCreateShellItem(ptr ptr ptr ptr)
 @ stdcall SHEmptyRecycleBinA(long str long)
diff --git a/dlls/shell32/shellitem.c b/dlls/shell32/shellitem.c
index ae6de18..762b13b 100644
--- a/dlls/shell32/shellitem.c
+++ b/dlls/shell32/shellitem.c
@@ -392,3 +392,30 @@ HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent,
     }
     return ret;
 }
+
+HRESULT WINAPI SHCreateItemFromParsingName(PCWSTR pszPath,
+    IBindCtx *pbc, REFIID riid, void **ppv)
+{
+    LPITEMIDLIST pidl;
+    HRESULT ret;
+
+    *ppv = NULL;
+
+    ret = SHParseDisplayName(pszPath, pbc, &pidl, 0, NULL);
+    if(SUCCEEDED(ret))
+    {
+        ShellItem *This;
+        ret = IShellItem_Constructor(NULL, riid, (void**)&This);
+
+        if(SUCCEEDED(ret))
+        {
+            This->pidl = pidl;
+            *ppv = (void*)This;
+        }
+        else
+        {
+            ILFree(pidl);
+        }
+    }
+    return ret;
+}
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index 1027184..10838e6 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -53,6 +53,7 @@ static HRESULT (WINAPI *pStrRetToBufW)(STRRET*,LPCITEMIDLIST,LPWSTR,UINT);
 static LPITEMIDLIST (WINAPI *pILFindLastID)(LPCITEMIDLIST);
 static void (WINAPI *pILFree)(LPITEMIDLIST);
 static BOOL (WINAPI *pILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST);
+static HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR,IBindCtx*,REFIID,void**);
 static HRESULT (WINAPI *pSHCreateShellItem)(LPCITEMIDLIST,IShellFolder*,LPCITEMIDLIST,IShellItem**);
 static LPITEMIDLIST (WINAPI *pILCombine)(LPCITEMIDLIST,LPCITEMIDLIST);
 static HRESULT (WINAPI *pSHParseDisplayName)(LPCWSTR,IBindCtx*,LPITEMIDLIST*,SFGAOF,SFGAOF*);
@@ -69,6 +70,7 @@ static void init_function_pointers(void)
 
 #define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hmod, #f))
     MAKEFUNC(SHBindToParent);
+    MAKEFUNC(SHCreateItemFromParsingName);
     MAKEFUNC(SHCreateShellItem);
     MAKEFUNC(SHGetFolderPathA);
     MAKEFUNC(SHGetFolderPathAndSubDirA);
@@ -1867,6 +1869,7 @@ static void test_SHCreateShellItem(void)
     HRESULT ret;
     char curdirA[MAX_PATH];
     WCHAR curdirW[MAX_PATH];
+    WCHAR fnbufW[MAX_PATH];
     IShellFolder *desktopfolder=NULL, *currentfolder=NULL;
     static WCHAR testfileW[] = {'t','e','s','t','f','i','l','e',0};
 
@@ -2035,6 +2038,47 @@ static void test_SHCreateShellItem(void)
         IShellItem_Release(shellitem);
     }
 
+    /* SHCreateItemFromParsingName */
+    if(pSHCreateItemFromParsingName)
+    {
+        if(0)
+        {
+            /* Crashes under windows 7 */
+            ret = pSHCreateItemFromParsingName(NULL, NULL, &IID_IShellItem, NULL);
+        }
+
+        shellitem = (void*)0xdeadbeef;
+        ret = pSHCreateItemFromParsingName(NULL, NULL, &IID_IShellItem, (void**)&shellitem);
+        ok(ret == E_INVALIDARG, "SHCreateItemFromParsingName returned %x\n", ret);
+        ok(shellitem == NULL, "shellitem was %p.\n", shellitem);
+
+        ret = pSHCreateItemFromParsingName(testfileW, NULL, &IID_IShellItem, (void**)&shellitem);
+        ok(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND),
+           "SHCreateItemFromParsingName returned %x\n", ret);
+        if(SUCCEEDED(ret)) IShellItem_Release(shellitem);
+
+        lstrcpyW(fnbufW, curdirW);
+        myPathAddBackslashW(fnbufW);
+        lstrcatW(fnbufW, testfileW);
+
+        ret = pSHCreateItemFromParsingName(fnbufW, NULL, &IID_IShellItem, (void**)&shellitem);
+        ok(ret == S_OK, "SHCreateItemFromParsingName returned %x\n", ret);
+        if(SUCCEEDED(ret))
+        {
+            LPWSTR tmp_fname;
+            ret = IShellItem_GetDisplayName(shellitem, SIGDN_FILESYSPATH, &tmp_fname);
+            ok(ret == S_OK, "GetDisplayName returned %x\n", ret);
+            if(SUCCEEDED(ret))
+            {
+                ok(!lstrcmpW(fnbufW, tmp_fname), "strings not equal\n");
+                CoTaskMemFree(tmp_fname);
+            }
+            IShellItem_Release(shellitem);
+        }
+    }
+    else
+        win_skip("No SHCreateItemFromParsingName\n");
+
     DeleteFileA(".\\testfile");
     pILFree(pidl_abstestfile);
     pILFree(pidl_testfile);
diff --git a/include/shobjidl.idl b/include/shobjidl.idl
index be85fbb..60c0f18 100644
--- a/include/shobjidl.idl
+++ b/include/shobjidl.idl
@@ -495,6 +495,7 @@ interface IShellItemArray : IUnknown
 }
 
 cpp_quote("HRESULT WINAPI SHGetNameFromIDList(PCIDLIST_ABSOLUTE pidl, SIGDN sigdnName, PWSTR *ppszName);")
+cpp_quote("HRESULT WINAPI SHCreateItemFromParsingName(PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv);")
 
 /*****************************************************************************
  * IShellItemFilter interface




More information about the wine-cvs mailing list