Myah Caron : shell32: Implement ShellLinkObject::get_Path.
Alexandre Julliard
julliard at winehq.org
Tue Mar 23 15:07:41 CDT 2021
Module: wine
Branch: oldstable
Commit: cc1f837b9b5a8919e624d1b2b89196c1f17ec1b9
URL: https://source.winehq.org/git/wine.git/?a=commit;h=cc1f837b9b5a8919e624d1b2b89196c1f17ec1b9
Author: Myah Caron <qsniyg at protonmail.com>
Date: Mon Sep 14 20:52:47 2020 +0000
shell32: Implement ShellLinkObject::get_Path.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49591
Signed-off-by: Myah Caron <qsniyg at protonmail.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 4c99e3ef341a6b4eda67dffa13a86829fa343bbb)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/shell32/shelldispatch.c | 53 ++++++++++++++++++++++++++++++++++----
dlls/shell32/tests/shelldispatch.c | 2 +-
2 files changed, 49 insertions(+), 6 deletions(-)
diff --git a/dlls/shell32/shelldispatch.c b/dlls/shell32/shelldispatch.c
index 5eda5c76eef..de581dec427 100644
--- a/dlls/shell32/shelldispatch.c
+++ b/dlls/shell32/shelldispatch.c
@@ -106,6 +106,8 @@ typedef struct {
typedef struct {
IShellLinkDual2 IShellLinkDual2_iface;
LONG ref;
+
+ IShellLinkW *shell_link;
} ShellLinkObjectImpl;
static inline ShellDispatch *impl_from_IShellDispatch6(IShellDispatch6 *iface)
@@ -671,6 +673,7 @@ static ULONG WINAPI ShellLinkObject_Release(IShellLinkDual2 *iface)
if (!ref)
{
+ if (This->shell_link) IShellLinkW_Release(This->shell_link);
heap_free(This);
}
return ref;
@@ -732,9 +735,20 @@ static HRESULT WINAPI ShellLinkObject_Invoke(IShellLinkDual2 *iface, DISPID disp
static HRESULT WINAPI ShellLinkObject_get_Path(IShellLinkDual2 *iface, BSTR *pbs)
{
- FIXME("(%p, %p)\n", iface, pbs);
+ ShellLinkObjectImpl *This = impl_from_IShellLinkDual(iface);
+ WCHAR path[MAX_PATH];
+ HRESULT hr;
- return E_NOTIMPL;
+ TRACE("(%p, %p)\n", iface, pbs);
+
+ *pbs = NULL;
+
+ hr = IShellLinkW_GetPath(This->shell_link, path, MAX_PATH, NULL, 0);
+ if (hr != S_OK)
+ return hr;
+
+ *pbs = SysAllocString(path);
+ return hr;
}
static HRESULT WINAPI ShellLinkObject_put_Path(IShellLinkDual2 *iface, BSTR bs)
@@ -878,11 +892,13 @@ static const IShellLinkDual2Vtbl ShellLinkObjectVtbl = {
ShellLinkObject_get_Target,
};
-static HRESULT ShellLinkObject_Constructor(IShellLinkDual2 **link)
+static HRESULT ShellLinkObject_Constructor(FolderItemImpl *item, IShellLinkDual2 **link)
{
+ HRESULT hr;
+ IPersistFile *persist_file = NULL;
ShellLinkObjectImpl *This;
- FIXME("(%p)\n", link);
+ TRACE("(%p, %p)\n", item, link);
*link = NULL;
@@ -891,6 +907,33 @@ static HRESULT ShellLinkObject_Constructor(IShellLinkDual2 **link)
This->IShellLinkDual2_iface.lpVtbl = &ShellLinkObjectVtbl;
This->ref = 1;
+ This->shell_link = NULL;
+ hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IShellLinkW, (LPVOID*)&This->shell_link);
+ if (FAILED(hr))
+ {
+ heap_free(This);
+ return hr;
+ }
+
+ hr = IShellLinkW_QueryInterface(This->shell_link, &IID_IPersistFile,
+ (LPVOID*)&persist_file);
+ if (FAILED(hr))
+ {
+ IShellLinkW_Release(This->shell_link);
+ heap_free(This);
+ return hr;
+ }
+
+ hr = IPersistFile_Load(persist_file, item->path, STGM_READ);
+ IPersistFile_Release(persist_file);
+ if (FAILED(hr))
+ {
+ IShellLinkW_Release(This->shell_link);
+ heap_free(This);
+ return hr;
+ }
+
*link = (IShellLinkDual2 *)&This->IShellLinkDual2_iface;
return S_OK;
}
@@ -1092,7 +1135,7 @@ static HRESULT WINAPI FolderItemImpl_get_GetLink(FolderItem2 *iface,
if (!(This->attributes & SFGAO_LINK))
return E_NOTIMPL;
- hr = ShellLinkObject_Constructor(&link);
+ hr = ShellLinkObject_Constructor(This, &link);
if (hr != S_OK)
return hr;
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c
index 9bd2cfd7155..8a9b8690b06 100644
--- a/dlls/shell32/tests/shelldispatch.c
+++ b/dlls/shell32/tests/shelldispatch.c
@@ -1481,7 +1481,7 @@ static void test_ShellLinkObject(void)
str = NULL;
hr = IShellLinkDual2_get_Path(sld, &str);
- todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
if (hr == S_OK) {
ok(!wcscmp(str, empty_path), "got %s (wanted %s)\n",
wine_dbgstr_w(str), wine_dbgstr_w(empty_path));
More information about the wine-cvs
mailing list