wshom.ocx: Implement IWshCollection::Item() for Desktop folder case.

This commit is contained in:
Nikolay Sivov 2011-12-31 00:46:43 +03:00 committed by Alexandre Julliard
parent 3149386b86
commit 4a068c64d0
4 changed files with 74 additions and 6 deletions

View File

@ -1,5 +1,5 @@
MODULE = wshom.ocx MODULE = wshom.ocx
IMPORTS = uuid oleaut32 IMPORTS = uuid oleaut32 ole32 shell32
C_SRCS = \ C_SRCS = \
shell.c \ shell.c \

View File

@ -19,7 +19,10 @@
#include "wshom_private.h" #include "wshom_private.h"
#include "wshom.h" #include "wshom.h"
#include "shlobj.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(wshom); WINE_DEFAULT_DEBUG_CHANNEL(wshom);
@ -167,8 +170,45 @@ static HRESULT WINAPI WshCollection_Invoke(IWshCollection *iface, DISPID dispIdM
static HRESULT WINAPI WshCollection_Item(IWshCollection *iface, VARIANT *index, VARIANT *value) static HRESULT WINAPI WshCollection_Item(IWshCollection *iface, VARIANT *index, VARIANT *value)
{ {
WshCollection *This = impl_from_IWshCollection(iface); WshCollection *This = impl_from_IWshCollection(iface);
FIXME("(%p)->(%s %p): stub\n", This, debugstr_variant(index), value); static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0};
return E_NOTIMPL; PIDLIST_ABSOLUTE pidl;
WCHAR pathW[MAX_PATH];
int kind = 0;
BSTR folder;
HRESULT hr;
TRACE("(%p)->(%s %p)\n", This, debugstr_variant(index), value);
if (V_VT(index) != VT_BSTR)
{
FIXME("only BSTR index supported, got %d\n", V_VT(index));
return E_NOTIMPL;
}
folder = V_BSTR(index);
if (!strcmpiW(folder, desktopW))
kind = CSIDL_DESKTOP;
else
{
FIXME("folder kind %s not supported\n", debugstr_w(folder));
return E_NOTIMPL;
}
hr = SHGetSpecialFolderLocation(NULL, kind, &pidl);
if (hr != S_OK) return hr;
if (SHGetPathFromIDListW(pidl, pathW))
{
V_VT(value) = VT_BSTR;
V_BSTR(value) = SysAllocString(pathW);
hr = V_BSTR(value) ? S_OK : E_OUTOFMEMORY;
}
else
hr = E_FAIL;
CoTaskMemFree(pidl);
return hr;
} }
static HRESULT WINAPI WshCollection_Count(IWshCollection *iface, LONG *count) static HRESULT WINAPI WshCollection_Count(IWshCollection *iface, LONG *count)

View File

@ -1,5 +1,5 @@
TESTDLL = wshom.ocx TESTDLL = wshom.ocx
IMPORTS = ole32 IMPORTS = oleaut32 ole32
C_SRCS = \ C_SRCS = \
wshom.c wshom.c

View File

@ -26,11 +26,14 @@
#include "wshom.h" #include "wshom.h"
#include "wine/test.h" #include "wine/test.h"
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
#define EXPECT_HR(hr,hr_exp) \ #define EXPECT_HR(hr,hr_exp) \
ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp) ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
static void test_wshshell(void) static void test_wshshell(void)
{ {
static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0};
IWshShell3 *sh3; IWshShell3 *sh3;
IDispatchEx *dispex; IDispatchEx *dispex;
IWshCollection *coll; IWshCollection *coll;
@ -40,6 +43,11 @@ static void test_wshshell(void)
ITypeInfo *ti; ITypeInfo *ti;
HRESULT hr; HRESULT hr;
TYPEATTR *tattr; TYPEATTR *tattr;
DISPPARAMS dp;
EXCEPINFO ei;
VARIANT arg, res;
BSTR str;
UINT err;
hr = CoCreateInstance(&CLSID_WshShell, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, hr = CoCreateInstance(&CLSID_WshShell, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IDispatch, (void**)&disp); &IID_IDispatch, (void**)&disp);
@ -72,11 +80,31 @@ static void test_wshshell(void)
hr = ITypeInfo_GetTypeAttr(ti, &tattr); hr = ITypeInfo_GetTypeAttr(ti, &tattr);
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
ok(IsEqualIID(&tattr->guid, &IID_IWshCollection), "got \n"); ok(IsEqualIID(&tattr->guid, &IID_IWshCollection), "got wrong type guid\n");
ITypeInfo_ReleaseTypeAttr(ti, tattr); ITypeInfo_ReleaseTypeAttr(ti, tattr);
IWshShell3_Release(sh3); /* try to call Item() with normal IDispatch procedure */
str = SysAllocString(desktopW);
V_VT(&arg) = VT_BSTR;
V_BSTR(&arg) = str;
dp.rgvarg = &arg;
dp.rgdispidNamedArgs = NULL;
dp.cArgs = 1;
dp.cNamedArgs = 0;
hr = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 1033, DISPATCH_PROPERTYGET, &dp, &res, &ei, &err);
EXPECT_HR(hr, DISP_E_MEMBERNOTFOUND);
/* try Item() directly, it returns directory path apparently */
V_VT(&res) = VT_EMPTY;
hr = IWshCollection_Item(coll, &arg, &res);
EXPECT_HR(hr, S_OK);
SysFreeString(str);
ok(V_VT(&res) == VT_BSTR, "got res type %d\n", V_VT(&res));
VariantClear(&res);
IWshCollection_Release(coll);
IDispatch_Release(disp);
IWshShell3_Release(sh3);
IUnknown_Release(shell); IUnknown_Release(shell);
} }