wshom: Implement LocationPath property for shortcut.

This commit is contained in:
Nikolay Sivov 2014-02-09 17:52:34 +04:00 committed by Alexandre Julliard
parent 0e73e478ff
commit 9239b86037
2 changed files with 48 additions and 4 deletions

View File

@ -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)

View File

@ -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);