1998-11-25 17:39:47 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright 1997 Marcus Meissner
|
|
|
|
* Copyright 1998 Juergen Schmied
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1998-11-25 17:39:47 +01:00
|
|
|
*/
|
|
|
|
|
2000-11-25 04:09:30 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
#include <string.h>
|
2000-11-02 21:22:07 +01:00
|
|
|
#include <stdio.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2000-11-02 21:22:07 +01:00
|
|
|
#include <errno.h>
|
2000-11-25 04:09:30 +01:00
|
|
|
#ifdef HAVE_SYS_WAIT_H
|
|
|
|
# include <sys/wait.h>
|
|
|
|
#endif
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2002-07-30 01:55:39 +02:00
|
|
|
#include "wine/port.h"
|
1999-01-23 15:12:48 +01:00
|
|
|
#include "winerror.h"
|
2000-09-26 02:00:55 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
2000-12-01 21:48:41 +01:00
|
|
|
#include "winreg.h"
|
1999-01-23 15:12:48 +01:00
|
|
|
|
2000-09-26 02:00:55 +02:00
|
|
|
#include "shlobj.h"
|
2001-08-16 20:49:56 +02:00
|
|
|
#include "undocshell.h"
|
2000-11-02 21:22:07 +01:00
|
|
|
#include "bitmaps/wine.xpm"
|
1998-11-25 17:39:47 +01:00
|
|
|
|
1999-02-24 16:58:26 +01:00
|
|
|
#include "heap.h"
|
1999-01-23 15:12:48 +01:00
|
|
|
#include "pidl.h"
|
1998-11-25 17:39:47 +01:00
|
|
|
#include "shell32_main.h"
|
1999-01-23 15:12:48 +01:00
|
|
|
#include "shlguid.h"
|
1998-11-25 17:39:47 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-02-24 16:58:26 +01:00
|
|
|
/* link file formats */
|
|
|
|
|
1999-04-25 14:36:53 +02:00
|
|
|
#include "pshpack1.h"
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-08-15 16:31:36 +02:00
|
|
|
/* flag1: lnk elements: simple link has 0x0B */
|
1999-02-24 16:58:26 +01:00
|
|
|
#define WORKDIR 0x10
|
|
|
|
#define ARGUMENT 0x20
|
|
|
|
#define ICON 0x40
|
1999-08-15 16:31:36 +02:00
|
|
|
#define UNC 0x80
|
1999-07-10 13:48:37 +02:00
|
|
|
|
1999-08-15 16:31:36 +02:00
|
|
|
/* fStartup */
|
1999-02-24 16:58:26 +01:00
|
|
|
#define NORMAL 0x01
|
|
|
|
#define MAXIMIZED 0x03
|
|
|
|
#define MINIMIZED 0x07
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
typedef struct _LINK_HEADER
|
1999-02-24 16:58:26 +01:00
|
|
|
{ DWORD MagicStr; /* 0x00 'L','\0','\0','\0' */
|
|
|
|
GUID MagicGuid; /* 0x04 is CLSID_ShellLink */
|
|
|
|
DWORD Flag1; /* 0x14 describes elements following */
|
|
|
|
DWORD Flag2; /* 0x18 */
|
|
|
|
FILETIME Time1; /* 0x1c */
|
|
|
|
FILETIME Time2; /* 0x24 */
|
|
|
|
FILETIME Time3; /* 0x2c */
|
|
|
|
DWORD Unknown1; /* 0x34 */
|
|
|
|
DWORD Unknown2; /* 0x38 icon number */
|
1999-08-15 16:31:36 +02:00
|
|
|
DWORD fStartup; /* 0x3c startup type */
|
1999-07-10 13:48:37 +02:00
|
|
|
DWORD wHotKey; /* 0x40 hotkey */
|
1999-02-24 16:58:26 +01:00
|
|
|
DWORD Unknown5; /* 0x44 */
|
|
|
|
DWORD Unknown6; /* 0x48 */
|
|
|
|
USHORT PidlSize; /* 0x4c */
|
|
|
|
ITEMIDLIST Pidl; /* 0x4e */
|
|
|
|
} LINK_HEADER, * PLINK_HEADER;
|
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
#define LINK_HEADER_SIZE (sizeof(LINK_HEADER)-sizeof(ITEMIDLIST))
|
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
BYTE bWidth;
|
|
|
|
BYTE bHeight;
|
|
|
|
BYTE bColorCount;
|
|
|
|
BYTE bReserved;
|
|
|
|
WORD wPlanes;
|
|
|
|
WORD wBitCount;
|
|
|
|
DWORD dwBytesInRes;
|
|
|
|
WORD nID;
|
|
|
|
} GRPICONDIRENTRY;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
WORD idReserved;
|
|
|
|
WORD idType;
|
|
|
|
WORD idCount;
|
|
|
|
GRPICONDIRENTRY idEntries[1];
|
|
|
|
} GRPICONDIR;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
BYTE bWidth;
|
|
|
|
BYTE bHeight;
|
|
|
|
BYTE bColorCount;
|
|
|
|
BYTE bReserved;
|
|
|
|
WORD wPlanes;
|
|
|
|
WORD wBitCount;
|
|
|
|
DWORD dwBytesInRes;
|
|
|
|
DWORD dwImageOffset;
|
|
|
|
} ICONDIRENTRY;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
WORD idReserved;
|
|
|
|
WORD idType;
|
|
|
|
WORD idCount;
|
|
|
|
} ICONDIR;
|
|
|
|
|
|
|
|
|
1999-04-25 14:36:53 +02:00
|
|
|
#include "poppack.h"
|
1999-02-24 16:58:26 +01:00
|
|
|
|
2001-08-11 00:29:48 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
HRSRC *pResInfo;
|
|
|
|
int nIndex;
|
|
|
|
} ENUMRESSTRUCT;
|
2000-11-02 21:22:07 +01:00
|
|
|
|
2000-08-03 06:21:23 +02:00
|
|
|
static ICOM_VTABLE(IShellLinkA) slvt;
|
1999-07-10 13:48:37 +02:00
|
|
|
static ICOM_VTABLE(IShellLinkW) slvtw;
|
|
|
|
static ICOM_VTABLE(IPersistFile) pfvt;
|
|
|
|
static ICOM_VTABLE(IPersistStream) psvt;
|
|
|
|
|
|
|
|
/* IShellLink Implementation */
|
|
|
|
|
1999-02-17 16:57:24 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2000-08-03 06:21:23 +02:00
|
|
|
ICOM_VFIELD(IShellLinkA);
|
1999-07-10 13:48:37 +02:00
|
|
|
DWORD ref;
|
|
|
|
|
|
|
|
ICOM_VTABLE(IShellLinkW)* lpvtblw;
|
|
|
|
ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
|
|
|
|
ICOM_VTABLE(IPersistStream)* lpvtblPersistStream;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
/* internal stream of the IPersistFile interface */
|
|
|
|
IStream* lpFileStream;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
/* data structures according to the informations in the lnk */
|
1999-02-24 16:58:26 +01:00
|
|
|
LPSTR sPath;
|
|
|
|
LPITEMIDLIST pPidl;
|
1999-07-10 13:48:37 +02:00
|
|
|
WORD wHotKey;
|
1999-08-15 16:31:36 +02:00
|
|
|
SYSTEMTIME time1;
|
|
|
|
SYSTEMTIME time2;
|
|
|
|
SYSTEMTIME time3;
|
1999-02-24 16:58:26 +01:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
LPSTR sIcoPath;
|
|
|
|
INT iIcoNdx;
|
|
|
|
LPSTR sArgs;
|
|
|
|
LPSTR sWorkDir;
|
|
|
|
LPSTR sDescription;
|
1999-07-10 13:48:37 +02:00
|
|
|
} IShellLinkImpl;
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
#define _IShellLinkW_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblw)))
|
|
|
|
#define _ICOM_THIS_From_IShellLinkW(class, name) class* This = (class*)(((char*)name)-_IShellLinkW_Offset);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
#define _IPersistFile_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistFile)))
|
|
|
|
#define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
|
1998-12-14 15:51:27 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
#define _IPersistStream_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistStream)))
|
|
|
|
#define _ICOM_THIS_From_IPersistStream(class, name) class* This = (class*)(((char*)name)-_IPersistStream_Offset);
|
|
|
|
#define _IPersistStream_From_ICOM_THIS(class, name) class* StreamThis = (class*)(((char*)name)+_IPersistStream_Offset);
|
1998-12-14 15:51:27 +01:00
|
|
|
|
2001-07-24 23:45:22 +02:00
|
|
|
|
|
|
|
/* strdup on the process heap */
|
|
|
|
inline static LPSTR heap_strdup( LPCSTR str )
|
|
|
|
{
|
|
|
|
INT len = strlen(str) + 1;
|
|
|
|
LPSTR p = HeapAlloc( GetProcessHeap(), 0, len );
|
|
|
|
if (p) memcpy( p, str, len );
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-14 15:51:27 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* IPersistFile_QueryInterface
|
|
|
|
*/
|
1999-01-17 17:32:32 +01:00
|
|
|
static HRESULT WINAPI IPersistFile_fnQueryInterface(
|
1999-07-10 13:48:37 +02:00
|
|
|
IPersistFile* iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1998-12-14 15:51:27 +01:00
|
|
|
|
2000-08-03 06:21:23 +02:00
|
|
|
return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObj);
|
1999-07-10 13:48:37 +02:00
|
|
|
}
|
1998-12-14 15:51:27 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* IPersistFile_AddRef
|
|
|
|
*/
|
1999-02-18 14:26:22 +01:00
|
|
|
static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile* iface)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
1999-01-23 15:12:48 +01:00
|
|
|
|
2000-08-03 06:21:23 +02:00
|
|
|
return IShellLinkA_AddRef((IShellLinkA*)This);
|
1998-12-14 15:51:27 +01:00
|
|
|
}
|
|
|
|
/******************************************************************************
|
|
|
|
* IPersistFile_Release
|
|
|
|
*/
|
1999-02-18 14:26:22 +01:00
|
|
|
static ULONG WINAPI IPersistFile_fnRelease(IPersistFile* iface)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
1999-01-23 15:12:48 +01:00
|
|
|
|
2000-08-03 06:21:23 +02:00
|
|
|
return IShellLinkA_Release((IShellLinkA*)This);
|
1998-12-14 15:51:27 +01:00
|
|
|
}
|
|
|
|
|
1999-07-31 15:13:23 +02:00
|
|
|
static HRESULT WINAPI IPersistFile_fnGetClassID(IPersistFile* iface, CLSID *pClassID)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)\n",This);
|
1998-12-14 15:51:27 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-07-31 15:13:23 +02:00
|
|
|
static HRESULT WINAPI IPersistFile_fnIsDirty(IPersistFile* iface)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)\n",This);
|
1998-12-14 15:51:27 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
|
|
|
|
_IPersistStream_From_ICOM_THIS(IPersistStream, This)
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
LPSTR sFile = HEAP_strdupWtoA ( GetProcessHeap(), 0, pszFileName);
|
1999-02-24 16:58:26 +01:00
|
|
|
HRESULT hRet = E_FAIL;
|
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p, %s)\n",This, sFile);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
if (This->lpFileStream)
|
|
|
|
IStream_Release(This->lpFileStream);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
if SUCCEEDED(CreateStreamOnFile(sFile, &(This->lpFileStream)))
|
|
|
|
{
|
|
|
|
if SUCCEEDED (IPersistStream_Load(StreamThis, This->lpFileStream))
|
|
|
|
{
|
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-24 16:58:26 +01:00
|
|
|
return hRet;
|
1998-12-14 15:51:27 +01:00
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
|
|
|
|
/* Icon extraction routines
|
|
|
|
*
|
|
|
|
* FIXME: should use PrivateExtractIcons and friends
|
|
|
|
* FIXME: should not use stdio
|
|
|
|
*/
|
|
|
|
|
|
|
|
static BOOL SaveIconResAsXPM(const BITMAPINFO *pIcon, const char *szXPMFileName)
|
|
|
|
{
|
|
|
|
FILE *fXPMFile;
|
|
|
|
int nHeight;
|
|
|
|
int nXORWidthBytes;
|
|
|
|
int nANDWidthBytes;
|
|
|
|
BOOL b8BitColors;
|
|
|
|
int nColors;
|
|
|
|
BYTE *pXOR;
|
|
|
|
BYTE *pAND;
|
|
|
|
BOOL aColorUsed[256] = {0};
|
|
|
|
int nColorsUsed = 0;
|
|
|
|
int i,j;
|
|
|
|
|
|
|
|
if (!((pIcon->bmiHeader.biBitCount == 4) || (pIcon->bmiHeader.biBitCount == 8)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!(fXPMFile = fopen(szXPMFileName, "w")))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
nHeight = pIcon->bmiHeader.biHeight / 2;
|
|
|
|
nXORWidthBytes = 4 * ((pIcon->bmiHeader.biWidth * pIcon->bmiHeader.biBitCount / 32)
|
|
|
|
+ ((pIcon->bmiHeader.biWidth * pIcon->bmiHeader.biBitCount % 32) > 0));
|
|
|
|
nANDWidthBytes = 4 * ((pIcon->bmiHeader.biWidth / 32)
|
|
|
|
+ ((pIcon->bmiHeader.biWidth % 32) > 0));
|
|
|
|
b8BitColors = pIcon->bmiHeader.biBitCount == 8;
|
|
|
|
nColors = pIcon->bmiHeader.biClrUsed ? pIcon->bmiHeader.biClrUsed
|
|
|
|
: 1 << pIcon->bmiHeader.biBitCount;
|
|
|
|
pXOR = (BYTE*) pIcon + sizeof (BITMAPINFOHEADER) + (nColors * sizeof (RGBQUAD));
|
|
|
|
pAND = pXOR + nHeight * nXORWidthBytes;
|
|
|
|
|
|
|
|
#define MASK(x,y) (pAND[(x) / 8 + (nHeight - (y) - 1) * nANDWidthBytes] & (1 << (7 - (x) % 8)))
|
|
|
|
#define COLOR(x,y) (b8BitColors ? pXOR[(x) + (nHeight - (y) - 1) * nXORWidthBytes] : (x) % 2 ? pXOR[(x) / 2 + (nHeight - (y) - 1) * nXORWidthBytes] & 0xF : (pXOR[(x) / 2 + (nHeight - (y) - 1) * nXORWidthBytes] & 0xF0) >> 4)
|
|
|
|
|
|
|
|
for (i = 0; i < nHeight; i++)
|
|
|
|
for (j = 0; j < pIcon->bmiHeader.biWidth; j++)
|
|
|
|
if (!aColorUsed[COLOR(j,i)] && !MASK(j,i))
|
|
|
|
{
|
|
|
|
aColorUsed[COLOR(j,i)] = TRUE;
|
|
|
|
nColorsUsed++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fprintf(fXPMFile, "/* XPM */\nstatic char *icon[] = {\n") <= 0)
|
|
|
|
goto error;
|
|
|
|
if (fprintf(fXPMFile, "\"%d %d %d %d\",\n",
|
|
|
|
(int) pIcon->bmiHeader.biWidth, nHeight, nColorsUsed + 1, 2) <=0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
for (i = 0; i < nColors; i++)
|
|
|
|
if (aColorUsed[i])
|
|
|
|
if (fprintf(fXPMFile, "\"%.2X c #%.2X%.2X%.2X\",\n", i, pIcon->bmiColors[i].rgbRed,
|
|
|
|
pIcon->bmiColors[i].rgbGreen, pIcon->bmiColors[i].rgbBlue) <= 0)
|
|
|
|
goto error;
|
|
|
|
if (fprintf(fXPMFile, "\" c None\"") <= 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
for (i = 0; i < nHeight; i++)
|
|
|
|
{
|
|
|
|
if (fprintf(fXPMFile, ",\n\"") <= 0)
|
|
|
|
goto error;
|
|
|
|
for (j = 0; j < pIcon->bmiHeader.biWidth; j++)
|
|
|
|
{
|
|
|
|
if MASK(j,i)
|
|
|
|
{
|
|
|
|
if (fprintf(fXPMFile, " ") <= 0)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (fprintf(fXPMFile, "%.2X", COLOR(j,i)) <= 0)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if (fprintf(fXPMFile, "\"") <= 0)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if (fprintf(fXPMFile, "};\n") <= 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
#undef MASK
|
|
|
|
#undef COLOR
|
|
|
|
|
|
|
|
fclose(fXPMFile);
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
error:
|
|
|
|
fclose(fXPMFile);
|
|
|
|
unlink( szXPMFileName );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL CALLBACK EnumResNameProc(HANDLE hModule, const char *lpszType, char *lpszName, LONG lParam)
|
|
|
|
{
|
2001-08-11 00:29:48 +02:00
|
|
|
ENUMRESSTRUCT *sEnumRes = (ENUMRESSTRUCT *) lParam;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-11 00:29:48 +02:00
|
|
|
if (!sEnumRes->nIndex--)
|
|
|
|
{
|
|
|
|
*sEnumRes->pResInfo = FindResourceA(hModule, lpszName, RT_GROUP_ICONA);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return TRUE;
|
2000-11-02 21:22:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ExtractFromEXEDLL(const char *szFileName, int nIndex, const char *szXPMFileName)
|
|
|
|
{
|
|
|
|
HMODULE hModule;
|
|
|
|
HRSRC hResInfo;
|
|
|
|
char *lpName = NULL;
|
|
|
|
HGLOBAL hResData;
|
|
|
|
GRPICONDIR *pIconDir;
|
|
|
|
BITMAPINFO *pIcon;
|
2001-08-11 00:29:48 +02:00
|
|
|
ENUMRESSTRUCT sEnumRes;
|
2000-11-02 21:22:07 +01:00
|
|
|
int nMax = 0;
|
2001-08-11 00:29:48 +02:00
|
|
|
int nMaxBits = 0;
|
2000-11-02 21:22:07 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!(hModule = LoadLibraryExA(szFileName, 0, LOAD_LIBRARY_AS_DATAFILE)))
|
2001-01-17 02:48:52 +01:00
|
|
|
{
|
|
|
|
TRACE("LoadLibraryExA (%s) failed, error %ld\n", szFileName, GetLastError());
|
2000-11-02 21:22:07 +01:00
|
|
|
goto error1;
|
2001-01-17 02:48:52 +01:00
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
|
2001-08-11 00:29:48 +02:00
|
|
|
if (nIndex < 0)
|
2001-01-17 02:48:52 +01:00
|
|
|
{
|
2001-08-11 00:29:48 +02:00
|
|
|
hResInfo = FindResourceA(hModule, MAKEINTRESOURCEA(-nIndex), RT_GROUP_ICONA);
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("FindResourceA (%s) called, return %p, error %ld\n", szFileName, hResInfo, GetLastError());
|
2001-01-17 02:48:52 +01:00
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
else
|
2001-08-11 00:29:48 +02:00
|
|
|
{
|
|
|
|
sEnumRes.pResInfo = &hResInfo;
|
|
|
|
sEnumRes.nIndex = nIndex;
|
2002-11-22 00:56:42 +01:00
|
|
|
if (EnumResourceNamesA(hModule, RT_GROUP_ICONA,
|
|
|
|
(ENUMRESNAMEPROCA)&EnumResNameProc,
|
|
|
|
(LONG) &sEnumRes))
|
2001-01-17 02:48:52 +01:00
|
|
|
{
|
|
|
|
TRACE("EnumResourceNamesA failed, error %ld\n", GetLastError());
|
2000-11-02 21:22:07 +01:00
|
|
|
goto error2;
|
2001-01-17 02:48:52 +01:00
|
|
|
}
|
2001-08-11 00:29:48 +02:00
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
|
|
|
|
if (!hResInfo)
|
2001-01-17 02:48:52 +01:00
|
|
|
{
|
|
|
|
TRACE("ExtractFromEXEDLL failed, error %ld\n", GetLastError());
|
2000-11-02 21:22:07 +01:00
|
|
|
goto error2;
|
2001-01-17 02:48:52 +01:00
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
|
|
|
|
if (!(hResData = LoadResource(hModule, hResInfo)))
|
2001-01-17 02:48:52 +01:00
|
|
|
{
|
|
|
|
TRACE("LoadResource failed, error %ld\n", GetLastError());
|
2000-11-02 21:22:07 +01:00
|
|
|
goto error2;
|
2001-01-17 02:48:52 +01:00
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
if (!(pIconDir = LockResource(hResData)))
|
2001-01-17 02:48:52 +01:00
|
|
|
{
|
|
|
|
TRACE("LockResource failed, error %ld\n", GetLastError());
|
2000-11-02 21:22:07 +01:00
|
|
|
goto error3;
|
2001-01-17 02:48:52 +01:00
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
|
|
|
|
for (i = 0; i < pIconDir->idCount; i++)
|
2001-08-11 00:29:48 +02:00
|
|
|
if ((pIconDir->idEntries[i].wBitCount >= nMaxBits) && (pIconDir->idEntries[i].wBitCount <= 8))
|
2000-11-02 21:22:07 +01:00
|
|
|
{
|
2001-08-11 00:29:48 +02:00
|
|
|
if (pIconDir->idEntries[i].wBitCount > nMaxBits)
|
|
|
|
{
|
|
|
|
nMaxBits = pIconDir->idEntries[i].wBitCount;
|
|
|
|
nMax = 0;
|
|
|
|
}
|
|
|
|
if ((pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth) > nMax)
|
|
|
|
{
|
|
|
|
lpName = MAKEINTRESOURCEA(pIconDir->idEntries[i].nID);
|
|
|
|
nMax = pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth;
|
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
FreeResource(hResData);
|
|
|
|
|
|
|
|
if (!(hResInfo = FindResourceA(hModule, lpName, RT_ICONA)))
|
2001-01-17 02:48:52 +01:00
|
|
|
{
|
|
|
|
TRACE("Second FindResourceA failed, error %ld\n", GetLastError());
|
2000-11-02 21:22:07 +01:00
|
|
|
goto error2;
|
2001-01-17 02:48:52 +01:00
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
if (!(hResData = LoadResource(hModule, hResInfo)))
|
2001-01-17 02:48:52 +01:00
|
|
|
{
|
|
|
|
TRACE("Second LoadResource failed, error %ld\n", GetLastError());
|
2000-11-02 21:22:07 +01:00
|
|
|
goto error2;
|
2001-01-17 02:48:52 +01:00
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
if (!(pIcon = LockResource(hResData)))
|
2001-01-17 02:48:52 +01:00
|
|
|
{
|
|
|
|
TRACE("Second LockResource failed, error %ld\n", GetLastError());
|
2000-11-02 21:22:07 +01:00
|
|
|
goto error3;
|
2001-01-17 02:48:52 +01:00
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
|
|
|
|
if(!SaveIconResAsXPM(pIcon, szXPMFileName))
|
2001-01-17 02:48:52 +01:00
|
|
|
{
|
|
|
|
TRACE("Failed saving icon as XPM, error %ld\n", GetLastError());
|
2000-11-02 21:22:07 +01:00
|
|
|
goto error3;
|
2001-01-17 02:48:52 +01:00
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
|
|
|
|
FreeResource(hResData);
|
|
|
|
FreeLibrary(hModule);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
error3:
|
|
|
|
FreeResource(hResData);
|
|
|
|
error2:
|
|
|
|
FreeLibrary(hModule);
|
|
|
|
error1:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-08-20 02:25:03 +02:00
|
|
|
/* get the Unix file name for a given path, allocating the string */
|
|
|
|
inline static char *get_unix_file_name( const char *dos )
|
|
|
|
{
|
|
|
|
char buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!wine_get_unix_file_name( dos, buffer, sizeof(buffer) )) return NULL;
|
|
|
|
return heap_strdup( buffer );
|
|
|
|
}
|
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
static int ExtractFromICO(const char *szFileName, const char *szXPMFileName)
|
|
|
|
{
|
|
|
|
FILE *fICOFile;
|
|
|
|
ICONDIR iconDir;
|
|
|
|
ICONDIRENTRY *pIconDirEntry;
|
|
|
|
int nMax = 0;
|
|
|
|
int nIndex = 0;
|
|
|
|
void *pIcon;
|
|
|
|
int i;
|
2002-08-20 02:25:03 +02:00
|
|
|
char *filename;
|
2000-11-02 21:22:07 +01:00
|
|
|
|
2002-08-20 02:25:03 +02:00
|
|
|
filename = get_unix_file_name(szFileName);
|
|
|
|
if (!(fICOFile = fopen(filename, "r")))
|
2000-11-02 21:22:07 +01:00
|
|
|
goto error1;
|
|
|
|
|
|
|
|
if (fread(&iconDir, sizeof (ICONDIR), 1, fICOFile) != 1)
|
|
|
|
goto error2;
|
|
|
|
if ((iconDir.idReserved != 0) || (iconDir.idType != 1))
|
|
|
|
goto error2;
|
|
|
|
|
|
|
|
if ((pIconDirEntry = malloc(iconDir.idCount * sizeof (ICONDIRENTRY))) == NULL)
|
|
|
|
goto error2;
|
|
|
|
if (fread(pIconDirEntry, sizeof (ICONDIRENTRY), iconDir.idCount, fICOFile) != iconDir.idCount)
|
|
|
|
goto error3;
|
|
|
|
|
|
|
|
for (i = 0; i < iconDir.idCount; i++)
|
|
|
|
if ((pIconDirEntry[i].bHeight * pIconDirEntry[i].bWidth) > nMax)
|
|
|
|
{
|
|
|
|
nIndex = i;
|
|
|
|
nMax = pIconDirEntry[i].bHeight * pIconDirEntry[i].bWidth;
|
|
|
|
}
|
|
|
|
if ((pIcon = malloc(pIconDirEntry[nIndex].dwBytesInRes)) == NULL)
|
|
|
|
goto error3;
|
|
|
|
if (fseek(fICOFile, pIconDirEntry[nIndex].dwImageOffset, SEEK_SET))
|
|
|
|
goto error4;
|
|
|
|
if (fread(pIcon, pIconDirEntry[nIndex].dwBytesInRes, 1, fICOFile) != 1)
|
|
|
|
goto error4;
|
|
|
|
|
|
|
|
if(!SaveIconResAsXPM(pIcon, szXPMFileName))
|
|
|
|
goto error4;
|
|
|
|
|
|
|
|
free(pIcon);
|
|
|
|
free(pIconDirEntry);
|
|
|
|
fclose(fICOFile);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
error4:
|
|
|
|
free(pIcon);
|
|
|
|
error3:
|
|
|
|
free(pIconDirEntry);
|
|
|
|
error2:
|
|
|
|
fclose(fICOFile);
|
|
|
|
error1:
|
2002-08-20 02:25:03 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, filename);
|
2000-11-02 21:22:07 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL create_default_icon( const char *filename )
|
|
|
|
{
|
|
|
|
FILE *fXPM;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!(fXPM = fopen(filename, "w"))) return FALSE;
|
|
|
|
fprintf(fXPM, "/* XPM */\nstatic char * icon[] = {");
|
|
|
|
for (i = 0; i < sizeof(wine_xpm)/sizeof(wine_xpm[0]); i++)
|
|
|
|
fprintf( fXPM, "\n\"%s\",", wine_xpm[i]);
|
|
|
|
fprintf( fXPM, "};\n" );
|
|
|
|
fclose( fXPM );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* extract an icon from an exe or icon file; helper for IPersistFile_fnSave */
|
2002-04-09 01:49:11 +02:00
|
|
|
static char *extract_icon( const char *path, int index)
|
2000-11-02 21:22:07 +01:00
|
|
|
{
|
2002-07-30 01:55:39 +02:00
|
|
|
int fd, nodefault = 1;
|
|
|
|
char *filename, tmpfn[25];
|
|
|
|
|
|
|
|
strcpy(tmpfn,"/tmp/icon.XXXXXX");
|
|
|
|
fd = mkstemp( tmpfn );
|
|
|
|
if (fd == -1)
|
|
|
|
return NULL;
|
|
|
|
filename = heap_strdup( tmpfn );
|
|
|
|
close(fd); /* not needed */
|
2002-04-09 01:49:11 +02:00
|
|
|
|
|
|
|
/* If icon path begins with a '*' then this is a deferred call */
|
|
|
|
if (path[0] == '*')
|
|
|
|
{
|
|
|
|
path++;
|
|
|
|
nodefault = 0;
|
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
if (ExtractFromEXEDLL( path, index, filename )) return filename;
|
|
|
|
if (ExtractFromICO( path, filename )) return filename;
|
2002-04-09 01:49:11 +02:00
|
|
|
if (!nodefault)
|
|
|
|
if (create_default_icon( filename )) return filename;
|
2000-11-02 21:22:07 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, filename );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-11-01 00:35:20 +01:00
|
|
|
/* This escapes \ in filenames */
|
|
|
|
static LPSTR
|
|
|
|
escape(LPCSTR arg) {
|
|
|
|
LPSTR narg, x;
|
|
|
|
|
|
|
|
narg = HeapAlloc(GetProcessHeap(),0,2*strlen(arg)+2);
|
|
|
|
x = narg;
|
|
|
|
while (*arg) {
|
|
|
|
*x++ = *arg;
|
|
|
|
if (*arg == '\\')
|
|
|
|
*x++='\\'; /* escape \ */
|
|
|
|
arg++;
|
|
|
|
}
|
|
|
|
*x = 0;
|
|
|
|
return narg;
|
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, BOOL fRemember)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
2000-11-02 21:22:07 +01:00
|
|
|
HRESULT ret = NOERROR;
|
|
|
|
int pid, status;
|
2002-04-09 01:49:11 +02:00
|
|
|
char buffer[MAX_PATH], buff2[MAX_PATH], ascii_filename[MAX_PATH];
|
2000-11-02 21:22:07 +01:00
|
|
|
char *filename, *link_name, *p;
|
|
|
|
char *shell_link_app = NULL;
|
|
|
|
char *icon_name = NULL;
|
|
|
|
char *work_dir = NULL;
|
2002-11-01 00:35:20 +01:00
|
|
|
char *escaped_path = NULL;
|
|
|
|
char *escaped_args = NULL;
|
2000-11-02 21:22:07 +01:00
|
|
|
BOOL bDesktop;
|
2000-12-01 21:48:41 +01:00
|
|
|
HKEY hkey;
|
2000-11-02 21:22:07 +01:00
|
|
|
|
|
|
|
_ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n",This,debugstr_w(pszFileName));
|
|
|
|
|
|
|
|
if (!pszFileName || !This->sPath)
|
|
|
|
return ERROR_UNKNOWN;
|
|
|
|
|
|
|
|
/* check for .exe extension */
|
|
|
|
if (!(p = strrchr( This->sPath, '.' ))) return NOERROR;
|
|
|
|
if (strchr( p, '\\' ) || strchr( p, '/' )) return NOERROR;
|
|
|
|
if (strcasecmp( p, ".exe" )) return NOERROR;
|
|
|
|
|
|
|
|
/* check if ShellLinker configured */
|
2000-12-01 21:48:41 +01:00
|
|
|
buffer[0] = 0;
|
|
|
|
if (!RegOpenKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Wine",
|
|
|
|
0, KEY_ALL_ACCESS, &hkey ))
|
|
|
|
{
|
|
|
|
DWORD type, count = sizeof(buffer);
|
|
|
|
if (RegQueryValueExA( hkey, "ShellLinker", 0, &type, buffer, &count )) buffer[0] = 0;
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
if (!*buffer) return NOERROR;
|
2001-07-24 23:45:22 +02:00
|
|
|
shell_link_app = heap_strdup( buffer );
|
2000-11-02 21:22:07 +01:00
|
|
|
|
2002-04-09 01:49:11 +02:00
|
|
|
if (!WideCharToMultiByte( CP_ACP, 0, pszFileName, -1, ascii_filename, sizeof(ascii_filename), NULL, NULL))
|
2000-11-02 21:22:07 +01:00
|
|
|
return ERROR_UNKNOWN;
|
2002-04-09 01:49:11 +02:00
|
|
|
GetFullPathNameA( ascii_filename, sizeof(buff2), buff2, NULL );
|
2001-07-24 23:45:22 +02:00
|
|
|
filename = heap_strdup( buff2 );
|
2000-11-02 21:22:07 +01:00
|
|
|
|
|
|
|
if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTUP, FALSE ))
|
|
|
|
{
|
|
|
|
/* ignore startup for now */
|
|
|
|
if (!strncasecmp( filename, buffer, strlen(buffer) )) goto done;
|
|
|
|
}
|
|
|
|
if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_DESKTOPDIRECTORY, FALSE ))
|
|
|
|
{
|
|
|
|
if (!strncasecmp( filename, buffer, strlen(buffer) ))
|
|
|
|
{
|
|
|
|
link_name = filename + strlen(buffer);
|
|
|
|
bDesktop = TRUE;
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTMENU, FALSE ))
|
|
|
|
{
|
|
|
|
if (!strncasecmp( filename, buffer, strlen(buffer) ))
|
|
|
|
{
|
|
|
|
link_name = filename + strlen(buffer);
|
|
|
|
bDesktop = FALSE;
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
found:
|
|
|
|
/* make link name a Unix name */
|
|
|
|
for (p = link_name; *p; p++) if (*p == '\\') *p = '/';
|
|
|
|
/* strip leading slashes */
|
|
|
|
while (*link_name == '/') link_name++;
|
|
|
|
/* remove extension */
|
|
|
|
if ((p = strrchr( link_name, '.' ))) *p = 0;
|
|
|
|
|
|
|
|
/* convert app working dir */
|
|
|
|
if (This->sWorkDir) work_dir = get_unix_file_name( This->sWorkDir );
|
|
|
|
|
|
|
|
/* extract the icon */
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!(icon_name = extract_icon( This->sIcoPath && strlen(This->sIcoPath) ?
|
2001-01-17 02:48:52 +01:00
|
|
|
This->sIcoPath : This->sPath,
|
2002-04-09 01:49:11 +02:00
|
|
|
This->iIcoNdx )))
|
|
|
|
{
|
|
|
|
/* Couldn't extract icon -- defer this menu entry to runonce. */
|
|
|
|
HKEY hRunOnce;
|
|
|
|
char* buffer = NULL;
|
2001-01-17 02:48:52 +01:00
|
|
|
|
2002-04-09 01:49:11 +02:00
|
|
|
TRACE("Deferring icon creation to reboot.\n");
|
|
|
|
if (RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce", 0,
|
|
|
|
NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hRunOnce, NULL) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ret = ERROR_UNKNOWN;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * 3 + (This->sArgs ? strlen(This->sArgs) : 0) +
|
|
|
|
(This->sDescription ? strlen(This->sDescription) : 0) + 200);
|
|
|
|
sprintf(buffer, "link:%s\xff*%s\xff%d\xff%s\xff%s\xff%s", This->sPath, This->sIcoPath, This->iIcoNdx,
|
|
|
|
This->sArgs ? This->sArgs : "", This->sDescription ? This->sDescription : "",
|
|
|
|
This->sWorkDir ? This->sWorkDir : "");
|
|
|
|
if (RegSetValueExA(hRunOnce, ascii_filename, 0, REG_SZ, buffer, strlen(buffer) + 1) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
RegCloseKey(hRunOnce);
|
|
|
|
ret = ERROR_UNKNOWN;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
RegCloseKey(hRunOnce);
|
|
|
|
goto done;
|
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
|
2000-11-04 03:57:51 +01:00
|
|
|
TRACE("linker app='%s' link='%s' mode=%s path='%s' args='%s' icon='%s' workdir='%s' descr='%s'\n",
|
2002-04-09 01:49:11 +02:00
|
|
|
shell_link_app, link_name, bDesktop ? "desktop" : "menu", This->sPath,
|
2000-11-02 21:22:07 +01:00
|
|
|
This->sArgs ? This->sArgs : "", icon_name, work_dir ? work_dir : "",
|
|
|
|
This->sDescription ? This->sDescription : "" );
|
|
|
|
|
|
|
|
if ((pid = fork()) == -1) goto done;
|
2002-11-01 00:35:20 +01:00
|
|
|
|
|
|
|
escaped_path = escape(This->sPath);
|
|
|
|
if (This->sArgs)
|
|
|
|
escaped_args = escape(This->sArgs);
|
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
if (!pid)
|
|
|
|
{
|
|
|
|
int pos = 0;
|
|
|
|
char *argv[20];
|
|
|
|
argv[pos++] = shell_link_app;
|
|
|
|
argv[pos++] = "--link";
|
|
|
|
argv[pos++] = link_name;
|
|
|
|
argv[pos++] = "--path";
|
2002-11-01 00:35:20 +01:00
|
|
|
argv[pos++] = escaped_path;
|
2000-11-02 21:22:07 +01:00
|
|
|
argv[pos++] = bDesktop ? "--desktop" : "--menu";
|
2001-01-17 02:48:52 +01:00
|
|
|
if (This->sArgs && strlen(This->sArgs))
|
2000-11-02 21:22:07 +01:00
|
|
|
{
|
|
|
|
argv[pos++] = "--args";
|
2002-11-01 00:35:20 +01:00
|
|
|
argv[pos++] = escaped_args;
|
2000-11-02 21:22:07 +01:00
|
|
|
}
|
|
|
|
if (icon_name)
|
|
|
|
{
|
|
|
|
argv[pos++] = "--icon";
|
|
|
|
argv[pos++] = icon_name;
|
|
|
|
}
|
2001-01-17 02:48:52 +01:00
|
|
|
if (This->sWorkDir && strlen(This->sWorkDir))
|
2000-11-02 21:22:07 +01:00
|
|
|
{
|
|
|
|
argv[pos++] = "--workdir";
|
2002-11-01 00:35:20 +01:00
|
|
|
argv[pos++] = work_dir;
|
2000-11-02 21:22:07 +01:00
|
|
|
}
|
2001-01-17 02:48:52 +01:00
|
|
|
if (This->sDescription && strlen(This->sDescription))
|
2000-11-02 21:22:07 +01:00
|
|
|
{
|
|
|
|
argv[pos++] = "--descr";
|
|
|
|
argv[pos++] = This->sDescription;
|
|
|
|
}
|
|
|
|
argv[pos] = NULL;
|
|
|
|
execvp( shell_link_app, argv );
|
|
|
|
_exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (waitpid( pid, &status, 0 ) == -1)
|
|
|
|
{
|
|
|
|
if (errno != EINTR)
|
|
|
|
{
|
|
|
|
ret = ERROR_UNKNOWN;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (status) ret = E_ACCESSDENIED;
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (icon_name) unlink( icon_name );
|
|
|
|
HeapFree( GetProcessHeap(), 0, shell_link_app );
|
|
|
|
HeapFree( GetProcessHeap(), 0, filename );
|
|
|
|
HeapFree( GetProcessHeap(), 0, icon_name );
|
|
|
|
HeapFree( GetProcessHeap(), 0, work_dir );
|
2002-11-01 00:35:20 +01:00
|
|
|
if (escaped_args) HeapFree( GetProcessHeap(), 0, escaped_args );
|
|
|
|
if (escaped_path) HeapFree( GetProcessHeap(), 0, escaped_path );
|
2000-11-02 21:22:07 +01:00
|
|
|
return ret;
|
1999-01-17 17:32:32 +01:00
|
|
|
}
|
2000-11-02 21:22:07 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile* iface, LPCOLESTR pszFileName)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)->(%s)\n",This,debugstr_w(pszFileName));
|
1999-07-10 13:48:37 +02:00
|
|
|
return NOERROR;
|
1999-01-17 17:32:32 +01:00
|
|
|
}
|
1999-07-31 15:13:23 +02:00
|
|
|
static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile* iface, LPOLESTR *ppszFileName)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)\n",This);
|
1998-12-14 15:51:27 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-07-10 13:48:37 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static ICOM_VTABLE(IPersistFile) pfvt =
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-05-22 13:41:38 +02:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-02-24 16:58:26 +01:00
|
|
|
IPersistFile_fnQueryInterface,
|
|
|
|
IPersistFile_fnAddRef,
|
|
|
|
IPersistFile_fnRelease,
|
|
|
|
IPersistFile_fnGetClassID,
|
|
|
|
IPersistFile_fnIsDirty,
|
|
|
|
IPersistFile_fnLoad,
|
|
|
|
IPersistFile_fnSave,
|
|
|
|
IPersistFile_fnSaveCompleted,
|
|
|
|
IPersistFile_fnGetCurFile
|
1999-01-17 17:32:32 +01:00
|
|
|
};
|
1998-12-14 15:51:27 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
/************************************************************************
|
|
|
|
* IPersistStream_QueryInterface
|
1998-12-14 15:51:27 +01:00
|
|
|
*/
|
1999-07-10 13:48:37 +02:00
|
|
|
static HRESULT WINAPI IPersistStream_fnQueryInterface(
|
|
|
|
IPersistStream* iface,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvoid)
|
1999-02-17 16:57:24 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1998-12-14 15:51:27 +01:00
|
|
|
|
2000-08-03 06:21:23 +02:00
|
|
|
return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvoid);
|
1999-07-10 13:48:37 +02:00
|
|
|
}
|
1998-12-14 15:51:27 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
/************************************************************************
|
|
|
|
* IPersistStream_Release
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI IPersistStream_fnRelease(
|
|
|
|
IPersistStream* iface)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
1998-12-14 15:51:27 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
2000-08-03 06:21:23 +02:00
|
|
|
return IShellLinkA_Release((IShellLinkA*)This);
|
1998-12-14 15:51:27 +01:00
|
|
|
}
|
1999-07-10 13:48:37 +02:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* IPersistStream_AddRef
|
1998-12-14 15:51:27 +01:00
|
|
|
*/
|
1999-07-10 13:48:37 +02:00
|
|
|
static ULONG WINAPI IPersistStream_fnAddRef(
|
|
|
|
IPersistStream* iface)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
1998-12-14 15:51:27 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1998-12-14 15:51:27 +01:00
|
|
|
|
2000-08-03 06:21:23 +02:00
|
|
|
return IShellLinkA_AddRef((IShellLinkA*)This);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1998-12-14 15:51:27 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
/************************************************************************
|
|
|
|
* IPersistStream_GetClassID
|
|
|
|
*
|
1998-12-14 15:51:27 +01:00
|
|
|
*/
|
1999-07-10 13:48:37 +02:00
|
|
|
static HRESULT WINAPI IPersistStream_fnGetClassID(
|
1999-07-31 15:13:23 +02:00
|
|
|
IPersistStream* iface,
|
1999-07-10 13:48:37 +02:00
|
|
|
CLSID* pClassID)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
1999-01-23 15:12:48 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
if (pClassID==0)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
/* memcpy(pClassID, &CLSID_???, sizeof(CLSID_???)); */
|
|
|
|
|
|
|
|
return S_OK;
|
1998-12-14 15:51:27 +01:00
|
|
|
}
|
1999-07-10 13:48:37 +02:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* IPersistStream_IsDirty (IPersistStream)
|
1998-12-14 15:51:27 +01:00
|
|
|
*/
|
1999-07-10 13:48:37 +02:00
|
|
|
static HRESULT WINAPI IPersistStream_fnIsDirty(
|
|
|
|
IPersistStream* iface)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
1999-01-23 15:12:48 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return S_OK;
|
1998-12-14 15:51:27 +01:00
|
|
|
}
|
1999-07-10 13:48:37 +02:00
|
|
|
/************************************************************************
|
|
|
|
* IPersistStream_Load (IPersistStream)
|
1998-12-14 15:51:27 +01:00
|
|
|
*/
|
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
static HRESULT WINAPI IPersistStream_fnLoad(
|
|
|
|
IPersistStream* iface,
|
|
|
|
IStream* pLoadStream)
|
|
|
|
{
|
|
|
|
PLINK_HEADER lpLinkHeader = HeapAlloc(GetProcessHeap(), 0, LINK_HEADER_SIZE);
|
|
|
|
ULONG dwBytesRead;
|
|
|
|
DWORD ret = E_FAIL;
|
1999-12-27 06:24:06 +01:00
|
|
|
char sTemp[MAX_PATH];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
1998-12-14 15:51:27 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p)(%p)\n", This, pLoadStream);
|
1998-12-14 15:51:27 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
if ( ! pLoadStream)
|
|
|
|
{
|
|
|
|
return STG_E_INVALIDPOINTER;
|
1998-12-14 15:51:27 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
IStream_AddRef (pLoadStream);
|
2002-08-17 01:27:07 +02:00
|
|
|
if(!lpLinkHeader)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
dwBytesRead = 0;
|
|
|
|
if (!(SUCCEEDED(IStream_Read(pLoadStream, lpLinkHeader, LINK_HEADER_SIZE, &dwBytesRead))))
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
if (dwBytesRead != LINK_HEADER_SIZE)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
if ( (lpLinkHeader->MagicStr != 0x0000004CL) || !IsEqualIID(&lpLinkHeader->MagicGuid, &CLSID_ShellLink) )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
if(lpLinkHeader->PidlSize)
|
1999-07-10 13:48:37 +02:00
|
|
|
{
|
2002-08-17 01:27:07 +02:00
|
|
|
lpLinkHeader = HeapReAlloc(GetProcessHeap(), 0, lpLinkHeader, LINK_HEADER_SIZE+lpLinkHeader->PidlSize);
|
|
|
|
if (!lpLinkHeader)
|
|
|
|
goto end;
|
|
|
|
dwBytesRead = 0;
|
|
|
|
if (!(SUCCEEDED(IStream_Read(pLoadStream, &(lpLinkHeader->Pidl), lpLinkHeader->PidlSize, &dwBytesRead))))
|
|
|
|
goto end;
|
|
|
|
if(dwBytesRead != lpLinkHeader->PidlSize)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
if (pcheck (&lpLinkHeader->Pidl))
|
|
|
|
{
|
|
|
|
This->pPidl = ILClone (&lpLinkHeader->Pidl);
|
|
|
|
|
|
|
|
SHGetPathFromIDListA(&lpLinkHeader->Pidl, sTemp);
|
|
|
|
This->sPath = heap_strdup( sTemp );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
This->wHotKey = lpLinkHeader->wHotKey;
|
|
|
|
FileTimeToSystemTime (&lpLinkHeader->Time1, &This->time1);
|
|
|
|
FileTimeToSystemTime (&lpLinkHeader->Time2, &This->time2);
|
|
|
|
FileTimeToSystemTime (&lpLinkHeader->Time3, &This->time3);
|
1999-08-15 16:31:36 +02:00
|
|
|
#if 1
|
2002-08-17 01:27:07 +02:00
|
|
|
GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time1, NULL, sTemp, 256);
|
|
|
|
TRACE("-- time1: %s\n", sTemp);
|
|
|
|
GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time2, NULL, sTemp, 256);
|
|
|
|
TRACE("-- time1: %s\n", sTemp);
|
|
|
|
GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time3, NULL, sTemp, 256);
|
|
|
|
TRACE("-- time1: %s\n", sTemp);
|
|
|
|
pdump (This->pPidl);
|
2002-06-01 01:06:46 +02:00
|
|
|
#endif
|
2002-08-17 01:27:07 +02:00
|
|
|
ret = S_OK;
|
1998-12-14 15:51:27 +01:00
|
|
|
|
2002-08-17 01:27:07 +02:00
|
|
|
end:
|
1999-07-10 13:48:37 +02:00
|
|
|
IStream_Release (pLoadStream);
|
|
|
|
|
|
|
|
pdump(This->pPidl);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpLinkHeader);
|
|
|
|
|
|
|
|
return ret;
|
1998-12-14 15:51:27 +01:00
|
|
|
}
|
1999-07-10 13:48:37 +02:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* IPersistStream_Save (IPersistStream)
|
1998-12-14 15:51:27 +01:00
|
|
|
*/
|
1999-07-10 13:48:37 +02:00
|
|
|
static HRESULT WINAPI IPersistStream_fnSave(
|
|
|
|
IPersistStream* iface,
|
|
|
|
IStream* pOutStream,
|
|
|
|
BOOL fClearDirty)
|
1999-01-17 17:32:32 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p) %p %x\n", This, pOutStream, fClearDirty);
|
|
|
|
|
1998-12-14 15:51:27 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
/************************************************************************
|
|
|
|
* IPersistStream_GetSizeMax (IPersistStream)
|
1999-02-24 16:58:26 +01:00
|
|
|
*/
|
1999-07-10 13:48:37 +02:00
|
|
|
static HRESULT WINAPI IPersistStream_fnGetSizeMax(
|
|
|
|
IPersistStream* iface,
|
|
|
|
ULARGE_INTEGER* pcbSize)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p)\n", This);
|
1998-11-25 17:39:47 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
static ICOM_VTABLE(IPersistStream) psvt =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
IPersistStream_fnQueryInterface,
|
|
|
|
IPersistStream_fnAddRef,
|
|
|
|
IPersistStream_fnRelease,
|
|
|
|
IPersistStream_fnGetClassID,
|
|
|
|
IPersistStream_fnIsDirty,
|
|
|
|
IPersistStream_fnLoad,
|
|
|
|
IPersistStream_fnSave,
|
|
|
|
IPersistStream_fnGetSizeMax
|
|
|
|
};
|
1998-11-25 17:39:47 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IShellLink_Constructor
|
|
|
|
*/
|
2002-07-02 04:05:17 +02:00
|
|
|
HRESULT WINAPI IShellLink_Constructor (
|
|
|
|
IUnknown * pUnkOuter,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppv)
|
|
|
|
{
|
|
|
|
IShellLinkImpl * sl;
|
|
|
|
|
|
|
|
TRACE("unkOut=%p riid=%s\n",pUnkOuter, debugstr_guid(riid));
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(pUnkOuter) return CLASS_E_NOAGGREGATION;
|
|
|
|
sl = (IShellLinkImpl *) LocalAlloc(GMEM_ZEROINIT,sizeof(IShellLinkImpl));
|
|
|
|
if (!sl) return E_OUTOFMEMORY;
|
1998-11-25 17:39:47 +01:00
|
|
|
|
|
|
|
sl->ref = 1;
|
1999-10-31 02:59:23 +01:00
|
|
|
ICOM_VTBL(sl) = &slvt;
|
1999-07-10 13:48:37 +02:00
|
|
|
sl->lpvtblw = &slvtw;
|
|
|
|
sl->lpvtblPersistFile = &pfvt;
|
|
|
|
sl->lpvtblPersistStream = &psvt;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)->()\n",sl);
|
2002-07-02 04:05:17 +02:00
|
|
|
|
2002-08-20 02:25:03 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IShellLinkA))
|
2002-07-02 04:05:17 +02:00
|
|
|
*ppv = sl;
|
|
|
|
else if (IsEqualIID(riid, &IID_IShellLinkW))
|
|
|
|
*ppv = &(sl->lpvtblw);
|
|
|
|
else {
|
|
|
|
LocalFree((HLOCAL)sl);
|
|
|
|
ERR("E_NOINTERFACE\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
1998-11-25 17:39:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2000-08-03 06:21:23 +02:00
|
|
|
* IShellLinkA_QueryInterface
|
1998-11-25 17:39:47 +01:00
|
|
|
*/
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID riid, LPVOID *ppvObj)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-01-18 06:09:49 +01:00
|
|
|
TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
|
1998-11-25 17:39:47 +01:00
|
|
|
|
1998-12-14 15:51:27 +01:00
|
|
|
*ppvObj = NULL;
|
1998-11-25 17:39:47 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
if(IsEqualIID(riid, &IID_IUnknown) ||
|
2000-08-03 06:21:23 +02:00
|
|
|
IsEqualIID(riid, &IID_IShellLinkA))
|
1999-07-10 13:48:37 +02:00
|
|
|
{
|
|
|
|
*ppvObj = This;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-07-10 13:48:37 +02:00
|
|
|
else if(IsEqualIID(riid, &IID_IShellLinkW))
|
|
|
|
{
|
|
|
|
*ppvObj = (IShellLinkW *)&(This->lpvtblw);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-07-10 13:48:37 +02:00
|
|
|
else if(IsEqualIID(riid, &IID_IPersistFile))
|
|
|
|
{
|
|
|
|
*ppvObj = (IPersistFile *)&(This->lpvtblPersistFile);
|
|
|
|
}
|
|
|
|
else if(IsEqualIID(riid, &IID_IPersistStream))
|
|
|
|
{
|
|
|
|
*ppvObj = (IPersistStream *)&(This->lpvtblPersistStream);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1998-11-25 17:39:47 +01:00
|
|
|
|
1998-12-14 15:51:27 +01:00
|
|
|
if(*ppvObj)
|
1999-07-10 13:48:37 +02:00
|
|
|
{
|
|
|
|
IUnknown_AddRef((IUnknown*)(*ppvObj));
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
|
1998-12-14 15:51:27 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("-- Interface: E_NOINTERFACE\n");
|
1998-12-14 15:51:27 +01:00
|
|
|
return E_NOINTERFACE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1998-11-25 17:39:47 +01:00
|
|
|
/******************************************************************************
|
2000-08-03 06:21:23 +02:00
|
|
|
* IShellLinkA_AddRef
|
1998-11-25 17:39:47 +01:00
|
|
|
*/
|
2000-08-03 06:21:23 +02:00
|
|
|
static ULONG WINAPI IShellLinkA_fnAddRef(IShellLinkA * iface)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
1999-01-23 15:12:48 +01:00
|
|
|
|
1999-02-24 16:58:26 +01:00
|
|
|
return ++(This->ref);
|
1998-11-25 17:39:47 +01:00
|
|
|
}
|
|
|
|
/******************************************************************************
|
2000-08-03 06:21:23 +02:00
|
|
|
* IShellLinkA_Release
|
1998-11-25 17:39:47 +01:00
|
|
|
*/
|
2000-08-03 06:21:23 +02:00
|
|
|
static ULONG WINAPI IShellLinkA_fnRelease(IShellLinkA * iface)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
1999-01-23 15:12:48 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!--(This->ref))
|
1999-06-12 17:45:58 +02:00
|
|
|
{ TRACE("-- destroying IShellLink(%p)\n",This);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
if (This->sIcoPath)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sIcoPath);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
if (This->sArgs)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sArgs);
|
|
|
|
|
|
|
|
if (This->sWorkDir)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sWorkDir);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
if (This->sDescription)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sDescription);
|
1999-07-10 13:48:37 +02:00
|
|
|
|
|
|
|
if (This->sPath)
|
|
|
|
HeapFree(GetProcessHeap(),0,This->sPath);
|
|
|
|
|
|
|
|
if (This->pPidl)
|
|
|
|
SHFree(This->pPidl);
|
|
|
|
|
|
|
|
if (This->lpFileStream)
|
|
|
|
IStream_Release(This->lpFileStream);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
This->iIcoNdx = 0;
|
1999-07-10 13:48:37 +02:00
|
|
|
|
2002-07-02 04:05:17 +02:00
|
|
|
LocalFree((HANDLE)This);
|
1998-12-14 15:51:27 +01:00
|
|
|
return 0;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
return This->ref;
|
1998-11-25 17:39:47 +01:00
|
|
|
}
|
|
|
|
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA * iface, LPSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)(%s)\n",This, pszFile, cchMaxPath, pfd, fFlags, debugstr_a(This->sPath));
|
|
|
|
|
|
|
|
if (This->sPath)
|
1999-07-25 14:21:43 +02:00
|
|
|
lstrcpynA(pszFile,This->sPath, cchMaxPath);
|
1999-07-10 13:48:37 +02:00
|
|
|
else
|
|
|
|
return E_FAIL;
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnGetIDList(IShellLinkA * iface, LPITEMIDLIST * ppidl)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)->(ppidl=%p)\n",This, ppidl);
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
*ppidl = ILClone(This->pPidl);
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnSetIDList(IShellLinkA * iface, LPCITEMIDLIST pidl)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)->(pidl=%p)\n",This, pidl);
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
if (This->pPidl)
|
|
|
|
SHFree(This->pPidl);
|
|
|
|
This->pPidl = ILClone (pidl);
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnGetDescription(IShellLinkA * iface, LPSTR pszName,INT cchMaxName)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
|
1999-07-25 14:21:43 +02:00
|
|
|
lstrcpynA(pszName,"Description, FIXME",cchMaxName);
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnSetDescription(IShellLinkA * iface, LPCSTR pszName)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
TRACE("(%p)->(pName=%s)\n", This, pszName);
|
|
|
|
|
|
|
|
if (This->sDescription)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sDescription);
|
2001-07-24 23:45:22 +02:00
|
|
|
if (!(This->sDescription = heap_strdup(pszName)))
|
2000-11-02 21:22:07 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnGetWorkingDirectory(IShellLinkA * iface, LPSTR pszDir,INT cchMaxPath)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-12 02:17:39 +01:00
|
|
|
TRACE("(%p)->(%p len=%u)\n", This, pszDir, cchMaxPath);
|
|
|
|
|
|
|
|
lstrcpynA( pszDir, This->sWorkDir ? This->sWorkDir : "", cchMaxPath );
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnSetWorkingDirectory(IShellLinkA * iface, LPCSTR pszDir)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
TRACE("(%p)->(dir=%s)\n",This, pszDir);
|
|
|
|
|
|
|
|
if (This->sWorkDir)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sWorkDir);
|
2001-07-24 23:45:22 +02:00
|
|
|
if (!(This->sWorkDir = heap_strdup(pszDir)))
|
2000-11-02 21:22:07 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnGetArguments(IShellLinkA * iface, LPSTR pszArgs,INT cchMaxPath)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-12 02:17:39 +01:00
|
|
|
TRACE("(%p)->(%p len=%u)\n", This, pszArgs, cchMaxPath);
|
|
|
|
|
|
|
|
lstrcpynA( pszArgs, This->sArgs ? This->sArgs : "", cchMaxPath );
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnSetArguments(IShellLinkA * iface, LPCSTR pszArgs)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
TRACE("(%p)->(args=%s)\n",This, pszArgs);
|
|
|
|
|
|
|
|
if (This->sArgs)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sArgs);
|
2001-07-24 23:45:22 +02:00
|
|
|
if (!(This->sArgs = heap_strdup(pszArgs)))
|
2000-11-02 21:22:07 +01:00
|
|
|
return E_OUTOFMEMORY;
|
1999-07-10 13:48:37 +02:00
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnGetHotkey(IShellLinkA * iface, WORD *pwHotkey)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p)->(%p)(0x%08x)\n",This, pwHotkey, This->wHotKey);
|
|
|
|
|
|
|
|
*pwHotkey = This->wHotKey;
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnSetHotkey(IShellLinkA * iface, WORD wHotkey)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
TRACE("(%p)->(hotkey=%x)\n",This, wHotkey);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 13:48:37 +02:00
|
|
|
This->wHotKey = wHotkey;
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnGetShowCmd(IShellLinkA * iface, INT *piShowCmd)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)->(%p)\n",This, piShowCmd);
|
1998-11-25 17:39:47 +01:00
|
|
|
*piShowCmd=0;
|
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnSetShowCmd(IShellLinkA * iface, INT iShowCmd)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-11-15 01:02:36 +01:00
|
|
|
/* SW_SHOWNORMAL is the default ... The others would have
|
|
|
|
* to be somehow passed through the link file ... We can't
|
|
|
|
* do that currently.
|
|
|
|
*/
|
|
|
|
if (iShowCmd != SW_SHOWNORMAL)
|
|
|
|
FIXME("(%p)->(showcmd=%x)\n",This, iShowCmd);
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR pszIconPath,INT cchIconPath,INT *piIcon)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-12 02:17:39 +01:00
|
|
|
TRACE("(%p)->(%p len=%u iicon=%p)\n", This, pszIconPath, cchIconPath, piIcon);
|
|
|
|
|
|
|
|
lstrcpynA( pszIconPath, This->sIcoPath ? This->sIcoPath : "", cchIconPath );
|
|
|
|
*piIcon = This->iIcoNdx;
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA * iface, LPCSTR pszIconPath,INT iIcon)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
TRACE("(%p)->(path=%s iicon=%u)\n",This, pszIconPath, iIcon);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
if (This->sIcoPath)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sIcoPath);
|
2001-07-24 23:45:22 +02:00
|
|
|
if (!(This->sIcoPath = heap_strdup(pszIconPath)))
|
2002-06-01 01:06:46 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2000-11-02 21:22:07 +01:00
|
|
|
This->iIcoNdx = iIcon;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA * iface, LPCSTR pszPathRel, DWORD dwReserved)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)->(path=%s %lx)\n",This, pszPathRel, dwReserved);
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnResolve(IShellLinkA * iface, HWND hwnd, DWORD fFlags)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
FIXME("(%p)->(hwnd=%p flags=%lx)\n",This, hwnd, fFlags);
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-03 06:21:23 +02:00
|
|
|
static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA * iface, LPCSTR pszFile)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
TRACE("(%p)->(path=%s)\n",This, pszFile);
|
|
|
|
|
|
|
|
if (This->sPath)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sPath);
|
2001-07-24 23:45:22 +02:00
|
|
|
if (!(This->sPath = heap_strdup(pszFile)))
|
2000-11-02 21:22:07 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
1999-02-24 16:58:26 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* IShellLink Implementation
|
|
|
|
*/
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static ICOM_VTABLE(IShellLinkA) slvt =
|
|
|
|
{
|
1999-05-22 13:41:38 +02:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
2000-08-03 06:21:23 +02:00
|
|
|
IShellLinkA_fnQueryInterface,
|
|
|
|
IShellLinkA_fnAddRef,
|
|
|
|
IShellLinkA_fnRelease,
|
|
|
|
IShellLinkA_fnGetPath,
|
|
|
|
IShellLinkA_fnGetIDList,
|
|
|
|
IShellLinkA_fnSetIDList,
|
|
|
|
IShellLinkA_fnGetDescription,
|
|
|
|
IShellLinkA_fnSetDescription,
|
|
|
|
IShellLinkA_fnGetWorkingDirectory,
|
|
|
|
IShellLinkA_fnSetWorkingDirectory,
|
|
|
|
IShellLinkA_fnGetArguments,
|
|
|
|
IShellLinkA_fnSetArguments,
|
|
|
|
IShellLinkA_fnGetHotkey,
|
|
|
|
IShellLinkA_fnSetHotkey,
|
|
|
|
IShellLinkA_fnGetShowCmd,
|
|
|
|
IShellLinkA_fnSetShowCmd,
|
|
|
|
IShellLinkA_fnGetIconLocation,
|
|
|
|
IShellLinkA_fnSetIconLocation,
|
|
|
|
IShellLinkA_fnSetRelativePath,
|
|
|
|
IShellLinkA_fnResolve,
|
|
|
|
IShellLinkA_fnSetPath
|
1999-02-24 16:58:26 +01:00
|
|
|
};
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
1999-02-24 16:58:26 +01:00
|
|
|
* IShellLinkW_fnQueryInterface
|
1998-11-25 17:39:47 +01:00
|
|
|
*/
|
1999-02-24 16:58:26 +01:00
|
|
|
static HRESULT WINAPI IShellLinkW_fnQueryInterface(
|
|
|
|
IShellLinkW * iface, REFIID riid, LPVOID *ppvObj)
|
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-03 06:21:23 +02:00
|
|
|
return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObj);
|
1999-07-10 13:48:37 +02:00
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
/******************************************************************************
|
1999-02-24 16:58:26 +01:00
|
|
|
* IShellLinkW_fnAddRef
|
1998-11-25 17:39:47 +01:00
|
|
|
*/
|
1999-02-24 16:58:26 +01:00
|
|
|
static ULONG WINAPI IShellLinkW_fnAddRef(IShellLinkW * iface)
|
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
1999-01-23 15:12:48 +01:00
|
|
|
|
2000-08-03 06:21:23 +02:00
|
|
|
return IShellLinkA_AddRef((IShellLinkA*)This);
|
1998-11-25 17:39:47 +01:00
|
|
|
}
|
|
|
|
/******************************************************************************
|
1999-02-24 16:58:26 +01:00
|
|
|
* IShellLinkW_fnRelease
|
1998-11-25 17:39:47 +01:00
|
|
|
*/
|
1999-02-24 16:58:26 +01:00
|
|
|
|
|
|
|
static ULONG WINAPI IShellLinkW_fnRelease(IShellLinkW * iface)
|
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
1999-01-23 15:12:48 +01:00
|
|
|
|
2000-08-03 06:21:23 +02:00
|
|
|
return IShellLinkA_Release((IShellLinkA*)This);
|
1998-11-25 17:39:47 +01:00
|
|
|
}
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This, pszFile, cchMaxPath, pfd, fFlags);
|
2000-11-28 23:40:56 +01:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, "c:\\foo.bar", -1, pszFile, cchMaxPath );
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST * ppidl)
|
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)->(ppidl=%p)\n",This, ppidl);
|
1998-11-25 17:39:47 +01:00
|
|
|
*ppidl = _ILCreateDesktop();
|
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST pidl)
|
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)->(pidl=%p)\n",This, pidl);
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI IShellLinkW_fnGetDescription(IShellLinkW * iface, LPWSTR pszName,INT cchMaxName)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
|
2000-11-28 23:40:56 +01:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, "Description, FIXME", -1, pszName, cchMaxName );
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI IShellLinkW_fnSetDescription(IShellLinkW * iface, LPCWSTR pszName)
|
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
TRACE("(%p)->(desc=%s)\n",This, debugstr_w(pszName));
|
|
|
|
|
|
|
|
if (This->sDescription)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sDescription);
|
|
|
|
if (!(This->sDescription = HEAP_strdupWtoA(GetProcessHeap(), 0, pszName)))
|
|
|
|
return E_OUTOFMEMORY;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI IShellLinkW_fnGetWorkingDirectory(IShellLinkW * iface, LPWSTR pszDir,INT cchMaxPath)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-12 02:17:39 +01:00
|
|
|
TRACE("(%p)->(%p len %u)\n", This, pszDir, cchMaxPath);
|
|
|
|
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, This->sWorkDir ? This->sWorkDir : "", -1, pszDir, cchMaxPath );
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI IShellLinkW_fnSetWorkingDirectory(IShellLinkW * iface, LPCWSTR pszDir)
|
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
TRACE("(%p)->(dir=%s)\n",This, debugstr_w(pszDir));
|
|
|
|
|
|
|
|
if (This->sWorkDir)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sWorkDir);
|
|
|
|
if (!(This->sWorkDir = HEAP_strdupWtoA(GetProcessHeap(), 0, pszDir)))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI IShellLinkW_fnGetArguments(IShellLinkW * iface, LPWSTR pszArgs,INT cchMaxPath)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-12 02:17:39 +01:00
|
|
|
TRACE("(%p)->(%p len=%u)\n", This, pszArgs, cchMaxPath);
|
|
|
|
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, This->sArgs ? This->sArgs : "", -1, pszArgs, cchMaxPath );
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI IShellLinkW_fnSetArguments(IShellLinkW * iface, LPCWSTR pszArgs)
|
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
TRACE("(%p)->(args=%s)\n",This, debugstr_w(pszArgs));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
if (This->sArgs)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sArgs);
|
|
|
|
if (!(This->sArgs = HEAP_strdupWtoA(GetProcessHeap(), 0, pszArgs)))
|
|
|
|
return E_OUTOFMEMORY;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI IShellLinkW_fnGetHotkey(IShellLinkW * iface, WORD *pwHotkey)
|
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)->(%p)\n",This, pwHotkey);
|
1998-11-25 17:39:47 +01:00
|
|
|
*pwHotkey=0x0;
|
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI IShellLinkW_fnSetHotkey(IShellLinkW * iface, WORD wHotkey)
|
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)->(hotkey=%x)\n",This, wHotkey);
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI IShellLinkW_fnGetShowCmd(IShellLinkW * iface, INT *piShowCmd)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)->(%p)\n",This, piShowCmd);
|
1998-11-25 17:39:47 +01:00
|
|
|
*piShowCmd=0;
|
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI IShellLinkW_fnSetShowCmd(IShellLinkW * iface, INT iShowCmd)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-11-13 00:25:33 +01:00
|
|
|
/* SW_SHOWNORMAL is the default ... The others would have
|
|
|
|
* to be somehow passed through the link file ... We can't
|
|
|
|
* do that currently.
|
|
|
|
*/
|
|
|
|
if (iShowCmd != SW_SHOWNORMAL)
|
|
|
|
FIXME("(%p)->(showcmd=%x)\n",This, iShowCmd);
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR pszIconPath,INT cchIconPath,INT *piIcon)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-12 02:17:39 +01:00
|
|
|
TRACE("(%p)->(%p len=%u iicon=%p)\n", This, pszIconPath, cchIconPath, piIcon);
|
|
|
|
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, This->sIcoPath ? This->sIcoPath : "", -1, pszIconPath, cchIconPath );
|
|
|
|
*piIcon = This->iIcoNdx;
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath,INT iIcon)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
TRACE("(%p)->(path=%s iicon=%u)\n",This, debugstr_w(pszIconPath), iIcon);
|
|
|
|
|
|
|
|
if (This->sIcoPath)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sIcoPath);
|
|
|
|
if (!(This->sIcoPath = HEAP_strdupWtoA(GetProcessHeap(), 0, pszIconPath)))
|
2002-06-01 01:06:46 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2000-11-02 21:22:07 +01:00
|
|
|
This->iIcoNdx = iIcon;
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI IShellLinkW_fnSetRelativePath(IShellLinkW * iface, LPCWSTR pszPathRel, DWORD dwReserved)
|
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p)->(path=%s %lx)\n",This, debugstr_w(pszPathRel), dwReserved);
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWORD fFlags)
|
1999-02-24 16:58:26 +01:00
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
FIXME("(%p)->(hwnd=%p flags=%lx)\n",This, hwnd, fFlags);
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
1999-02-24 16:58:26 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile)
|
|
|
|
{
|
1999-07-10 13:48:37 +02:00
|
|
|
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
TRACE("(%p)->(path=%s)\n",This, debugstr_w(pszFile));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
if (This->sPath)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->sPath);
|
|
|
|
if (!(This->sPath = HEAP_strdupWtoA(GetProcessHeap(), 0, pszFile)))
|
2002-06-01 01:06:46 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
1998-11-25 17:39:47 +01:00
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
1999-02-24 16:58:26 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* IShellLinkW Implementation
|
|
|
|
*/
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static ICOM_VTABLE(IShellLinkW) slvtw =
|
|
|
|
{
|
1999-05-22 13:41:38 +02:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
IShellLinkW_fnQueryInterface,
|
1999-02-24 16:58:26 +01:00
|
|
|
IShellLinkW_fnAddRef,
|
|
|
|
IShellLinkW_fnRelease,
|
|
|
|
IShellLinkW_fnGetPath,
|
|
|
|
IShellLinkW_fnGetIDList,
|
|
|
|
IShellLinkW_fnSetIDList,
|
|
|
|
IShellLinkW_fnGetDescription,
|
|
|
|
IShellLinkW_fnSetDescription,
|
|
|
|
IShellLinkW_fnGetWorkingDirectory,
|
|
|
|
IShellLinkW_fnSetWorkingDirectory,
|
|
|
|
IShellLinkW_fnGetArguments,
|
|
|
|
IShellLinkW_fnSetArguments,
|
|
|
|
IShellLinkW_fnGetHotkey,
|
|
|
|
IShellLinkW_fnSetHotkey,
|
|
|
|
IShellLinkW_fnGetShowCmd,
|
|
|
|
IShellLinkW_fnSetShowCmd,
|
|
|
|
IShellLinkW_fnGetIconLocation,
|
|
|
|
IShellLinkW_fnSetIconLocation,
|
|
|
|
IShellLinkW_fnSetRelativePath,
|
|
|
|
IShellLinkW_fnResolve,
|
|
|
|
IShellLinkW_fnSetPath
|
|
|
|
};
|