Nikolay Sivov : wshom.ocx: Implement CurrentDirectory() property.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Mar 9 08:43:17 CDT 2015
Module: wine
Branch: master
Commit: b9819b0b8ed6d92421349c9116f07b559ae7bb29
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b9819b0b8ed6d92421349c9116f07b559ae7bb29
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sat Mar 7 16:40:52 2015 +0300
wshom.ocx: Implement CurrentDirectory() property.
---
dlls/wshom.ocx/shell.c | 33 +++++++++++++++++++++++++++++----
dlls/wshom.ocx/tests/wshom.c | 25 +++++++++++++++++++++++++
2 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/dlls/wshom.ocx/shell.c b/dlls/wshom.ocx/shell.c
index 422f89b..c164b70 100644
--- a/dlls/wshom.ocx/shell.c
+++ b/dlls/wshom.ocx/shell.c
@@ -1329,14 +1329,39 @@ static HRESULT WINAPI WshShell3_Exec(IWshShell3 *iface, BSTR command, IWshExec *
static HRESULT WINAPI WshShell3_get_CurrentDirectory(IWshShell3 *iface, BSTR *dir)
{
- FIXME("(%p): stub\n", dir);
- return E_NOTIMPL;
+ DWORD ret;
+
+ TRACE("(%p)\n", dir);
+
+ ret = GetCurrentDirectoryW(0, NULL);
+ if (!ret)
+ return HRESULT_FROM_WIN32(GetLastError());
+
+ *dir = SysAllocStringLen(NULL, ret-1);
+ if (!*dir)
+ return E_OUTOFMEMORY;
+
+ ret = GetCurrentDirectoryW(ret, *dir);
+ if (!ret) {
+ SysFreeString(*dir);
+ *dir = NULL;
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+
+ return S_OK;
}
static HRESULT WINAPI WshShell3_put_CurrentDirectory(IWshShell3 *iface, BSTR dir)
{
- FIXME("(%s): stub\n", debugstr_w(dir));
- return E_NOTIMPL;
+ TRACE("(%s)\n", debugstr_w(dir));
+
+ if (!dir)
+ return E_INVALIDARG;
+
+ if (!SetCurrentDirectoryW(dir))
+ return HRESULT_FROM_WIN32(GetLastError());
+
+ return S_OK;
}
static const IWshShell3Vtbl WshShell3Vtbl = {
diff --git a/dlls/wshom.ocx/tests/wshom.c b/dlls/wshom.ocx/tests/wshom.c
index 888023f..0a69af3 100644
--- a/dlls/wshom.ocx/tests/wshom.c
+++ b/dlls/wshom.ocx/tests/wshom.c
@@ -39,6 +39,8 @@ static void test_wshshell(void)
static const WCHAR pathW[] = {'%','P','A','T','H','%',0};
static const WCHAR sysW[] = {'S','Y','S','T','E','M',0};
static const WCHAR path2W[] = {'P','A','T','H',0};
+ static const WCHAR dummydirW[] = {'d','e','a','d','p','a','r','r','o','t',0};
+ static const WCHAR emptyW[] = {'e','m','p','t','y',0};
IWshEnvironment *env;
IWshShell3 *sh3;
IDispatchEx *dispex;
@@ -209,6 +211,29 @@ static void test_wshshell(void)
SysFreeString(str);
+ /* current directory */
+if (0) /* crashes on native */
+ hr = IWshShell3_get_CurrentDirectory(sh3, NULL);
+
+ str = NULL;
+ hr = IWshShell3_get_CurrentDirectory(sh3, &str);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(str && str[0] != 0, "got empty string\n");
+ SysFreeString(str);
+
+ hr = IWshShell3_put_CurrentDirectory(sh3, NULL);
+ ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+ str = SysAllocString(emptyW);
+ hr = IWshShell3_put_CurrentDirectory(sh3, str);
+ ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
+ SysFreeString(str);
+
+ str = SysAllocString(dummydirW);
+ hr = IWshShell3_put_CurrentDirectory(sh3, str);
+ ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
+ SysFreeString(str);
+
IWshCollection_Release(coll);
IDispatch_Release(disp);
IWshShell3_Release(sh3);
More information about the wine-cvs
mailing list