wshom.ocx: Implement CurrentDirectory() property.
This commit is contained in:
parent
99afcdff2d
commit
b9819b0b8e
|
@ -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 = {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue