Module: wine Branch: master Commit: 2b1f2001b153190bbd3bb138684149f672a0bf12 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2b1f2001b153190bbd3bb13868...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed Feb 5 09:29:19 2014 +0400
wshom: Implement get_WorkingDirectory(), handle allocation failures.
---
dlls/wshom.ocx/shell.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/dlls/wshom.ocx/shell.c b/dlls/wshom.ocx/shell.c index 2dc2bbe..ea9caba 100644 --- a/dlls/wshom.ocx/shell.c +++ b/dlls/wshom.ocx/shell.c @@ -409,7 +409,7 @@ static HRESULT WINAPI WshShortcut_get_Arguments(IWshShortcut *iface, BSTR *Argum return hr;
*Arguments = SysAllocString(buffW); - return S_OK; + return *Arguments ? S_OK : E_OUTOFMEMORY; }
static HRESULT WINAPI WshShortcut_put_Arguments(IWshShortcut *iface, BSTR Arguments) @@ -501,14 +501,26 @@ static HRESULT WINAPI WshShortcut_put_WindowStyle(IWshShortcut *iface, int ShowC static HRESULT WINAPI WshShortcut_get_WorkingDirectory(IWshShortcut *iface, BSTR *WorkingDirectory) { WshShortcut *This = impl_from_IWshShortcut(iface); - FIXME("(%p)->(%p): stub\n", This, WorkingDirectory); - return E_NOTIMPL; + WCHAR buffW[MAX_PATH]; + HRESULT hr; + + TRACE("(%p)->(%p)\n", This, WorkingDirectory); + + if (!WorkingDirectory) + return E_POINTER; + + *WorkingDirectory = NULL; + hr = IShellLinkW_GetWorkingDirectory(This->link, buffW, sizeof(buffW)/sizeof(WCHAR)); + if (FAILED(hr)) return hr; + + *WorkingDirectory = SysAllocString(buffW); + return *WorkingDirectory ? S_OK : E_OUTOFMEMORY; }
static HRESULT WINAPI WshShortcut_put_WorkingDirectory(IWshShortcut *iface, BSTR WorkingDirectory) { WshShortcut *This = impl_from_IWshShortcut(iface); - TRACE("(%p)->(%s): stub\n", This, debugstr_w(WorkingDirectory)); + TRACE("(%p)->(%s)\n", This, debugstr_w(WorkingDirectory)); return IShellLinkW_SetWorkingDirectory(This->link, WorkingDirectory); }
@@ -584,6 +596,13 @@ static HRESULT WshShortcut_Create(const WCHAR *path, IDispatch **shortcut) }
This->path_link = SysAllocString(path); + if (!This->path_link) + { + IShellLinkW_Release(This->link); + HeapFree(GetProcessHeap(), 0, This); + return E_OUTOFMEMORY; + } + *shortcut = (IDispatch*)&This->IWshShortcut_iface;
return S_OK;