Module: wine Branch: master Commit: 9239b8603768a97bff26888e08c7aef5c99dcea5 URL: http://source.winehq.org/git/wine.git/?a=commit;h=9239b8603768a97bff26888e08...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Sun Feb 9 17:52:34 2014 +0400
wshom: Implement LocationPath property for shortcut.
---
dlls/wshom.ocx/shell.c | 49 ++++++++++++++++++++++++++++++++++++++---- dlls/wshom.ocx/tests/wshom.c | 3 +++ 2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/dlls/wshom.ocx/shell.c b/dlls/wshom.ocx/shell.c index ea9caba..92733cc 100644 --- a/dlls/wshom.ocx/shell.c +++ b/dlls/wshom.ocx/shell.c @@ -451,16 +451,57 @@ static HRESULT WINAPI WshShortcut_put_Hotkey(IWshShortcut *iface, BSTR Hotkey)
static HRESULT WINAPI WshShortcut_get_IconLocation(IWshShortcut *iface, BSTR *IconPath) { + static const WCHAR fmtW[] = {'%','s',',',' ','%','d',0}; WshShortcut *This = impl_from_IWshShortcut(iface); - FIXME("(%p)->(%p): stub\n", This, IconPath); - return E_NOTIMPL; + WCHAR buffW[MAX_PATH], pathW[MAX_PATH]; + INT icon = 0; + HRESULT hr; + + TRACE("(%p)->(%p)\n", This, IconPath); + + if (!IconPath) + return E_POINTER; + + hr = IShellLinkW_GetIconLocation(This->link, buffW, sizeof(buffW)/sizeof(WCHAR), &icon); + if (FAILED(hr)) return hr; + + sprintfW(pathW, fmtW, buffW, icon); + *IconPath = SysAllocString(pathW); + if (!*IconPath) return E_OUTOFMEMORY; + + return S_OK; }
static HRESULT WINAPI WshShortcut_put_IconLocation(IWshShortcut *iface, BSTR IconPath) { WshShortcut *This = impl_from_IWshShortcut(iface); - FIXME("(%p)->(%s): stub\n", This, debugstr_w(IconPath)); - return E_NOTIMPL; + HRESULT hr; + WCHAR *ptr; + BSTR path; + INT icon; + + TRACE("(%p)->(%s)\n", This, debugstr_w(IconPath)); + + /* scan for icon id */ + ptr = strrchrW(IconPath, ','); + if (!ptr) + { + WARN("icon index not found\n"); + return E_FAIL; + } + + path = SysAllocStringLen(IconPath, ptr-IconPath); + + /* skip spaces if any */ + while (isspaceW(*++ptr)) + ; + + icon = atoiW(ptr); + + hr = IShellLinkW_SetIconLocation(This->link, path, icon); + SysFreeString(path); + + return hr; }
static HRESULT WINAPI WshShortcut_put_RelativePath(IWshShortcut *iface, BSTR rhs) diff --git a/dlls/wshom.ocx/tests/wshom.c b/dlls/wshom.ocx/tests/wshom.c index 0e01304..5f6e79d 100644 --- a/dlls/wshom.ocx/tests/wshom.c +++ b/dlls/wshom.ocx/tests/wshom.c @@ -116,6 +116,9 @@ static void test_wshshell(void) hr = IWshShortcut_get_Arguments(shcut, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr);
+ hr = IWshShortcut_get_IconLocation(shcut, NULL); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + IWshShortcut_Release(shcut); IDispatch_Release(shortcut);