2011-09-20 11:55:52 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#define CONST_VTABLE
|
|
|
|
|
|
|
|
#include <initguid.h>
|
|
|
|
#include <ole2.h>
|
|
|
|
#include <dispex.h>
|
|
|
|
|
2011-12-30 14:13:40 +01:00
|
|
|
#include "wshom.h"
|
2011-09-20 11:55:52 +02:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
2011-12-30 22:46:43 +01:00
|
|
|
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
|
|
|
|
2011-12-30 14:13:40 +01:00
|
|
|
#define EXPECT_HR(hr,hr_exp) \
|
|
|
|
ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
|
2011-09-20 11:55:52 +02:00
|
|
|
|
|
|
|
static void test_wshshell(void)
|
|
|
|
{
|
2011-12-30 22:46:43 +01:00
|
|
|
static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0};
|
2012-01-02 13:09:52 +01:00
|
|
|
static const WCHAR lnk1W[] = {'f','i','l','e','.','l','n','k',0};
|
2013-10-27 09:28:06 +01:00
|
|
|
static const WCHAR pathW[] = {'%','P','A','T','H','%',0};
|
2011-12-30 14:13:40 +01:00
|
|
|
IWshShell3 *sh3;
|
2011-12-29 10:16:22 +01:00
|
|
|
IDispatchEx *dispex;
|
2011-12-30 14:13:40 +01:00
|
|
|
IWshCollection *coll;
|
2012-01-02 13:09:52 +01:00
|
|
|
IDispatch *disp, *shortcut;
|
2014-02-04 07:24:30 +01:00
|
|
|
IUnknown *shell;
|
2011-12-30 14:13:40 +01:00
|
|
|
IFolderCollection *folders;
|
2014-02-04 07:24:30 +01:00
|
|
|
IWshShortcut *shcut;
|
2011-12-30 14:13:40 +01:00
|
|
|
ITypeInfo *ti;
|
|
|
|
HRESULT hr;
|
|
|
|
TYPEATTR *tattr;
|
2011-12-30 22:46:43 +01:00
|
|
|
DISPPARAMS dp;
|
|
|
|
EXCEPINFO ei;
|
|
|
|
VARIANT arg, res;
|
|
|
|
BSTR str;
|
|
|
|
UINT err;
|
2011-09-20 11:55:52 +02:00
|
|
|
|
2011-12-30 14:13:40 +01:00
|
|
|
hr = CoCreateInstance(&CLSID_WshShell, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
2011-09-20 11:55:52 +02:00
|
|
|
&IID_IDispatch, (void**)&disp);
|
2011-12-30 14:13:40 +01:00
|
|
|
if(FAILED(hr)) {
|
|
|
|
win_skip("Could not create WshShell object: %08x\n", hr);
|
2011-09-20 11:55:52 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-30 14:13:40 +01:00
|
|
|
hr = IDispatch_QueryInterface(disp, &IID_IWshShell3, (void**)&shell);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
IDispatch_Release(disp);
|
2011-09-20 11:55:52 +02:00
|
|
|
|
2011-12-30 14:13:40 +01:00
|
|
|
hr = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
|
|
|
|
EXPECT_HR(hr, E_NOINTERFACE);
|
|
|
|
|
2012-08-24 11:23:43 +02:00
|
|
|
hr = IUnknown_QueryInterface(shell, &IID_IWshShell3, (void**)&sh3);
|
2011-12-30 14:13:40 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IWshShell3_get_SpecialFolders(sh3, &coll);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IWshCollection_QueryInterface(coll, &IID_IFolderCollection, (void**)&folders);
|
|
|
|
EXPECT_HR(hr, E_NOINTERFACE);
|
|
|
|
|
|
|
|
hr = IWshCollection_QueryInterface(coll, &IID_IDispatch, (void**)&disp);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = IDispatch_GetTypeInfo(disp, 0, 0, &ti);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
|
|
|
|
hr = ITypeInfo_GetTypeAttr(ti, &tattr);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
2011-12-30 22:46:43 +01:00
|
|
|
ok(IsEqualIID(&tattr->guid, &IID_IWshCollection), "got wrong type guid\n");
|
2011-12-30 14:13:40 +01:00
|
|
|
ITypeInfo_ReleaseTypeAttr(ti, tattr);
|
|
|
|
|
2011-12-30 22:46:43 +01:00
|
|
|
/* 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);
|
|
|
|
ok(V_VT(&res) == VT_BSTR, "got res type %d\n", V_VT(&res));
|
2012-01-02 13:09:52 +01:00
|
|
|
SysFreeString(str);
|
2011-12-30 22:46:43 +01:00
|
|
|
VariantClear(&res);
|
2011-12-29 10:16:22 +01:00
|
|
|
|
2012-01-02 13:09:52 +01:00
|
|
|
/* CreateShortcut() */
|
|
|
|
str = SysAllocString(lnk1W);
|
|
|
|
hr = IWshShell3_CreateShortcut(sh3, str, &shortcut);
|
|
|
|
EXPECT_HR(hr, S_OK);
|
|
|
|
SysFreeString(str);
|
2014-02-04 07:24:30 +01:00
|
|
|
hr = IDispatch_QueryInterface(shortcut, &IID_IWshShortcut, (void**)&shcut);
|
2012-01-02 13:09:52 +01:00
|
|
|
EXPECT_HR(hr, S_OK);
|
2014-02-04 07:24:30 +01:00
|
|
|
|
|
|
|
hr = IWshShortcut_get_Arguments(shcut, NULL);
|
|
|
|
ok(hr == E_POINTER, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IWshShortcut_Release(shcut);
|
2012-01-02 13:09:52 +01:00
|
|
|
IDispatch_Release(shortcut);
|
|
|
|
|
2013-10-27 09:28:06 +01:00
|
|
|
/* ExpandEnvironmentStrings */
|
|
|
|
hr = IWshShell3_ExpandEnvironmentStrings(sh3, NULL, NULL);
|
|
|
|
ok(hr == E_POINTER, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
str = SysAllocString(pathW);
|
|
|
|
hr = IWshShell3_ExpandEnvironmentStrings(sh3, str, NULL);
|
|
|
|
ok(hr == E_POINTER, "got 0x%08x\n", hr);
|
|
|
|
SysFreeString(str);
|
|
|
|
|
2011-12-30 22:46:43 +01:00
|
|
|
IWshCollection_Release(coll);
|
|
|
|
IDispatch_Release(disp);
|
|
|
|
IWshShell3_Release(sh3);
|
2011-09-20 11:55:52 +02:00
|
|
|
IUnknown_Release(shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(wshom)
|
|
|
|
{
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
|
|
|
test_wshshell();
|
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|