From f471883ade5bbb5ca1443a5fc7d451062f96595e Mon Sep 17 00:00:00 2001 From: Andrew Bogott Date: Wed, 10 Nov 2010 23:55:48 -0600 Subject: [PATCH] shdocvw: Test read/write of a couple of properties on IUniformResourceLocator. --- dlls/shdocvw/tests/intshcut.c | 58 +++++++++++++++++++++++++++++++++++ include/shlobj.h | 17 ++++++++++ 2 files changed, 75 insertions(+) diff --git a/dlls/shdocvw/tests/intshcut.c b/dlls/shdocvw/tests/intshcut.c index af346143d37..4cf289d2c94 100644 --- a/dlls/shdocvw/tests/intshcut.c +++ b/dlls/shdocvw/tests/intshcut.c @@ -173,6 +173,63 @@ static BOOL check_ie(void) return TRUE; } +static void test_ReadAndWriteProperties(void) +{ + HRESULT hr; + IUniformResourceLocatorA *urlA; + IPropertySetStorage *pPropSetStg; + + hr = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_ALL, &IID_IUniformResourceLocatorA, (void**)&urlA); + if (hr == S_OK) + { + WCHAR iconPath[] = {'f','i','l','e',':','/','/','/','C',':','/','a','r','b','i','t','r','a','r','y','/','i','c','o','n','/','p','a','t','h',0}; + int iconIndex = 7; + IPropertyStorage *pPropStgWrite; + IPropertyStorage *pPropStgRead; + PROPSPEC ps[2]; + PROPVARIANT pv[2]; + PROPVARIANT pvread[2]; + ps[0].ulKind = PRSPEC_PROPID; + ps[0].propid = PID_IS_ICONFILE; + ps[1].ulKind = PRSPEC_PROPID; + ps[1].propid = PID_IS_ICONINDEX; + pv[0].vt = VT_LPWSTR; + pv[0].pwszVal = (void *) iconPath; + pv[1].vt = VT_I4; + pv[1].iVal = iconIndex; + + hr = urlA->lpVtbl->QueryInterface(urlA, &IID_IPropertySetStorage, (void **) &pPropSetStg); + ok(hr == S_OK, "Unable to get an IPropertySetStorage, hr=0x%x\n", hr); + + hr = IPropertySetStorage_Open(pPropSetStg, &FMTID_Intshcut, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &pPropStgWrite); + ok(hr == S_OK, "Unable to get an IPropertyStorage for writing, hr=0x%x\n", hr); + + hr = IPropertyStorage_WriteMultiple(pPropStgWrite, 2, ps, pv, 0); + ok(hr == S_OK, "Unable to set properties, hr=0x%x\n", hr); + + hr = IPropertyStorage_Commit(pPropStgWrite, STGC_DEFAULT); + ok(hr == S_OK, "Failed to commit properties, hr=0x%x\n", hr); + + pPropStgWrite->lpVtbl->Release(pPropStgWrite); + + hr = IPropertySetStorage_Open(pPropSetStg, &FMTID_Intshcut, STGM_READ | STGM_SHARE_EXCLUSIVE, &pPropStgRead); + ok(hr == S_OK, "Unable to get an IPropertyStorage for reading, hr=0x%x\n", hr); + + hr = IPropertyStorage_ReadMultiple(pPropStgRead, 2, ps, pvread); + ok(hr == S_OK, "Unable to read properties, hr=0x%x\n", hr); + + ok(pvread[1].iVal == iconIndex, "Read wrong icon index: %d\n", pvread[1].iVal); + + ok(lstrcmpW(pvread[0].pwszVal, iconPath) == 0, "Wrong icon path read: %s\n",wine_dbgstr_w(pvread[0].pwszVal)); + + IPropertyStorage_Release(pPropStgRead); + IPropertySetStorage_Release(pPropSetStg); + urlA->lpVtbl->Release(urlA); + } + else + skip("could not create a CLSID_InternetShortcut for property tests, hr=0x%x\n", hr); +} + static void test_NullURLs(void) { HRESULT hr; @@ -231,6 +288,7 @@ static void test_InternetShortcut(void) test_QueryInterface(); test_NullURLs(); test_SetURLFlags(); + test_ReadAndWriteProperties(); } } diff --git a/include/shlobj.h b/include/shlobj.h index f3aa3b6532d..aab93fce728 100644 --- a/include/shlobj.h +++ b/include/shlobj.h @@ -1661,6 +1661,23 @@ BOOL WINAPI DAD_DragLeave(void); BOOL WINAPI DAD_AutoScroll(HWND,AUTO_SCROLL_DATA*,LPPOINT); HRESULT WINAPI SHDoDragDrop(HWND,IDataObject*,IDropSource*,DWORD,LPDWORD); +/**************************************************************************** + * Internet shortcut properties + */ + +#define PID_IS_URL 2 +#define PID_IS_NAME 4 +#define PID_IS_WORKINGDIR 5 +#define PID_IS_HOTKEY 6 +#define PID_IS_SHOWCMD 7 +#define PID_IS_ICONINDEX 8 +#define PID_IS_ICONFILE 9 +#define PID_IS_WHATSNEW 10 +#define PID_IS_AUTHOR 11 +#define PID_IS_DESCRIPTION 12 +#define PID_IS_COMMENT 13 + + LPITEMIDLIST WINAPI ILAppendID(LPITEMIDLIST,LPCSHITEMID,BOOL); LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST); LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST);