2004-10-22 21:52:33 +02:00
|
|
|
/*
|
|
|
|
* Unit tests for shelllinks
|
|
|
|
*
|
|
|
|
* Copyright 2004 Mike McCormack
|
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-10-22 21:52:33 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
2008-07-08 16:17:17 +02:00
|
|
|
#include "initguid.h"
|
|
|
|
#include "windows.h"
|
2004-10-22 21:52:33 +02:00
|
|
|
#include "shlguid.h"
|
|
|
|
#include "shobjidl.h"
|
2005-02-14 12:52:29 +01:00
|
|
|
#include "shlobj.h"
|
2013-10-26 21:10:26 +02:00
|
|
|
#include "shellapi.h"
|
2004-10-22 21:52:33 +02:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
2005-07-24 18:26:53 +02:00
|
|
|
#include "shell32_test.h"
|
|
|
|
|
2008-07-20 14:54:14 +02:00
|
|
|
#ifndef SLDF_HAS_LOGO3ID
|
|
|
|
# define SLDF_HAS_LOGO3ID 0x00000800 /* not available in the Vista SDK */
|
|
|
|
#endif
|
2006-08-09 12:31:26 +02:00
|
|
|
|
2012-06-15 15:20:30 +02:00
|
|
|
static void (WINAPI *pILFree)(LPITEMIDLIST);
|
|
|
|
static BOOL (WINAPI *pILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST);
|
|
|
|
static HRESULT (WINAPI *pSHILCreateFromPath)(LPCWSTR, LPITEMIDLIST *,DWORD*);
|
|
|
|
static HRESULT (WINAPI *pSHDefExtractIconA)(LPCSTR, int, UINT, HICON*, HICON*, UINT);
|
2013-04-25 20:22:06 +02:00
|
|
|
static HRESULT (WINAPI *pSHGetStockIconInfo)(SHSTOCKICONID, UINT, SHSTOCKICONINFO *);
|
2007-08-14 12:11:04 +02:00
|
|
|
static DWORD (WINAPI *pGetLongPathNameA)(LPCSTR, LPSTR, DWORD);
|
2009-07-26 22:35:34 +02:00
|
|
|
static DWORD (WINAPI *pGetShortPathNameA)(LPCSTR, LPSTR, DWORD);
|
2014-03-25 12:53:27 +01:00
|
|
|
static UINT (WINAPI *pSHExtractIconsW)(LPCWSTR, int, int, int, HICON *, UINT *, UINT, UINT);
|
2007-08-14 12:11:04 +02:00
|
|
|
|
2006-08-09 12:31:26 +02:00
|
|
|
static const GUID _IID_IShellLinkDataList = {
|
|
|
|
0x45e2b4ae, 0xb1c3, 0x11d0,
|
|
|
|
{ 0xb9, 0x2f, 0x00, 0xa0, 0xc9, 0x03, 0x12, 0xe1 }
|
|
|
|
};
|
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
/* For some reason SHILCreateFromPath does not work on Win98 and
|
|
|
|
* SHSimpleIDListFromPathA does not work on NT4. But if we call both we
|
|
|
|
* get what we want on all platforms.
|
|
|
|
*/
|
2006-02-22 12:04:02 +01:00
|
|
|
static LPITEMIDLIST (WINAPI *pSHSimpleIDListFromPathAW)(LPCVOID);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
static LPITEMIDLIST path_to_pidl(const char* path)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
|
2006-02-22 12:04:02 +01:00
|
|
|
if (!pSHSimpleIDListFromPathAW)
|
2005-02-14 12:52:29 +01:00
|
|
|
{
|
2007-08-16 13:12:27 +02:00
|
|
|
HMODULE hdll=GetModuleHandleA("shell32.dll");
|
2006-02-22 12:04:02 +01:00
|
|
|
pSHSimpleIDListFromPathAW=(void*)GetProcAddress(hdll, (char*)162);
|
|
|
|
if (!pSHSimpleIDListFromPathAW)
|
2008-10-20 23:05:51 +02:00
|
|
|
win_skip("SHSimpleIDListFromPathAW not found in shell32.dll\n");
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pidl=NULL;
|
2006-02-22 12:04:02 +01:00
|
|
|
/* pSHSimpleIDListFromPathAW maps to A on non NT platforms */
|
|
|
|
if (pSHSimpleIDListFromPathAW && (GetVersion() & 0x80000000))
|
|
|
|
pidl=pSHSimpleIDListFromPathAW(path);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
if (!pidl)
|
|
|
|
{
|
|
|
|
WCHAR* pathW;
|
|
|
|
HRESULT r;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
len=MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
|
|
|
|
pathW=HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, path, -1, pathW, len);
|
|
|
|
|
2006-08-09 12:31:26 +02:00
|
|
|
r=pSHILCreateFromPath(pathW, &pidl, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "SHILCreateFromPath failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, pathW);
|
|
|
|
}
|
|
|
|
return pidl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test manipulation of an IShellLink's properties.
|
|
|
|
*/
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_get_set(void)
|
2004-10-22 21:52:33 +02:00
|
|
|
{
|
|
|
|
HRESULT r;
|
2005-02-14 12:52:29 +01:00
|
|
|
IShellLinkA *sl;
|
2009-09-09 20:24:47 +02:00
|
|
|
IShellLinkW *slW = NULL;
|
2005-02-14 12:52:29 +01:00
|
|
|
char mypath[MAX_PATH];
|
|
|
|
char buffer[INFOTIPSIZE];
|
|
|
|
LPITEMIDLIST pidl, tmp_pidl;
|
2005-06-01 13:04:26 +02:00
|
|
|
const char * str;
|
2005-02-14 12:52:29 +01:00
|
|
|
int i;
|
|
|
|
WORD w;
|
|
|
|
|
|
|
|
r = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IShellLinkA, (LPVOID*)&sl);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "no IID_IShellLinkA (0x%08x)\n", r);
|
|
|
|
if (r != S_OK)
|
2005-02-14 12:52:29 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Test Getting / Setting the description */
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetDescription(sl, buffer, sizeof(buffer));
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetDescription failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
ok(*buffer=='\0', "GetDescription returned '%s'\n", buffer);
|
|
|
|
|
|
|
|
str="Some description";
|
|
|
|
r = IShellLinkA_SetDescription(sl, str);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "SetDescription failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetDescription(sl, buffer, sizeof(buffer));
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetDescription failed (0x%08x)\n", r);
|
2013-10-26 21:10:26 +02:00
|
|
|
ok(strcmp(buffer,str)==0, "GetDescription returned '%s'\n", buffer);
|
2004-10-22 21:52:33 +02:00
|
|
|
|
2010-04-30 17:04:19 +02:00
|
|
|
r = IShellLinkA_SetDescription(sl, NULL);
|
|
|
|
ok(r == S_OK, "SetDescription failed (0x%08x)\n", r);
|
|
|
|
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetDescription(sl, buffer, sizeof(buffer));
|
|
|
|
ok(r == S_OK, "GetDescription failed (0x%08x)\n", r);
|
2013-10-26 21:10:26 +02:00
|
|
|
ok(*buffer=='\0' || broken(strcmp(buffer,str)==0), "GetDescription returned '%s'\n", buffer); /* NT4 */
|
2010-04-30 17:04:19 +02:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
/* Test Getting / Setting the work directory */
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetWorkingDirectory(sl, buffer, sizeof(buffer));
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetWorkingDirectory failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
ok(*buffer=='\0', "GetWorkingDirectory returned '%s'\n", buffer);
|
2004-10-22 21:52:33 +02:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
str="c:\\nonexistent\\directory";
|
|
|
|
r = IShellLinkA_SetWorkingDirectory(sl, str);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "SetWorkingDirectory failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetWorkingDirectory(sl, buffer, sizeof(buffer));
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetWorkingDirectory failed (0x%08x)\n", r);
|
2013-10-26 21:10:26 +02:00
|
|
|
ok(lstrcmpiA(buffer,str)==0, "GetWorkingDirectory returned '%s'\n", buffer);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
2008-01-26 03:05:09 +01:00
|
|
|
/* Test Getting / Setting the path */
|
2005-02-14 12:52:29 +01:00
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
|
2010-03-23 02:21:13 +01:00
|
|
|
todo_wine ok(r == S_FALSE || broken(r == S_OK) /* NT4/W2K */, "GetPath failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
|
|
|
|
|
2009-09-09 20:24:47 +02:00
|
|
|
CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IShellLinkW, (LPVOID*)&slW);
|
2010-12-14 14:05:25 +01:00
|
|
|
if (!slW /* Win9x */ || !pGetLongPathNameA /* NT4 */)
|
|
|
|
skip("SetPath with NULL parameter crashes on Win9x and some NT4\n");
|
2009-09-09 20:24:47 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
IShellLinkW_Release(slW);
|
|
|
|
r = IShellLinkA_SetPath(sl, NULL);
|
2009-09-10 10:12:35 +02:00
|
|
|
ok(r==E_INVALIDARG ||
|
|
|
|
broken(r==S_OK), /* Some Win95 and NT4 */
|
2010-12-14 14:05:25 +01:00
|
|
|
"SetPath returned wrong error (0x%08x)\n", r);
|
2009-09-09 20:24:47 +02:00
|
|
|
}
|
2009-09-09 12:25:44 +02:00
|
|
|
|
2005-02-16 17:27:42 +01:00
|
|
|
r = IShellLinkA_SetPath(sl, "");
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(r==S_OK, "SetPath failed (0x%08x)\n", r);
|
2005-02-16 17:27:42 +01:00
|
|
|
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
|
2010-03-23 02:21:13 +01:00
|
|
|
todo_wine ok(r == S_FALSE, "GetPath failed (0x%08x)\n", r);
|
2005-02-16 17:27:42 +01:00
|
|
|
ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
|
|
|
|
|
2007-06-29 02:56:30 +02:00
|
|
|
/* Win98 returns S_FALSE, but WinXP returns S_OK */
|
2005-02-14 12:52:29 +01:00
|
|
|
str="c:\\nonexistent\\file";
|
|
|
|
r = IShellLinkA_SetPath(sl, str);
|
2007-06-29 02:56:30 +02:00
|
|
|
ok(r==S_FALSE || r==S_OK, "SetPath failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetPath failed (0x%08x)\n", r);
|
2013-10-26 21:10:26 +02:00
|
|
|
ok(lstrcmpiA(buffer,str)==0, "GetPath returned '%s'\n", buffer);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
2008-05-19 21:27:22 +02:00
|
|
|
/* Get some real path to play with */
|
|
|
|
GetWindowsDirectoryA( mypath, sizeof(mypath)-12 );
|
|
|
|
strcat(mypath, "\\regedit.exe");
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
/* Test the interaction of SetPath and SetIDList */
|
|
|
|
tmp_pidl=NULL;
|
|
|
|
r = IShellLinkA_GetIDList(sl, &tmp_pidl);
|
2010-11-11 22:58:12 +01:00
|
|
|
ok(r == S_OK, "GetIDList failed (0x%08x)\n", r);
|
2010-03-23 02:21:13 +01:00
|
|
|
if (r == S_OK)
|
2004-10-22 21:52:33 +02:00
|
|
|
{
|
2008-05-20 11:24:38 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
strcpy(buffer,"garbage");
|
2008-05-20 11:24:38 +02:00
|
|
|
ret = SHGetPathFromIDListA(tmp_pidl, buffer);
|
|
|
|
ok(ret, "SHGetPathFromIDListA failed\n");
|
|
|
|
if (ret)
|
2013-10-26 21:10:26 +02:00
|
|
|
ok(lstrcmpiA(buffer,str)==0, "GetIDList returned '%s'\n", buffer);
|
2010-01-22 13:08:47 +01:00
|
|
|
pILFree(tmp_pidl);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
2004-10-22 21:52:33 +02:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
pidl=path_to_pidl(mypath);
|
|
|
|
ok(pidl!=NULL, "path_to_pidl returned a NULL pidl\n");
|
|
|
|
|
|
|
|
if (pidl)
|
|
|
|
{
|
2010-01-22 13:08:47 +01:00
|
|
|
LPITEMIDLIST second_pidl;
|
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
r = IShellLinkA_SetIDList(sl, pidl);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "SetIDList failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
tmp_pidl=NULL;
|
|
|
|
r = IShellLinkA_GetIDList(sl, &tmp_pidl);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetIDList failed (0x%08x)\n", r);
|
2006-08-09 12:31:26 +02:00
|
|
|
ok(tmp_pidl && pILIsEqual(pidl, tmp_pidl),
|
2005-02-14 12:52:29 +01:00
|
|
|
"GetIDList returned an incorrect pidl\n");
|
|
|
|
|
2010-01-22 13:08:47 +01:00
|
|
|
r = IShellLinkA_GetIDList(sl, &second_pidl);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetIDList failed (0x%08x)\n", r);
|
2010-01-22 13:08:47 +01:00
|
|
|
ok(second_pidl && pILIsEqual(pidl, second_pidl),
|
|
|
|
"GetIDList returned an incorrect pidl\n");
|
|
|
|
ok(second_pidl != tmp_pidl, "pidls are the same\n");
|
|
|
|
|
|
|
|
pILFree(second_pidl);
|
|
|
|
pILFree(tmp_pidl);
|
2006-08-09 12:31:26 +02:00
|
|
|
pILFree(pidl);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetPath failed (0x%08x)\n", r);
|
2008-05-19 21:27:22 +02:00
|
|
|
todo_wine
|
2013-10-26 21:10:26 +02:00
|
|
|
ok(lstrcmpiA(buffer, mypath)==0, "GetPath returned '%s'\n", buffer);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
|
2008-10-09 09:52:17 +02:00
|
|
|
/* test path with quotes (IShellLinkA_SetPath returns S_FALSE on W2K and below and S_OK on XP and above */
|
2006-08-09 13:38:51 +02:00
|
|
|
r = IShellLinkA_SetPath(sl, "\"c:\\nonexistent\\file\"");
|
2007-06-29 02:56:30 +02:00
|
|
|
ok(r==S_FALSE || r == S_OK, "SetPath failed (0x%08x)\n", r);
|
2006-08-09 13:38:51 +02:00
|
|
|
|
2009-07-26 22:35:34 +02:00
|
|
|
strcpy(buffer,"garbage");
|
2006-08-09 13:38:51 +02:00
|
|
|
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(r==S_OK, "GetPath failed (0x%08x)\n", r);
|
2013-10-26 21:10:26 +02:00
|
|
|
ok(!strcmp(buffer, "C:\\nonexistent\\file") ||
|
|
|
|
broken(!strcmp(buffer, "C:\\\"c:\\nonexistent\\file\"")), /* NT4 */
|
2008-10-09 09:52:17 +02:00
|
|
|
"case doesn't match\n");
|
2006-08-09 13:38:51 +02:00
|
|
|
|
|
|
|
r = IShellLinkA_SetPath(sl, "\"c:\\foo");
|
2008-07-20 15:41:48 +02:00
|
|
|
ok(r==S_FALSE || r == S_OK || r == E_INVALIDARG /* Vista */, "SetPath failed (0x%08x)\n", r);
|
2006-08-09 13:38:51 +02:00
|
|
|
|
|
|
|
r = IShellLinkA_SetPath(sl, "\"\"c:\\foo");
|
2008-07-20 15:41:48 +02:00
|
|
|
ok(r==S_FALSE || r == S_OK || r == E_INVALIDARG /* Vista */, "SetPath failed (0x%08x)\n", r);
|
2006-08-09 13:38:51 +02:00
|
|
|
|
|
|
|
r = IShellLinkA_SetPath(sl, "c:\\foo\"");
|
2008-07-20 15:41:48 +02:00
|
|
|
ok(r==S_FALSE || r == S_OK || r == E_INVALIDARG /* Vista */, "SetPath failed (0x%08x)\n", r);
|
2006-08-09 13:38:51 +02:00
|
|
|
|
|
|
|
r = IShellLinkA_SetPath(sl, "\"\"c:\\foo\"");
|
2008-07-20 15:41:48 +02:00
|
|
|
ok(r==S_FALSE || r == S_OK || r == E_INVALIDARG /* Vista */, "SetPath failed (0x%08x)\n", r);
|
2006-08-09 13:38:51 +02:00
|
|
|
|
|
|
|
r = IShellLinkA_SetPath(sl, "\"\"c:\\foo\"\"");
|
2008-07-20 15:41:48 +02:00
|
|
|
ok(r==S_FALSE || r == S_OK || r == E_INVALIDARG /* Vista */, "SetPath failed (0x%08x)\n", r);
|
2006-08-09 13:38:51 +02:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
/* Test Getting / Setting the arguments */
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetArguments(sl, buffer, sizeof(buffer));
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetArguments failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
ok(*buffer=='\0', "GetArguments returned '%s'\n", buffer);
|
|
|
|
|
|
|
|
str="param1 \"spaced param2\"";
|
|
|
|
r = IShellLinkA_SetArguments(sl, str);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "SetArguments failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetArguments(sl, buffer, sizeof(buffer));
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetArguments failed (0x%08x)\n", r);
|
2013-10-26 21:10:26 +02:00
|
|
|
ok(strcmp(buffer,str)==0, "GetArguments returned '%s'\n", buffer);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
2009-11-16 20:09:48 +01:00
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_SetArguments(sl, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "SetArguments failed (0x%08x)\n", r);
|
2009-11-16 20:09:48 +01:00
|
|
|
r = IShellLinkA_GetArguments(sl, buffer, sizeof(buffer));
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetArguments failed (0x%08x)\n", r);
|
2013-10-26 21:10:26 +02:00
|
|
|
ok(!buffer[0] || strcmp(buffer,str)==0, "GetArguments returned '%s'\n", buffer);
|
2009-11-16 20:09:48 +01:00
|
|
|
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_SetArguments(sl, "");
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "SetArguments failed (0x%08x)\n", r);
|
2009-11-16 20:09:48 +01:00
|
|
|
r = IShellLinkA_GetArguments(sl, buffer, sizeof(buffer));
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetArguments failed (0x%08x)\n", r);
|
2009-11-16 20:09:48 +01:00
|
|
|
ok(!buffer[0], "GetArguments returned '%s'\n", buffer);
|
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
/* Test Getting / Setting showcmd */
|
|
|
|
i=0xdeadbeef;
|
|
|
|
r = IShellLinkA_GetShowCmd(sl, &i);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetShowCmd failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
ok(i==SW_SHOWNORMAL, "GetShowCmd returned %d\n", i);
|
|
|
|
|
|
|
|
r = IShellLinkA_SetShowCmd(sl, SW_SHOWMAXIMIZED);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "SetShowCmd failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
i=0xdeadbeef;
|
|
|
|
r = IShellLinkA_GetShowCmd(sl, &i);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetShowCmd failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
ok(i==SW_SHOWMAXIMIZED, "GetShowCmd returned %d'\n", i);
|
|
|
|
|
|
|
|
/* Test Getting / Setting the icon */
|
|
|
|
i=0xdeadbeef;
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetIconLocation failed (0x%08x)\n", r);
|
2010-11-11 22:58:37 +01:00
|
|
|
ok(*buffer=='\0', "GetIconLocation returned '%s'\n", buffer);
|
|
|
|
ok(i==0, "GetIconLocation returned %d\n", i);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
str="c:\\nonexistent\\file";
|
|
|
|
r = IShellLinkA_SetIconLocation(sl, str, 0xbabecafe);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "SetIconLocation failed (0x%08x)\n", r);
|
2004-10-22 21:52:33 +02:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
i=0xdeadbeef;
|
|
|
|
r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetIconLocation failed (0x%08x)\n", r);
|
2013-10-26 21:10:26 +02:00
|
|
|
ok(lstrcmpiA(buffer,str)==0, "GetIconLocation returned '%s'\n", buffer);
|
2005-02-14 12:52:29 +01:00
|
|
|
ok(i==0xbabecafe, "GetIconLocation returned %d'\n", i);
|
|
|
|
|
|
|
|
/* Test Getting / Setting the hot key */
|
|
|
|
w=0xbeef;
|
|
|
|
r = IShellLinkA_GetHotkey(sl, &w);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetHotkey failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
ok(w==0, "GetHotkey returned %d\n", w);
|
|
|
|
|
|
|
|
r = IShellLinkA_SetHotkey(sl, 0x5678);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "SetHotkey failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
w=0xbeef;
|
|
|
|
r = IShellLinkA_GetHotkey(sl, &w);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "GetHotkey failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
ok(w==0x5678, "GetHotkey returned %d'\n", w);
|
|
|
|
|
|
|
|
IShellLinkA_Release(sl);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test saving and loading .lnk files
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define lok ok_(__FILE__, line)
|
2007-06-29 02:55:56 +02:00
|
|
|
#define check_lnk(a,b,c) check_lnk_(__LINE__, (a), (b), (c))
|
2005-02-14 12:52:29 +01:00
|
|
|
|
2005-07-24 18:26:53 +02:00
|
|
|
void create_lnk_(int line, const WCHAR* path, lnk_desc_t* desc, int save_fails)
|
2005-02-14 12:52:29 +01:00
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
IShellLinkA *sl;
|
|
|
|
IPersistFile *pf;
|
|
|
|
|
|
|
|
r = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IShellLinkA, (LPVOID*)&sl);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "no IID_IShellLinkA (0x%08x)\n", r);
|
|
|
|
if (r != S_OK)
|
2005-02-14 12:52:29 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (desc->description)
|
|
|
|
{
|
|
|
|
r = IShellLinkA_SetDescription(sl, desc->description);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "SetDescription failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->workdir)
|
|
|
|
{
|
|
|
|
r = IShellLinkA_SetWorkingDirectory(sl, desc->workdir);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "SetWorkingDirectory failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->path)
|
|
|
|
{
|
|
|
|
r = IShellLinkA_SetPath(sl, desc->path);
|
2006-10-07 20:18:17 +02:00
|
|
|
lok(SUCCEEDED(r), "SetPath failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->pidl)
|
|
|
|
{
|
|
|
|
r = IShellLinkA_SetIDList(sl, desc->pidl);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "SetIDList failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->arguments)
|
|
|
|
{
|
|
|
|
r = IShellLinkA_SetArguments(sl, desc->arguments);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "SetArguments failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->showcmd)
|
|
|
|
{
|
|
|
|
r = IShellLinkA_SetShowCmd(sl, desc->showcmd);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "SetShowCmd failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->icon)
|
|
|
|
{
|
|
|
|
r = IShellLinkA_SetIconLocation(sl, desc->icon, desc->icon_id);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "SetIconLocation failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->hotkey)
|
|
|
|
{
|
|
|
|
r = IShellLinkA_SetHotkey(sl, desc->hotkey);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "SetHotkey failed (0x%08x)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
|
2012-08-24 11:17:20 +02:00
|
|
|
r = IShellLinkA_QueryInterface(sl, &IID_IPersistFile, (void**)&pf);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "no IID_IPersistFile (0x%08x)\n", r);
|
|
|
|
if (r == S_OK)
|
2005-02-14 12:52:29 +01:00
|
|
|
{
|
2010-03-18 22:52:41 +01:00
|
|
|
LPOLESTR str;
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on XP */
|
2011-02-10 22:28:13 +01:00
|
|
|
IPersistFile_GetCurFile(pf, NULL);
|
2010-03-18 22:52:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* test GetCurFile before ::Save */
|
|
|
|
str = (LPWSTR)0xdeadbeef;
|
|
|
|
r = IPersistFile_GetCurFile(pf, &str);
|
2010-03-22 13:29:06 +01:00
|
|
|
lok(r == S_FALSE ||
|
|
|
|
broken(r == S_OK), /* shell32 < 5.0 */
|
|
|
|
"got 0x%08x\n", r);
|
|
|
|
lok(str == NULL, "got %p\n", str);
|
2010-03-18 22:52:41 +01:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
r = IPersistFile_Save(pf, path, TRUE);
|
2016-02-20 14:04:30 +01:00
|
|
|
todo_wine_if (save_fails)
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "save failed (0x%08x)\n", r);
|
2010-03-18 22:52:41 +01:00
|
|
|
|
|
|
|
/* test GetCurFile after ::Save */
|
|
|
|
r = IPersistFile_GetCurFile(pf, &str);
|
|
|
|
lok(r == S_OK, "got 0x%08x\n", r);
|
2010-03-22 13:29:06 +01:00
|
|
|
lok(str != NULL ||
|
|
|
|
broken(str == NULL), /* shell32 < 5.0 */
|
|
|
|
"Didn't expect NULL\n");
|
|
|
|
if (str != NULL)
|
|
|
|
{
|
|
|
|
IMalloc *pmalloc;
|
2010-03-18 22:52:41 +01:00
|
|
|
|
2010-03-22 13:29:06 +01:00
|
|
|
lok(!winetest_strcmpW(path, str), "Expected %s, got %s\n",
|
|
|
|
wine_dbgstr_w(path), wine_dbgstr_w(str));
|
2010-03-18 22:52:41 +01:00
|
|
|
|
2010-03-22 13:29:06 +01:00
|
|
|
SHGetMalloc(&pmalloc);
|
|
|
|
IMalloc_Free(pmalloc, str);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("GetCurFile fails on shell32 < 5.0\n");
|
2010-03-18 22:52:41 +01:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
IPersistFile_Release(pf);
|
|
|
|
}
|
2004-10-22 21:52:33 +02:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
IShellLinkA_Release(sl);
|
|
|
|
}
|
2004-10-22 21:52:33 +02:00
|
|
|
|
2007-06-29 02:55:56 +02:00
|
|
|
static void check_lnk_(int line, const WCHAR* path, lnk_desc_t* desc, int todo)
|
2005-02-14 12:52:29 +01:00
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
IShellLinkA *sl;
|
|
|
|
IPersistFile *pf;
|
|
|
|
char buffer[INFOTIPSIZE];
|
2010-03-18 22:52:41 +01:00
|
|
|
LPOLESTR str;
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
r = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IShellLinkA, (LPVOID*)&sl);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "no IID_IShellLinkA (0x%08x)\n", r);
|
|
|
|
if (r != S_OK)
|
2005-02-14 12:52:29 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
r = IShellLinkA_QueryInterface(sl, &IID_IPersistFile, (LPVOID*)&pf);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "no IID_IPersistFile (0x%08x)\n", r);
|
|
|
|
if (r != S_OK)
|
2005-02-14 12:52:29 +01:00
|
|
|
{
|
|
|
|
IShellLinkA_Release(sl);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-18 22:52:41 +01:00
|
|
|
/* test GetCurFile before ::Load */
|
|
|
|
str = (LPWSTR)0xdeadbeef;
|
|
|
|
r = IPersistFile_GetCurFile(pf, &str);
|
2010-03-22 13:29:06 +01:00
|
|
|
lok(r == S_FALSE ||
|
|
|
|
broken(r == S_OK), /* shell32 < 5.0 */
|
|
|
|
"got 0x%08x\n", r);
|
2010-03-18 22:52:41 +01:00
|
|
|
lok(str == NULL, "got %p\n", str);
|
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
r = IPersistFile_Load(pf, path, STGM_READ);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "load failed (0x%08x)\n", r);
|
2010-03-18 22:52:41 +01:00
|
|
|
|
|
|
|
/* test GetCurFile after ::Save */
|
|
|
|
r = IPersistFile_GetCurFile(pf, &str);
|
|
|
|
lok(r == S_OK, "got 0x%08x\n", r);
|
2010-03-22 13:29:06 +01:00
|
|
|
lok(str != NULL ||
|
|
|
|
broken(str == NULL), /* shell32 < 5.0 */
|
|
|
|
"Didn't expect NULL\n");
|
|
|
|
if (str != NULL)
|
|
|
|
{
|
|
|
|
IMalloc *pmalloc;
|
2010-03-18 22:52:41 +01:00
|
|
|
|
2010-03-22 13:29:06 +01:00
|
|
|
lok(!winetest_strcmpW(path, str), "Expected %s, got %s\n",
|
|
|
|
wine_dbgstr_w(path), wine_dbgstr_w(str));
|
2010-03-18 22:52:41 +01:00
|
|
|
|
2010-03-22 13:29:06 +01:00
|
|
|
SHGetMalloc(&pmalloc);
|
|
|
|
IMalloc_Free(pmalloc, str);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("GetCurFile fails on shell32 < 5.0\n");
|
2010-03-18 22:52:41 +01:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
IPersistFile_Release(pf);
|
2010-03-23 02:21:13 +01:00
|
|
|
if (r != S_OK)
|
2005-02-14 12:52:29 +01:00
|
|
|
{
|
|
|
|
IShellLinkA_Release(sl);
|
|
|
|
return;
|
2004-10-22 21:52:33 +02:00
|
|
|
}
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
if (desc->description)
|
|
|
|
{
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetDescription(sl, buffer, sizeof(buffer));
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "GetDescription failed (0x%08x)\n", r);
|
2016-02-20 14:04:31 +01:00
|
|
|
todo_wine_if ((todo & 0x1) != 0)
|
|
|
|
lok(strcmp(buffer, desc->description)==0, "GetDescription returned '%s' instead of '%s'\n",
|
|
|
|
buffer, desc->description);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->workdir)
|
|
|
|
{
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetWorkingDirectory(sl, buffer, sizeof(buffer));
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "GetWorkingDirectory failed (0x%08x)\n", r);
|
2016-02-20 14:04:31 +01:00
|
|
|
todo_wine_if ((todo & 0x2) != 0)
|
|
|
|
lok(lstrcmpiA(buffer, desc->workdir)==0, "GetWorkingDirectory returned '%s' instead of '%s'\n",
|
|
|
|
buffer, desc->workdir);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->path)
|
|
|
|
{
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
|
2006-10-07 20:18:17 +02:00
|
|
|
lok(SUCCEEDED(r), "GetPath failed (0x%08x)\n", r);
|
2016-02-20 14:04:31 +01:00
|
|
|
todo_wine_if ((todo & 0x4) != 0)
|
|
|
|
lok(lstrcmpiA(buffer, desc->path)==0, "GetPath returned '%s' instead of '%s'\n",
|
|
|
|
buffer, desc->path);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->pidl)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl=NULL;
|
|
|
|
r = IShellLinkA_GetIDList(sl, &pidl);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "GetIDList failed (0x%08x)\n", r);
|
2016-02-20 14:04:31 +01:00
|
|
|
todo_wine_if ((todo & 0x8) != 0)
|
|
|
|
lok(pILIsEqual(pidl, desc->pidl), "GetIDList returned an incorrect pidl\n");
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->showcmd)
|
|
|
|
{
|
|
|
|
int i=0xdeadbeef;
|
|
|
|
r = IShellLinkA_GetShowCmd(sl, &i);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "GetShowCmd failed (0x%08x)\n", r);
|
2016-02-20 14:04:31 +01:00
|
|
|
todo_wine_if ((todo & 0x10) != 0)
|
|
|
|
lok(i==desc->showcmd, "GetShowCmd returned 0x%0x instead of 0x%0x\n",
|
|
|
|
i, desc->showcmd);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->icon)
|
|
|
|
{
|
|
|
|
int i=0xdeadbeef;
|
|
|
|
strcpy(buffer,"garbage");
|
|
|
|
r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "GetIconLocation failed (0x%08x)\n", r);
|
2016-02-20 14:04:31 +01:00
|
|
|
todo_wine_if ((todo & 0x20) != 0) {
|
|
|
|
lok(lstrcmpiA(buffer, desc->icon)==0, "GetIconLocation returned '%s' instead of '%s'\n",
|
|
|
|
buffer, desc->icon);
|
|
|
|
lok(i==desc->icon_id, "GetIconLocation returned 0x%0x instead of 0x%0x\n",
|
|
|
|
i, desc->icon_id);
|
|
|
|
}
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
if (desc->hotkey)
|
|
|
|
{
|
|
|
|
WORD i=0xbeef;
|
|
|
|
r = IShellLinkA_GetHotkey(sl, &i);
|
2010-03-23 02:21:13 +01:00
|
|
|
lok(r == S_OK, "GetHotkey failed (0x%08x)\n", r);
|
2016-02-20 14:04:31 +01:00
|
|
|
todo_wine_if ((todo & 0x40) != 0)
|
|
|
|
lok(i==desc->hotkey, "GetHotkey returned 0x%04x instead of 0x%04x\n",
|
|
|
|
i, desc->hotkey);
|
2005-02-14 12:52:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
IShellLinkA_Release(sl);
|
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_load_save(void)
|
2005-02-14 12:52:29 +01:00
|
|
|
{
|
2008-07-20 15:40:19 +02:00
|
|
|
WCHAR lnkfile[MAX_PATH];
|
|
|
|
char lnkfileA[MAX_PATH];
|
|
|
|
static const char lnkfileA_name[] = "\\test.lnk";
|
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
lnk_desc_t desc;
|
|
|
|
char mypath[MAX_PATH];
|
|
|
|
char mydir[MAX_PATH];
|
2007-02-11 06:08:22 +01:00
|
|
|
char realpath[MAX_PATH];
|
2005-02-14 12:52:29 +01:00
|
|
|
char* p;
|
2007-06-29 02:56:00 +02:00
|
|
|
HANDLE hf;
|
2005-02-14 12:52:29 +01:00
|
|
|
DWORD r;
|
|
|
|
|
2008-05-27 16:57:25 +02:00
|
|
|
if (!pGetLongPathNameA)
|
|
|
|
{
|
2009-02-25 10:28:30 +01:00
|
|
|
win_skip("GetLongPathNameA is not available\n");
|
2008-05-27 16:57:25 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-07-20 15:40:19 +02:00
|
|
|
/* Don't used a fixed path for the test.lnk file */
|
|
|
|
GetTempPathA(MAX_PATH, lnkfileA);
|
|
|
|
lstrcatA(lnkfileA, lnkfileA_name);
|
2008-08-03 22:38:32 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, lnkfileA, -1, lnkfile, MAX_PATH);
|
2008-07-20 15:40:19 +02:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
/* Save an empty .lnk file */
|
|
|
|
memset(&desc, 0, sizeof(desc));
|
2005-02-25 17:19:57 +01:00
|
|
|
create_lnk(lnkfile, &desc, 0);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
/* It should come back as a bunch of empty strings */
|
|
|
|
desc.description="";
|
|
|
|
desc.workdir="";
|
|
|
|
desc.path="";
|
|
|
|
desc.arguments="";
|
|
|
|
desc.icon="";
|
2007-06-29 02:55:56 +02:00
|
|
|
check_lnk(lnkfile, &desc, 0x0);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
/* Point a .lnk file to nonexistent files */
|
|
|
|
desc.description="";
|
|
|
|
desc.workdir="c:\\Nonexitent\\work\\directory";
|
|
|
|
desc.path="c:\\nonexistent\\path";
|
|
|
|
desc.pidl=NULL;
|
|
|
|
desc.arguments="";
|
|
|
|
desc.showcmd=0;
|
|
|
|
desc.icon="c:\\nonexistent\\icon\\file";
|
|
|
|
desc.icon_id=1234;
|
|
|
|
desc.hotkey=0;
|
|
|
|
create_lnk(lnkfile, &desc, 0);
|
2007-06-29 02:55:56 +02:00
|
|
|
check_lnk(lnkfile, &desc, 0x0);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
2013-10-26 21:10:26 +02:00
|
|
|
r=GetModuleFileNameA(NULL, mypath, sizeof(mypath));
|
2007-11-01 15:30:55 +01:00
|
|
|
ok(r<sizeof(mypath), "GetModuleFileName failed (%d)\n", r);
|
2005-02-14 12:52:29 +01:00
|
|
|
strcpy(mydir, mypath);
|
|
|
|
p=strrchr(mydir, '\\');
|
|
|
|
if (p)
|
|
|
|
*p='\0';
|
|
|
|
|
2008-05-26 07:19:54 +02:00
|
|
|
/* IShellLink returns path in long form */
|
2008-06-23 17:22:01 +02:00
|
|
|
if (!pGetLongPathNameA(mypath, realpath, MAX_PATH)) strcpy( realpath, mypath );
|
2008-05-26 07:19:54 +02:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
/* Overwrite the existing lnk file and point it to existing files */
|
|
|
|
desc.description="test 2";
|
|
|
|
desc.workdir=mydir;
|
2008-05-26 07:19:54 +02:00
|
|
|
desc.path=realpath;
|
2005-02-14 12:52:29 +01:00
|
|
|
desc.pidl=NULL;
|
|
|
|
desc.arguments="/option1 /option2 \"Some string\"";
|
|
|
|
desc.showcmd=SW_SHOWNORMAL;
|
|
|
|
desc.icon=mypath;
|
|
|
|
desc.icon_id=0;
|
|
|
|
desc.hotkey=0x1234;
|
|
|
|
create_lnk(lnkfile, &desc, 0);
|
2007-06-29 02:55:56 +02:00
|
|
|
check_lnk(lnkfile, &desc, 0x0);
|
2005-02-14 12:52:29 +01:00
|
|
|
|
2011-01-24 20:46:29 +01:00
|
|
|
/* Test omitting .exe from an absolute path */
|
2011-01-27 11:39:45 +01:00
|
|
|
p=strrchr(realpath, '.');
|
2011-01-24 20:46:29 +01:00
|
|
|
if (p)
|
|
|
|
*p='\0';
|
|
|
|
|
|
|
|
desc.description="absolute path without .exe";
|
|
|
|
desc.workdir=mydir;
|
2011-01-27 11:39:45 +01:00
|
|
|
desc.path=realpath;
|
2011-01-24 20:46:29 +01:00
|
|
|
desc.pidl=NULL;
|
|
|
|
desc.arguments="/option1 /option2 \"Some string\"";
|
|
|
|
desc.showcmd=SW_SHOWNORMAL;
|
|
|
|
desc.icon=mypath;
|
|
|
|
desc.icon_id=0;
|
|
|
|
desc.hotkey=0x1234;
|
|
|
|
create_lnk(lnkfile, &desc, 0);
|
2011-01-27 11:39:45 +01:00
|
|
|
strcat(realpath, ".exe");
|
2011-01-24 20:46:29 +01:00
|
|
|
check_lnk(lnkfile, &desc, 0x4);
|
|
|
|
|
2007-02-11 06:08:22 +01:00
|
|
|
/* Overwrite the existing lnk file and test link to a command on the path */
|
|
|
|
desc.description="command on path";
|
|
|
|
desc.workdir=mypath;
|
|
|
|
desc.path="rundll32.exe";
|
|
|
|
desc.pidl=NULL;
|
|
|
|
desc.arguments="/option1 /option2 \"Some string\"";
|
|
|
|
desc.showcmd=SW_SHOWNORMAL;
|
|
|
|
desc.icon=mypath;
|
|
|
|
desc.icon_id=0;
|
|
|
|
desc.hotkey=0x1234;
|
|
|
|
create_lnk(lnkfile, &desc, 0);
|
|
|
|
/* Check that link is created to proper location */
|
|
|
|
SearchPathA( NULL, desc.path, NULL, MAX_PATH, realpath, NULL);
|
|
|
|
desc.path=realpath;
|
2007-06-29 02:55:56 +02:00
|
|
|
check_lnk(lnkfile, &desc, 0x0);
|
2007-02-11 06:08:22 +01:00
|
|
|
|
2011-01-24 20:46:29 +01:00
|
|
|
/* Test omitting .exe from a command on the path */
|
|
|
|
desc.description="command on path without .exe";
|
|
|
|
desc.workdir=mypath;
|
|
|
|
desc.path="rundll32";
|
|
|
|
desc.pidl=NULL;
|
|
|
|
desc.arguments="/option1 /option2 \"Some string\"";
|
|
|
|
desc.showcmd=SW_SHOWNORMAL;
|
|
|
|
desc.icon=mypath;
|
|
|
|
desc.icon_id=0;
|
|
|
|
desc.hotkey=0x1234;
|
|
|
|
create_lnk(lnkfile, &desc, 0);
|
|
|
|
/* Check that link is created to proper location */
|
|
|
|
SearchPathA( NULL, "rundll32", NULL, MAX_PATH, realpath, NULL);
|
|
|
|
desc.path=realpath;
|
|
|
|
check_lnk(lnkfile, &desc, 0x4);
|
|
|
|
|
2007-06-29 02:56:00 +02:00
|
|
|
/* Create a temporary non-executable file */
|
2013-10-26 21:10:26 +02:00
|
|
|
r=GetTempPathA(sizeof(mypath), mypath);
|
2007-11-01 15:30:55 +01:00
|
|
|
ok(r<sizeof(mypath), "GetTempPath failed (%d), err %d\n", r, GetLastError());
|
2007-08-14 12:11:04 +02:00
|
|
|
r=pGetLongPathNameA(mypath, mydir, sizeof(mydir));
|
2007-11-01 15:30:55 +01:00
|
|
|
ok(r<sizeof(mydir), "GetLongPathName failed (%d), err %d\n", r, GetLastError());
|
2007-06-29 02:56:00 +02:00
|
|
|
p=strrchr(mydir, '\\');
|
|
|
|
if (p)
|
|
|
|
*p='\0';
|
|
|
|
|
|
|
|
strcpy(mypath, mydir);
|
|
|
|
strcat(mypath, "\\test.txt");
|
2013-10-26 21:10:26 +02:00
|
|
|
hf = CreateFileA(mypath, GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
2007-06-29 02:56:00 +02:00
|
|
|
CloseHandle(hf);
|
|
|
|
|
|
|
|
/* Overwrite the existing lnk file and test link to an existing non-executable file */
|
|
|
|
desc.description="non-executable file";
|
|
|
|
desc.workdir=mydir;
|
|
|
|
desc.path=mypath;
|
|
|
|
desc.pidl=NULL;
|
|
|
|
desc.arguments="";
|
|
|
|
desc.showcmd=SW_SHOWNORMAL;
|
|
|
|
desc.icon=mypath;
|
|
|
|
desc.icon_id=0;
|
|
|
|
desc.hotkey=0x1234;
|
|
|
|
create_lnk(lnkfile, &desc, 0);
|
2007-06-29 03:00:30 +02:00
|
|
|
check_lnk(lnkfile, &desc, 0x0);
|
2007-06-29 02:56:00 +02:00
|
|
|
|
2009-07-26 22:35:34 +02:00
|
|
|
r=pGetShortPathNameA(mydir, mypath, sizeof(mypath));
|
2011-02-10 22:28:13 +01:00
|
|
|
ok(r<sizeof(mypath), "GetShortPathName failed (%d), err %d\n", r, GetLastError());
|
|
|
|
|
2009-07-26 22:35:34 +02:00
|
|
|
strcpy(realpath, mypath);
|
|
|
|
strcat(realpath, "\\test.txt");
|
|
|
|
strcat(mypath, "\\\\test.txt");
|
|
|
|
|
|
|
|
/* Overwrite the existing lnk file and test link to a short path with double backslashes */
|
|
|
|
desc.description="non-executable file";
|
|
|
|
desc.workdir=mydir;
|
|
|
|
desc.path=mypath;
|
|
|
|
desc.pidl=NULL;
|
|
|
|
desc.arguments="";
|
|
|
|
desc.showcmd=SW_SHOWNORMAL;
|
|
|
|
desc.icon=mypath;
|
|
|
|
desc.icon_id=0;
|
|
|
|
desc.hotkey=0x1234;
|
|
|
|
create_lnk(lnkfile, &desc, 0);
|
|
|
|
desc.path=realpath;
|
|
|
|
check_lnk(lnkfile, &desc, 0x0);
|
|
|
|
|
2007-06-29 02:56:00 +02:00
|
|
|
r = DeleteFileA(mypath);
|
|
|
|
ok(r, "failed to delete file %s (%d)\n", mypath, GetLastError());
|
|
|
|
|
2011-01-24 20:46:29 +01:00
|
|
|
/* Create a temporary .bat file */
|
|
|
|
strcpy(mypath, mydir);
|
|
|
|
strcat(mypath, "\\test.bat");
|
2013-10-26 21:10:26 +02:00
|
|
|
hf = CreateFileA(mypath, GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
2011-01-24 20:46:29 +01:00
|
|
|
CloseHandle(hf);
|
|
|
|
|
|
|
|
strcpy(realpath, mypath);
|
|
|
|
|
|
|
|
p=strrchr(mypath, '.');
|
|
|
|
if (p)
|
|
|
|
*p='\0';
|
|
|
|
|
|
|
|
/* Try linking to the .bat file without the extension */
|
|
|
|
desc.description="batch file";
|
|
|
|
desc.workdir=mydir;
|
|
|
|
desc.path=mypath;
|
|
|
|
desc.pidl=NULL;
|
|
|
|
desc.arguments="";
|
|
|
|
desc.showcmd=SW_SHOWNORMAL;
|
|
|
|
desc.icon=mypath;
|
|
|
|
desc.icon_id=0;
|
|
|
|
desc.hotkey=0x1234;
|
|
|
|
create_lnk(lnkfile, &desc, 0);
|
|
|
|
desc.path = realpath;
|
|
|
|
check_lnk(lnkfile, &desc, 0x4);
|
|
|
|
|
|
|
|
r = DeleteFileA(realpath);
|
2011-02-10 22:28:13 +01:00
|
|
|
ok(r, "failed to delete file %s (%d)\n", realpath, GetLastError());
|
2011-01-24 20:46:29 +01:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
/* FIXME: Also test saving a .lnk pointing to a pidl that cannot be
|
|
|
|
* represented as a path.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* DeleteFileW is not implemented on Win9x */
|
2008-07-20 15:40:19 +02:00
|
|
|
r=DeleteFileA(lnkfileA);
|
|
|
|
ok(r, "failed to delete link '%s' (%d)\n", lnkfileA, GetLastError());
|
2004-10-22 21:52:33 +02:00
|
|
|
}
|
|
|
|
|
2005-11-04 12:40:58 +01:00
|
|
|
static void test_datalink(void)
|
|
|
|
{
|
|
|
|
static const WCHAR lnk[] = {
|
2009-09-02 12:16:01 +02:00
|
|
|
':',':','{','9','d','b','1','1','8','6','e','-','4','0','d','f','-','1',
|
2005-11-04 12:40:58 +01:00
|
|
|
'1','d','1','-','a','a','8','c','-','0','0','c','0','4','f','b','6','7',
|
2009-09-02 12:16:01 +02:00
|
|
|
'8','6','3','}',':','2','6',',','!','!','g','x','s','f','(','N','g',']',
|
|
|
|
'q','F','`','H','{','L','s','A','C','C','E','S','S','F','i','l','e','s',
|
|
|
|
'>','p','l','T',']','j','I','{','j','f','(','=','1','&','L','[','-','8',
|
|
|
|
'1','-',']',':',':',0 };
|
2005-11-04 12:40:58 +01:00
|
|
|
static const WCHAR comp[] = {
|
|
|
|
'2','6',',','!','!','g','x','s','f','(','N','g',']','q','F','`','H','{',
|
|
|
|
'L','s','A','C','C','E','S','S','F','i','l','e','s','>','p','l','T',']',
|
|
|
|
'j','I','{','j','f','(','=','1','&','L','[','-','8','1','-',']',0 };
|
|
|
|
IShellLinkDataList *dl = NULL;
|
|
|
|
IShellLinkW *sl = NULL;
|
|
|
|
HRESULT r;
|
|
|
|
DWORD flags = 0;
|
|
|
|
EXP_DARWIN_LINK *dar;
|
|
|
|
|
|
|
|
r = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IShellLinkW, (LPVOID*)&sl );
|
2008-11-05 08:20:34 +01:00
|
|
|
ok( r == S_OK ||
|
|
|
|
broken(r == E_NOINTERFACE), /* Win9x */
|
|
|
|
"CoCreateInstance failed (0x%08x)\n", r);
|
2005-11-04 12:40:58 +01:00
|
|
|
if (!sl)
|
2007-06-29 02:56:24 +02:00
|
|
|
{
|
2009-02-25 10:28:30 +01:00
|
|
|
win_skip("no shelllink\n");
|
2005-11-04 12:40:58 +01:00
|
|
|
return;
|
2007-06-29 02:56:24 +02:00
|
|
|
}
|
2005-11-04 12:40:58 +01:00
|
|
|
|
2006-08-09 12:31:26 +02:00
|
|
|
r = IShellLinkW_QueryInterface( sl, &_IID_IShellLinkDataList, (LPVOID*) &dl );
|
2008-11-05 08:20:34 +01:00
|
|
|
ok( r == S_OK ||
|
|
|
|
broken(r == E_NOINTERFACE), /* NT4 */
|
|
|
|
"IShellLinkW_QueryInterface failed (0x%08x)\n", r);
|
2005-11-04 12:40:58 +01:00
|
|
|
|
|
|
|
if (!dl)
|
2007-06-29 02:56:24 +02:00
|
|
|
{
|
2009-02-25 10:28:30 +01:00
|
|
|
win_skip("no datalink interface\n");
|
2008-11-05 08:20:34 +01:00
|
|
|
IShellLinkW_Release( sl );
|
2005-11-04 12:40:58 +01:00
|
|
|
return;
|
2007-06-29 02:56:24 +02:00
|
|
|
}
|
2005-11-04 12:40:58 +01:00
|
|
|
|
|
|
|
flags = 0;
|
2008-02-26 16:28:10 +01:00
|
|
|
r = IShellLinkDataList_GetFlags( dl, &flags );
|
2005-11-04 12:40:58 +01:00
|
|
|
ok( r == S_OK, "GetFlags failed\n");
|
|
|
|
ok( flags == 0, "GetFlags returned wrong flags\n");
|
|
|
|
|
|
|
|
dar = (void*)-1;
|
2008-02-26 16:28:10 +01:00
|
|
|
r = IShellLinkDataList_CopyDataBlock( dl, EXP_DARWIN_ID_SIG, (LPVOID*) &dar );
|
2005-11-04 12:40:58 +01:00
|
|
|
ok( r == E_FAIL, "CopyDataBlock failed\n");
|
|
|
|
ok( dar == NULL, "should be null\n");
|
|
|
|
|
2010-12-14 14:05:25 +01:00
|
|
|
if (!pGetLongPathNameA /* NT4 */)
|
|
|
|
skip("SetPath with NULL parameter crashes on NT4\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = IShellLinkW_SetPath(sl, NULL);
|
|
|
|
ok(r == E_INVALIDARG, "SetPath returned wrong error (0x%08x)\n", r);
|
|
|
|
}
|
2009-09-09 12:25:44 +02:00
|
|
|
|
2005-11-04 12:40:58 +01:00
|
|
|
r = IShellLinkW_SetPath(sl, lnk);
|
2010-12-14 14:05:25 +01:00
|
|
|
ok(r == S_OK, "SetPath failed\n");
|
2005-11-04 12:40:58 +01:00
|
|
|
|
2010-03-18 22:52:41 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* the following crashes */
|
2011-02-10 22:28:13 +01:00
|
|
|
IShellLinkDataList_GetFlags( dl, NULL );
|
2010-03-18 22:52:41 +01:00
|
|
|
}
|
2005-11-04 12:40:58 +01:00
|
|
|
|
|
|
|
flags = 0;
|
2008-02-26 16:28:10 +01:00
|
|
|
r = IShellLinkDataList_GetFlags( dl, &flags );
|
2005-11-04 12:40:58 +01:00
|
|
|
ok( r == S_OK, "GetFlags failed\n");
|
2009-09-02 12:16:01 +02:00
|
|
|
/* SLDF_HAS_LOGO3ID is no longer supported on Vista+, filter it out */
|
|
|
|
ok( (flags & (~ SLDF_HAS_LOGO3ID)) == SLDF_HAS_DARWINID,
|
2005-11-04 12:40:58 +01:00
|
|
|
"GetFlags returned wrong flags\n");
|
|
|
|
|
|
|
|
dar = NULL;
|
2008-02-26 16:28:10 +01:00
|
|
|
r = IShellLinkDataList_CopyDataBlock( dl, EXP_DARWIN_ID_SIG, (LPVOID*) &dar );
|
2005-11-04 12:40:58 +01:00
|
|
|
ok( r == S_OK, "CopyDataBlock failed\n");
|
|
|
|
|
2006-10-03 14:12:18 +02:00
|
|
|
ok( dar && ((DATABLOCK_HEADER*)dar)->dwSignature == EXP_DARWIN_ID_SIG, "signature wrong\n");
|
2005-11-04 12:40:58 +01:00
|
|
|
ok( dar && 0==lstrcmpW(dar->szwDarwinID, comp ), "signature wrong\n");
|
|
|
|
|
|
|
|
LocalFree( dar );
|
|
|
|
|
2012-08-24 11:17:20 +02:00
|
|
|
IShellLinkDataList_Release( dl );
|
2005-11-04 12:40:58 +01:00
|
|
|
IShellLinkW_Release( sl );
|
|
|
|
}
|
|
|
|
|
2009-05-15 22:16:35 +02:00
|
|
|
static void test_shdefextracticon(void)
|
|
|
|
{
|
|
|
|
HICON hiconlarge=NULL, hiconsmall=NULL;
|
|
|
|
HRESULT res;
|
|
|
|
|
|
|
|
if (!pSHDefExtractIconA)
|
|
|
|
{
|
|
|
|
win_skip("SHDefExtractIconA is unavailable\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = pSHDefExtractIconA("shell32.dll", 0, 0, &hiconlarge, &hiconsmall, MAKELONG(16,24));
|
|
|
|
ok(SUCCEEDED(res), "SHDefExtractIconA failed, res=%x\n", res);
|
|
|
|
ok(hiconlarge != NULL, "got null hiconlarge\n");
|
|
|
|
ok(hiconsmall != NULL, "got null hiconsmall\n");
|
|
|
|
DestroyIcon(hiconlarge);
|
|
|
|
DestroyIcon(hiconsmall);
|
|
|
|
|
|
|
|
hiconsmall = NULL;
|
|
|
|
res = pSHDefExtractIconA("shell32.dll", 0, 0, NULL, &hiconsmall, MAKELONG(16,24));
|
|
|
|
ok(SUCCEEDED(res), "SHDefExtractIconA failed, res=%x\n", res);
|
|
|
|
ok(hiconsmall != NULL, "got null hiconsmall\n");
|
|
|
|
DestroyIcon(hiconsmall);
|
|
|
|
|
|
|
|
res = pSHDefExtractIconA("shell32.dll", 0, 0, NULL, NULL, MAKELONG(16,24));
|
|
|
|
ok(SUCCEEDED(res), "SHDefExtractIconA failed, res=%x\n", res);
|
|
|
|
}
|
|
|
|
|
2010-11-11 22:58:37 +01:00
|
|
|
static void test_GetIconLocation(void)
|
|
|
|
{
|
|
|
|
IShellLinkA *sl;
|
|
|
|
const char *str;
|
|
|
|
char buffer[INFOTIPSIZE], mypath[MAX_PATH];
|
|
|
|
int i;
|
|
|
|
HRESULT r;
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
|
|
|
|
r = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IShellLinkA, (LPVOID*)&sl);
|
|
|
|
ok(r == S_OK, "no IID_IShellLinkA (0x%08x)\n", r);
|
|
|
|
if(r != S_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
i = 0xdeadbeef;
|
|
|
|
strcpy(buffer, "garbage");
|
|
|
|
r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
|
|
|
|
ok(r == S_OK, "GetIconLocation failed (0x%08x)\n", r);
|
|
|
|
ok(*buffer == '\0', "GetIconLocation returned '%s'\n", buffer);
|
|
|
|
ok(i == 0, "GetIconLocation returned %d\n", i);
|
|
|
|
|
|
|
|
str = "c:\\some\\path";
|
|
|
|
r = IShellLinkA_SetPath(sl, str);
|
|
|
|
ok(r == S_FALSE || r == S_OK, "SetPath failed (0x%08x)\n", r);
|
|
|
|
|
|
|
|
i = 0xdeadbeef;
|
|
|
|
strcpy(buffer, "garbage");
|
|
|
|
r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
|
|
|
|
ok(r == S_OK, "GetIconLocation failed (0x%08x)\n", r);
|
|
|
|
ok(*buffer == '\0', "GetIconLocation returned '%s'\n", buffer);
|
|
|
|
ok(i == 0, "GetIconLocation returned %d\n", i);
|
|
|
|
|
|
|
|
GetWindowsDirectoryA(mypath, sizeof(mypath) - 12);
|
|
|
|
strcat(mypath, "\\regedit.exe");
|
|
|
|
pidl = path_to_pidl(mypath);
|
|
|
|
r = IShellLinkA_SetIDList(sl, pidl);
|
|
|
|
ok(r == S_OK, "SetPath failed (0x%08x)\n", r);
|
2011-01-18 20:37:14 +01:00
|
|
|
pILFree(pidl);
|
2010-11-11 22:58:37 +01:00
|
|
|
|
|
|
|
i = 0xdeadbeef;
|
|
|
|
strcpy(buffer, "garbage");
|
|
|
|
r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
|
|
|
|
ok(r == S_OK, "GetIconLocation failed (0x%08x)\n", r);
|
|
|
|
ok(*buffer == '\0', "GetIconLocation returned '%s'\n", buffer);
|
|
|
|
ok(i == 0, "GetIconLocation returned %d\n", i);
|
|
|
|
|
|
|
|
str = "c:\\nonexistent\\file";
|
|
|
|
r = IShellLinkA_SetIconLocation(sl, str, 0xbabecafe);
|
|
|
|
ok(r == S_OK, "SetIconLocation failed (0x%08x)\n", r);
|
|
|
|
|
|
|
|
i = 0xdeadbeef;
|
|
|
|
r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
|
|
|
|
ok(r == S_OK, "GetIconLocation failed (0x%08x)\n", r);
|
2013-10-26 21:10:26 +02:00
|
|
|
ok(lstrcmpiA(buffer,str) == 0, "GetIconLocation returned '%s'\n", buffer);
|
2010-11-11 22:58:37 +01:00
|
|
|
ok(i == 0xbabecafe, "GetIconLocation returned %d'\n", i);
|
|
|
|
|
|
|
|
IShellLinkA_Release(sl);
|
|
|
|
}
|
|
|
|
|
2013-04-25 20:22:06 +02:00
|
|
|
static void test_SHGetStockIconInfo(void)
|
|
|
|
{
|
|
|
|
BYTE buffer[sizeof(SHSTOCKICONINFO) + 16];
|
|
|
|
SHSTOCKICONINFO *sii = (SHSTOCKICONINFO *) buffer;
|
|
|
|
HRESULT hr;
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
/* not present before vista */
|
|
|
|
if (!pSHGetStockIconInfo)
|
|
|
|
{
|
|
|
|
win_skip("SHGetStockIconInfo not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* negative values are handled */
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
sii->cbSize = sizeof(SHSTOCKICONINFO);
|
2015-09-16 11:43:48 +02:00
|
|
|
hr = pSHGetStockIconInfo(SIID_INVALID, SHGSI_ICONLOCATION, sii);
|
2013-04-25 20:22:06 +02:00
|
|
|
ok(hr == E_INVALIDARG, "-1: got 0x%x (expected E_INVALIDARG)\n", hr);
|
|
|
|
|
|
|
|
/* max. id for vista is 140 (no definition exists for this value) */
|
2015-09-16 11:43:48 +02:00
|
|
|
for (i = SIID_DOCNOASSOC; i <= SIID_CLUSTEREDDRIVE; i++)
|
2013-04-25 20:22:06 +02:00
|
|
|
{
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
sii->cbSize = sizeof(SHSTOCKICONINFO);
|
|
|
|
hr = pSHGetStockIconInfo(i, SHGSI_ICONLOCATION, sii);
|
|
|
|
|
|
|
|
ok(hr == S_OK,
|
|
|
|
"%3d: got 0x%x, iSysImageIndex: 0x%x, iIcon: 0x%x (expected S_OK)\n",
|
|
|
|
i, hr, sii->iSysImageIndex, sii->iIcon);
|
|
|
|
|
|
|
|
if ((hr == S_OK) && (winetest_debug > 1))
|
|
|
|
trace("%3d: got iSysImageIndex %3d, iIcon %3d and %s\n", i, sii->iSysImageIndex,
|
|
|
|
sii->iIcon, wine_dbgstr_w(sii->szPath));
|
|
|
|
}
|
|
|
|
|
2015-09-16 11:43:48 +02:00
|
|
|
/* test invalid icons indices that are invalid for all platforms */
|
|
|
|
for (i = SIID_MAX_ICONS; i < (SIID_MAX_ICONS + 25) ; i++)
|
2013-04-25 20:22:06 +02:00
|
|
|
{
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
sii->cbSize = sizeof(SHSTOCKICONINFO);
|
|
|
|
hr = pSHGetStockIconInfo(i, SHGSI_ICONLOCATION, sii);
|
2015-09-16 11:43:48 +02:00
|
|
|
ok(hr == E_INVALIDARG, "%3d: got 0x%x (expected E_INVALIDARG)\n", i, hr);
|
|
|
|
todo_wine {
|
|
|
|
ok(sii->iSysImageIndex == -1, "%d: got iSysImageIndex %d\n", i, sii->iSysImageIndex);
|
|
|
|
ok(sii->iIcon == -1, "%d: got iIcon %d\n", i, sii->iIcon);
|
|
|
|
}
|
2013-04-25 20:22:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* test more returned SHSTOCKICONINFO elements without extra flags */
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
sii->cbSize = sizeof(SHSTOCKICONINFO);
|
|
|
|
hr = pSHGetStockIconInfo(SIID_FOLDER, SHGSI_ICONLOCATION, sii);
|
|
|
|
ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
|
|
|
|
ok(!sii->hIcon, "got %p (expected NULL)\n", sii->hIcon);
|
|
|
|
ok(sii->iSysImageIndex == -1, "got %d (expected -1)\n", sii->iSysImageIndex);
|
|
|
|
|
|
|
|
/* the exact size is required of the struct */
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
sii->cbSize = sizeof(SHSTOCKICONINFO) + 2;
|
|
|
|
hr = pSHGetStockIconInfo(SIID_FOLDER, SHGSI_ICONLOCATION, sii);
|
|
|
|
ok(hr == E_INVALIDARG, "+2: got 0x%x, iSysImageIndex: 0x%x, iIcon: 0x%x\n", hr, sii->iSysImageIndex, sii->iIcon);
|
|
|
|
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
sii->cbSize = sizeof(SHSTOCKICONINFO) + 1;
|
|
|
|
hr = pSHGetStockIconInfo(SIID_FOLDER, SHGSI_ICONLOCATION, sii);
|
|
|
|
ok(hr == E_INVALIDARG, "+1: got 0x%x, iSysImageIndex: 0x%x, iIcon: 0x%x\n", hr, sii->iSysImageIndex, sii->iIcon);
|
|
|
|
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
sii->cbSize = sizeof(SHSTOCKICONINFO) - 1;
|
|
|
|
hr = pSHGetStockIconInfo(SIID_FOLDER, SHGSI_ICONLOCATION, sii);
|
|
|
|
ok(hr == E_INVALIDARG, "-1: got 0x%x, iSysImageIndex: 0x%x, iIcon: 0x%x\n", hr, sii->iSysImageIndex, sii->iIcon);
|
|
|
|
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
sii->cbSize = sizeof(SHSTOCKICONINFO) - 2;
|
|
|
|
hr = pSHGetStockIconInfo(SIID_FOLDER, SHGSI_ICONLOCATION, sii);
|
|
|
|
ok(hr == E_INVALIDARG, "-2: got 0x%x, iSysImageIndex: 0x%x, iIcon: 0x%x\n", hr, sii->iSysImageIndex, sii->iIcon);
|
|
|
|
|
|
|
|
/* there is a NULL check for the struct */
|
|
|
|
hr = pSHGetStockIconInfo(SIID_FOLDER, SHGSI_ICONLOCATION, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "NULL: got 0x%x\n", hr);
|
|
|
|
}
|
|
|
|
|
2014-03-25 12:53:27 +01:00
|
|
|
static void test_SHExtractIcons(void)
|
|
|
|
{
|
|
|
|
static const WCHAR notepadW[] = {'n','o','t','e','p','a','d','.','e','x','e',0};
|
|
|
|
static const WCHAR shell32W[] = {'s','h','e','l','l','3','2','.','d','l','l',0};
|
|
|
|
static const WCHAR emptyW[] = {0};
|
|
|
|
UINT ret, ret2;
|
|
|
|
HICON icons[256];
|
|
|
|
UINT ids[256], i;
|
|
|
|
|
|
|
|
if (!pSHExtractIconsW)
|
|
|
|
{
|
|
|
|
win_skip("SHExtractIconsW not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pSHExtractIconsW(emptyW, 0, 16, 16, icons, ids, 1, 0);
|
|
|
|
ok(ret == ~0u, "got %u\n", ret);
|
|
|
|
|
|
|
|
ret = pSHExtractIconsW(notepadW, 0, 16, 16, NULL, NULL, 1, 0);
|
|
|
|
ok(ret == 1 || broken(ret == 2) /* win2k */, "got %u\n", ret);
|
|
|
|
|
|
|
|
icons[0] = (HICON)0xdeadbeef;
|
|
|
|
ret = pSHExtractIconsW(notepadW, 0, 16, 16, icons, NULL, 1, 0);
|
|
|
|
ok(ret == 1, "got %u\n", ret);
|
|
|
|
ok(icons[0] != (HICON)0xdeadbeef, "icon not set\n");
|
|
|
|
DestroyIcon(icons[0]);
|
|
|
|
|
|
|
|
icons[0] = (HICON)0xdeadbeef;
|
|
|
|
ids[0] = 0xdeadbeef;
|
|
|
|
ret = pSHExtractIconsW(notepadW, 0, 16, 16, icons, ids, 1, 0);
|
|
|
|
ok(ret == 1, "got %u\n", ret);
|
|
|
|
ok(icons[0] != (HICON)0xdeadbeef, "icon not set\n");
|
|
|
|
ok(ids[0] != 0xdeadbeef, "id not set\n");
|
|
|
|
DestroyIcon(icons[0]);
|
|
|
|
|
|
|
|
ret = pSHExtractIconsW(shell32W, 0, 16, 16, NULL, NULL, 0, 0);
|
|
|
|
ret2 = pSHExtractIconsW(shell32W, 4, MAKELONG(32,16), MAKELONG(32,16), NULL, NULL, 256, 0);
|
|
|
|
ok(ret && ret == ret2,
|
|
|
|
"icon count should be independent of requested icon sizes and base icon index\n");
|
|
|
|
|
|
|
|
ret = pSHExtractIconsW(shell32W, 0, 16, 16, icons, ids, 0, 0);
|
|
|
|
ok(ret == ~0u || !ret /* < vista */, "got %u\n", ret);
|
|
|
|
|
|
|
|
ret = pSHExtractIconsW(shell32W, 0, 16, 16, icons, ids, 3, 0);
|
|
|
|
ok(ret == 3, "got %u\n", ret);
|
|
|
|
for (i = 0; i < ret; i++) DestroyIcon(icons[i]);
|
|
|
|
|
|
|
|
/* count must be a multiple of two when getting two sizes */
|
|
|
|
ret = pSHExtractIconsW(shell32W, 0, MAKELONG(16,32), MAKELONG(16,32), icons, ids, 3, 0);
|
|
|
|
ok(!ret /* vista */ || ret == 4, "got %u\n", ret);
|
|
|
|
for (i = 0; i < ret; i++) DestroyIcon(icons[i]);
|
|
|
|
|
|
|
|
ret = pSHExtractIconsW(shell32W, 0, MAKELONG(16,32), MAKELONG(16,32), icons, ids, 4, 0);
|
|
|
|
ok(ret == 4, "got %u\n", ret);
|
|
|
|
for (i = 0; i < ret; i++) DestroyIcon(icons[i]);
|
|
|
|
}
|
|
|
|
|
2014-12-22 13:18:20 +01:00
|
|
|
static void test_propertystore(void)
|
|
|
|
{
|
|
|
|
IShellLinkA *linkA;
|
|
|
|
IShellLinkW *linkW;
|
|
|
|
IPropertyStore *ps;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IShellLinkA, (void**)&linkA);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IShellLinkA_QueryInterface(linkA, &IID_IShellLinkW, (void**)&linkW);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IShellLinkA_QueryInterface(linkA, &IID_IPropertyStore, (void**)&ps);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
IPropertyStoreCache *pscache;
|
|
|
|
|
|
|
|
IPropertyStore_Release(ps);
|
|
|
|
|
|
|
|
hr = IShellLinkW_QueryInterface(linkW, &IID_IPropertyStore, (void**)&ps);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IPropertyStore_QueryInterface(ps, &IID_IPropertyStoreCache, (void**)&pscache);
|
|
|
|
ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IPropertyStore_Release(ps);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("IShellLink doesn't support IPropertyStore.\n");
|
|
|
|
|
|
|
|
IShellLinkA_Release(linkA);
|
|
|
|
IShellLinkW_Release(linkW);
|
|
|
|
}
|
|
|
|
|
2004-10-22 21:52:33 +02:00
|
|
|
START_TEST(shelllink)
|
|
|
|
{
|
2005-02-14 12:52:29 +01:00
|
|
|
HRESULT r;
|
2007-08-14 12:11:04 +02:00
|
|
|
HMODULE hmod = GetModuleHandleA("shell32.dll");
|
|
|
|
HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
|
2006-08-09 12:31:26 +02:00
|
|
|
|
2012-06-15 15:20:30 +02:00
|
|
|
pILFree = (void *)GetProcAddress(hmod, (LPSTR)155);
|
|
|
|
pILIsEqual = (void *)GetProcAddress(hmod, (LPSTR)21);
|
|
|
|
pSHILCreateFromPath = (void *)GetProcAddress(hmod, (LPSTR)28);
|
|
|
|
pSHDefExtractIconA = (void *)GetProcAddress(hmod, "SHDefExtractIconA");
|
2013-04-25 20:22:06 +02:00
|
|
|
pSHGetStockIconInfo = (void *)GetProcAddress(hmod, "SHGetStockIconInfo");
|
2007-08-14 12:11:04 +02:00
|
|
|
pGetLongPathNameA = (void *)GetProcAddress(hkernel32, "GetLongPathNameA");
|
2009-07-26 22:35:34 +02:00
|
|
|
pGetShortPathNameA = (void *)GetProcAddress(hkernel32, "GetShortPathNameA");
|
2014-03-25 12:53:27 +01:00
|
|
|
pSHExtractIconsW = (void *)GetProcAddress(hmod, "SHExtractIconsW");
|
2007-08-14 12:11:04 +02:00
|
|
|
|
2005-02-14 12:52:29 +01:00
|
|
|
r = CoInitialize(NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "CoInitialize failed (0x%08x)\n", r);
|
|
|
|
if (r != S_OK)
|
2005-02-14 12:52:29 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
test_get_set();
|
|
|
|
test_load_save();
|
2005-11-04 12:40:58 +01:00
|
|
|
test_datalink();
|
2009-05-15 22:16:35 +02:00
|
|
|
test_shdefextracticon();
|
2010-11-11 22:58:37 +01:00
|
|
|
test_GetIconLocation();
|
2013-04-25 20:22:06 +02:00
|
|
|
test_SHGetStockIconInfo();
|
2014-03-25 12:53:27 +01:00
|
|
|
test_SHExtractIcons();
|
2014-12-22 13:18:20 +01:00
|
|
|
test_propertystore();
|
2005-02-14 12:52:29 +01:00
|
|
|
|
|
|
|
CoUninitialize();
|
2004-10-22 21:52:33 +02:00
|
|
|
}
|