[4121] | 1 | /*
|
---|
| 2 | *
|
---|
[6709] | 3 | * Copyright 1997 Marcus Meissner
|
---|
| 4 | * Copyright 1998 Juergen Schmied
|
---|
[4121] | 5 | *
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[5618] | 8 | #include "config.h"
|
---|
| 9 |
|
---|
[4121] | 10 | #include <string.h>
|
---|
[4561] | 11 | #include <sys/stat.h>
|
---|
| 12 | #include <stdio.h>
|
---|
| 13 | #ifndef __WIN32OS2__
|
---|
| 14 | #include <unistd.h>
|
---|
| 15 | #endif
|
---|
| 16 | #include <errno.h>
|
---|
[5618] | 17 | #ifdef HAVE_SYS_WAIT_H
|
---|
| 18 | # include <sys/wait.h>
|
---|
[4561] | 19 | #endif
|
---|
[4121] | 20 | #include "debugtools.h"
|
---|
| 21 | #include "winerror.h"
|
---|
[4561] | 22 | #include "winbase.h"
|
---|
| 23 | #include "winnls.h"
|
---|
[5618] | 24 | #include "winreg.h"
|
---|
[4121] | 25 |
|
---|
[4561] | 26 | #include "shlobj.h"
|
---|
[8614] | 27 | #include "undocshell.h"
|
---|
[6481] | 28 | #ifdef __WIN32OS2__
|
---|
[9888] | 29 | #include <winbase.h>
|
---|
[6481] | 30 | #define NO_DCDATA
|
---|
| 31 | #include <winuser32.h>
|
---|
| 32 | #include <winres.h>
|
---|
| 33 | #else
|
---|
[4561] | 34 | #include "bitmaps/wine.xpm"
|
---|
| 35 | #endif
|
---|
[4121] | 36 |
|
---|
| 37 | #include "heap.h"
|
---|
| 38 | #include "pidl.h"
|
---|
| 39 | #include "shell32_main.h"
|
---|
| 40 | #include "shlguid.h"
|
---|
| 41 |
|
---|
| 42 | DEFAULT_DEBUG_CHANNEL(shell);
|
---|
| 43 |
|
---|
| 44 | /* link file formats */
|
---|
| 45 |
|
---|
| 46 | #include "pshpack1.h"
|
---|
| 47 |
|
---|
| 48 | /* flag1: lnk elements: simple link has 0x0B */
|
---|
[6709] | 49 | #define WORKDIR 0x10
|
---|
| 50 | #define ARGUMENT 0x20
|
---|
| 51 | #define ICON 0x40
|
---|
| 52 | #define UNC 0x80
|
---|
[4121] | 53 |
|
---|
| 54 | /* fStartup */
|
---|
[6709] | 55 | #define NORMAL 0x01
|
---|
| 56 | #define MAXIMIZED 0x03
|
---|
| 57 | #define MINIMIZED 0x07
|
---|
[4121] | 58 |
|
---|
[6709] | 59 | typedef struct _LINK_HEADER
|
---|
| 60 | { DWORD MagicStr; /* 0x00 'L','\0','\0','\0' */
|
---|
| 61 | GUID MagicGuid; /* 0x04 is CLSID_ShellLink */
|
---|
| 62 | DWORD Flag1; /* 0x14 describes elements following */
|
---|
| 63 | DWORD Flag2; /* 0x18 */
|
---|
| 64 | FILETIME Time1; /* 0x1c */
|
---|
| 65 | FILETIME Time2; /* 0x24 */
|
---|
| 66 | FILETIME Time3; /* 0x2c */
|
---|
| 67 | DWORD Unknown1; /* 0x34 */
|
---|
| 68 | DWORD Unknown2; /* 0x38 icon number */
|
---|
| 69 | DWORD fStartup; /* 0x3c startup type */
|
---|
| 70 | DWORD wHotKey; /* 0x40 hotkey */
|
---|
| 71 | DWORD Unknown5; /* 0x44 */
|
---|
| 72 | DWORD Unknown6; /* 0x48 */
|
---|
| 73 | USHORT PidlSize; /* 0x4c */
|
---|
| 74 | ITEMIDLIST Pidl; /* 0x4e */
|
---|
[4121] | 75 | } LINK_HEADER, * PLINK_HEADER;
|
---|
| 76 |
|
---|
| 77 | #define LINK_HEADER_SIZE (sizeof(LINK_HEADER)-sizeof(ITEMIDLIST))
|
---|
| 78 |
|
---|
[4561] | 79 | typedef struct
|
---|
| 80 | {
|
---|
[6709] | 81 | BYTE bWidth;
|
---|
| 82 | BYTE bHeight;
|
---|
| 83 | BYTE bColorCount;
|
---|
| 84 | BYTE bReserved;
|
---|
| 85 | WORD wPlanes;
|
---|
| 86 | WORD wBitCount;
|
---|
| 87 | DWORD dwBytesInRes;
|
---|
| 88 | WORD nID;
|
---|
[4561] | 89 | } GRPICONDIRENTRY;
|
---|
| 90 |
|
---|
| 91 | typedef struct
|
---|
| 92 | {
|
---|
[6709] | 93 | WORD idReserved;
|
---|
| 94 | WORD idType;
|
---|
| 95 | WORD idCount;
|
---|
| 96 | GRPICONDIRENTRY idEntries[1];
|
---|
[4561] | 97 | } GRPICONDIR;
|
---|
| 98 |
|
---|
| 99 | typedef struct
|
---|
| 100 | {
|
---|
[6709] | 101 | BYTE bWidth;
|
---|
| 102 | BYTE bHeight;
|
---|
| 103 | BYTE bColorCount;
|
---|
| 104 | BYTE bReserved;
|
---|
| 105 | WORD wPlanes;
|
---|
| 106 | WORD wBitCount;
|
---|
| 107 | DWORD dwBytesInRes;
|
---|
| 108 | DWORD dwImageOffset;
|
---|
[4561] | 109 | } ICONDIRENTRY;
|
---|
| 110 |
|
---|
| 111 | typedef struct
|
---|
| 112 | {
|
---|
[6709] | 113 | WORD idReserved;
|
---|
| 114 | WORD idType;
|
---|
| 115 | WORD idCount;
|
---|
[4561] | 116 | } ICONDIR;
|
---|
| 117 |
|
---|
| 118 |
|
---|
[4121] | 119 | #include "poppack.h"
|
---|
| 120 |
|
---|
[8048] | 121 | typedef struct
|
---|
| 122 | {
|
---|
| 123 | HRSRC *pResInfo;
|
---|
| 124 | int nIndex;
|
---|
| 125 | } ENUMRESSTRUCT;
|
---|
[4561] | 126 |
|
---|
[6709] | 127 | static ICOM_VTABLE(IShellLinkA) slvt;
|
---|
| 128 | static ICOM_VTABLE(IShellLinkW) slvtw;
|
---|
| 129 | static ICOM_VTABLE(IPersistFile) pfvt;
|
---|
| 130 | static ICOM_VTABLE(IPersistStream) psvt;
|
---|
[4121] | 131 |
|
---|
| 132 | /* IShellLink Implementation */
|
---|
| 133 |
|
---|
| 134 | typedef struct
|
---|
| 135 | {
|
---|
[6709] | 136 | ICOM_VFIELD(IShellLinkA);
|
---|
| 137 | DWORD ref;
|
---|
[4121] | 138 |
|
---|
[6709] | 139 | ICOM_VTABLE(IShellLinkW)* lpvtblw;
|
---|
| 140 | ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
|
---|
| 141 | ICOM_VTABLE(IPersistStream)* lpvtblPersistStream;
|
---|
| 142 |
|
---|
| 143 | /* internal stream of the IPersistFile interface */
|
---|
| 144 | IStream* lpFileStream;
|
---|
| 145 |
|
---|
| 146 | /* data structures according to the informations in the lnk */
|
---|
| 147 | LPSTR sPath;
|
---|
| 148 | LPITEMIDLIST pPidl;
|
---|
| 149 | WORD wHotKey;
|
---|
| 150 | SYSTEMTIME time1;
|
---|
| 151 | SYSTEMTIME time2;
|
---|
| 152 | SYSTEMTIME time3;
|
---|
[4121] | 153 |
|
---|
[6709] | 154 | LPSTR sIcoPath;
|
---|
| 155 | INT iIcoNdx;
|
---|
| 156 | LPSTR sArgs;
|
---|
| 157 | LPSTR sWorkDir;
|
---|
| 158 | LPSTR sDescription;
|
---|
[4121] | 159 | } IShellLinkImpl;
|
---|
| 160 |
|
---|
| 161 | #define _IShellLinkW_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblw)))
|
---|
| 162 | #define _ICOM_THIS_From_IShellLinkW(class, name) class* This = (class*)(((char*)name)-_IShellLinkW_Offset);
|
---|
| 163 |
|
---|
| 164 | #define _IPersistFile_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistFile)))
|
---|
| 165 | #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
|
---|
| 166 |
|
---|
| 167 | #define _IPersistStream_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistStream)))
|
---|
| 168 | #define _ICOM_THIS_From_IPersistStream(class, name) class* This = (class*)(((char*)name)-_IPersistStream_Offset);
|
---|
| 169 | #define _IPersistStream_From_ICOM_THIS(class, name) class* StreamThis = (class*)(((char*)name)+_IPersistStream_Offset);
|
---|
| 170 |
|
---|
[8048] | 171 |
|
---|
| 172 | /* strdup on the process heap */
|
---|
| 173 | inline static LPSTR heap_strdup( LPCSTR str )
|
---|
| 174 | {
|
---|
| 175 | INT len = strlen(str) + 1;
|
---|
| 176 | LPSTR p = HeapAlloc( GetProcessHeap(), 0, len );
|
---|
| 177 | if (p) memcpy( p, str, len );
|
---|
| 178 | return p;
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 |
|
---|
[4121] | 182 | /**************************************************************************
|
---|
| 183 | * IPersistFile_QueryInterface
|
---|
| 184 | */
|
---|
| 185 | static HRESULT WINAPI IPersistFile_fnQueryInterface(
|
---|
[6709] | 186 | IPersistFile* iface,
|
---|
| 187 | REFIID riid,
|
---|
| 188 | LPVOID *ppvObj)
|
---|
[4121] | 189 | {
|
---|
[6709] | 190 | _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
|
---|
[4121] | 191 |
|
---|
[6709] | 192 | TRACE("(%p)\n",This);
|
---|
[4121] | 193 |
|
---|
[6709] | 194 | return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObj);
|
---|
[4121] | 195 | }
|
---|
| 196 |
|
---|
| 197 | /******************************************************************************
|
---|
| 198 | * IPersistFile_AddRef
|
---|
| 199 | */
|
---|
| 200 | static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile* iface)
|
---|
| 201 | {
|
---|
[6709] | 202 | _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
|
---|
[4121] | 203 |
|
---|
[6709] | 204 | TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
---|
[4121] | 205 |
|
---|
[6709] | 206 | return IShellLinkA_AddRef((IShellLinkA*)This);
|
---|
[4121] | 207 | }
|
---|
| 208 | /******************************************************************************
|
---|
| 209 | * IPersistFile_Release
|
---|
| 210 | */
|
---|
| 211 | static ULONG WINAPI IPersistFile_fnRelease(IPersistFile* iface)
|
---|
| 212 | {
|
---|
[6709] | 213 | _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
|
---|
[4121] | 214 |
|
---|
[6709] | 215 | TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
---|
[4121] | 216 |
|
---|
[6709] | 217 | return IShellLinkA_Release((IShellLinkA*)This);
|
---|
[4121] | 218 | }
|
---|
| 219 |
|
---|
| 220 | static HRESULT WINAPI IPersistFile_fnGetClassID(IPersistFile* iface, CLSID *pClassID)
|
---|
| 221 | {
|
---|
[6709] | 222 | _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
|
---|
| 223 | FIXME("(%p)\n",This);
|
---|
| 224 | return NOERROR;
|
---|
[4121] | 225 | }
|
---|
| 226 | static HRESULT WINAPI IPersistFile_fnIsDirty(IPersistFile* iface)
|
---|
| 227 | {
|
---|
[6709] | 228 | _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
|
---|
| 229 | FIXME("(%p)\n",This);
|
---|
| 230 | return NOERROR;
|
---|
[4121] | 231 | }
|
---|
| 232 | static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
|
---|
| 233 | {
|
---|
[7336] | 234 | HRESULT hRet = E_FAIL;
|
---|
| 235 | LPSTR sFile;
|
---|
| 236 |
|
---|
| 237 | _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
|
---|
[6709] | 238 | _IPersistStream_From_ICOM_THIS(IPersistStream, This)
|
---|
[4121] | 239 |
|
---|
[7336] | 240 | sFile = HEAP_strdupWtoA ( GetProcessHeap(), 0, pszFileName);
|
---|
[4121] | 241 |
|
---|
[6709] | 242 | TRACE("(%p, %s)\n",This, sFile);
|
---|
| 243 |
|
---|
[4121] | 244 |
|
---|
[6709] | 245 | if (This->lpFileStream)
|
---|
| 246 | IStream_Release(This->lpFileStream);
|
---|
| 247 |
|
---|
| 248 | if SUCCEEDED(CreateStreamOnFile(sFile, &(This->lpFileStream)))
|
---|
| 249 | {
|
---|
| 250 | if SUCCEEDED (IPersistStream_Load(StreamThis, This->lpFileStream))
|
---|
| 251 | {
|
---|
[7336] | 252 | hRet = NOERROR;
|
---|
[6709] | 253 | }
|
---|
| 254 | }
|
---|
| 255 |
|
---|
[7343] | 256 | #ifdef __WIN32OS2__
|
---|
[7336] | 257 | // PH 2001-11-13 memory leak in WINE?
|
---|
| 258 | HeapFree( GetProcessHeap(), 0, sFile);
|
---|
| 259 | #endif
|
---|
| 260 |
|
---|
[6709] | 261 | return hRet;
|
---|
[4121] | 262 | }
|
---|
| 263 |
|
---|
[4561] | 264 |
|
---|
[6481] | 265 | #ifdef __WIN32OS2__
|
---|
[21916] | 266 | static BOOL SaveIconFileAsOS2ICO(const char *szFileName, const char *szXPMFileName)
|
---|
[9851] | 267 | {
|
---|
[9888] | 268 | HFILE fXPMFile = NULL, fICOFile = NULL;
|
---|
[9851] | 269 | void *lpOS2Icon = NULL, *lpWinIcon = NULL;
|
---|
| 270 | DWORD ressize, filesize;
|
---|
| 271 | BOOL ret = FALSE;
|
---|
| 272 |
|
---|
[9888] | 273 | if (!(fICOFile = _lopen(szFileName, OF_READ)))
|
---|
[9851] | 274 | goto failure;
|
---|
[9888] | 275 | _llseek(fICOFile, 0, FILE_END);
|
---|
| 276 | filesize = _llseek(fICOFile, 0, FILE_CURRENT);
|
---|
| 277 | _llseek(fICOFile, 0, FILE_BEGIN);
|
---|
[9851] | 278 |
|
---|
| 279 | lpWinIcon = malloc(filesize);
|
---|
| 280 | if(lpWinIcon == NULL) goto failure;
|
---|
[9888] | 281 | if (_lread(fICOFile, lpWinIcon, filesize) != filesize)
|
---|
[9851] | 282 | goto failure;
|
---|
| 283 |
|
---|
[9888] | 284 | if (!(fXPMFile = _lcreat(szXPMFileName, OF_READWRITE)))
|
---|
[9851] | 285 | goto failure;
|
---|
| 286 |
|
---|
| 287 | lpOS2Icon = ConvertIconGroupIndirect(lpWinIcon, filesize, &ressize);
|
---|
| 288 | if(lpOS2Icon) {
|
---|
[9888] | 289 | _lwrite(fXPMFile, lpOS2Icon, ressize);
|
---|
[9851] | 290 | }
|
---|
| 291 | ret = TRUE;
|
---|
| 292 |
|
---|
| 293 | failure:
|
---|
[9888] | 294 | if(fICOFile) _lclose(fICOFile);
|
---|
| 295 | if(fXPMFile) _lclose(fXPMFile);
|
---|
[9851] | 296 | if(lpWinIcon) free(lpWinIcon);
|
---|
| 297 | if(lpOS2Icon) free(lpOS2Icon);
|
---|
| 298 | return ret;
|
---|
| 299 | }
|
---|
| 300 |
|
---|
[6709] | 301 | static BOOL SaveIconResAsOS2ICO(GRPICONDIR *pIconDir, HINSTANCE hInstance,
|
---|
[6486] | 302 | const char *szXPMFileName)
|
---|
[6481] | 303 | {
|
---|
| 304 | FILE *fXPMFile;
|
---|
| 305 | void *lpOS2Icon;
|
---|
| 306 | DWORD ressize;
|
---|
| 307 |
|
---|
[6492] | 308 | if (!(fXPMFile = fopen(szXPMFileName, "wb")))
|
---|
[6481] | 309 | return 0;
|
---|
| 310 |
|
---|
| 311 | lpOS2Icon = ConvertIconGroup((void *)pIconDir, hInstance, &ressize);
|
---|
| 312 | if(lpOS2Icon) {
|
---|
| 313 | fwrite(lpOS2Icon, 1, ressize, fXPMFile);
|
---|
| 314 | free(lpOS2Icon);
|
---|
| 315 | }
|
---|
| 316 | fclose(fXPMFile);
|
---|
| 317 | return 1;
|
---|
| 318 | }
|
---|
| 319 | #else
|
---|
[4561] | 320 | /* Icon extraction routines
|
---|
| 321 | *
|
---|
| 322 | * FIXME: should use PrivateExtractIcons and friends
|
---|
| 323 | * FIXME: should not use stdio
|
---|
| 324 | */
|
---|
| 325 |
|
---|
| 326 | static BOOL SaveIconResAsXPM(const BITMAPINFO *pIcon, const char *szXPMFileName)
|
---|
| 327 | {
|
---|
| 328 | FILE *fXPMFile;
|
---|
| 329 | int nHeight;
|
---|
| 330 | int nXORWidthBytes;
|
---|
| 331 | int nANDWidthBytes;
|
---|
| 332 | BOOL b8BitColors;
|
---|
| 333 | int nColors;
|
---|
| 334 | BYTE *pXOR;
|
---|
| 335 | BYTE *pAND;
|
---|
| 336 | BOOL aColorUsed[256] = {0};
|
---|
| 337 | int nColorsUsed = 0;
|
---|
| 338 | int i,j;
|
---|
| 339 |
|
---|
| 340 | if (!((pIcon->bmiHeader.biBitCount == 4) || (pIcon->bmiHeader.biBitCount == 8)))
|
---|
| 341 | return 0;
|
---|
| 342 |
|
---|
| 343 | if (!(fXPMFile = fopen(szXPMFileName, "w")))
|
---|
| 344 | return 0;
|
---|
| 345 |
|
---|
| 346 | nHeight = pIcon->bmiHeader.biHeight / 2;
|
---|
| 347 | nXORWidthBytes = 4 * ((pIcon->bmiHeader.biWidth * pIcon->bmiHeader.biBitCount / 32)
|
---|
| 348 | + ((pIcon->bmiHeader.biWidth * pIcon->bmiHeader.biBitCount % 32) > 0));
|
---|
| 349 | nANDWidthBytes = 4 * ((pIcon->bmiHeader.biWidth / 32)
|
---|
| 350 | + ((pIcon->bmiHeader.biWidth % 32) > 0));
|
---|
| 351 | b8BitColors = pIcon->bmiHeader.biBitCount == 8;
|
---|
| 352 | nColors = pIcon->bmiHeader.biClrUsed ? pIcon->bmiHeader.biClrUsed
|
---|
| 353 | : 1 << pIcon->bmiHeader.biBitCount;
|
---|
| 354 | pXOR = (BYTE*) pIcon + sizeof (BITMAPINFOHEADER) + (nColors * sizeof (RGBQUAD));
|
---|
| 355 | pAND = pXOR + nHeight * nXORWidthBytes;
|
---|
| 356 |
|
---|
| 357 | #define MASK(x,y) (pAND[(x) / 8 + (nHeight - (y) - 1) * nANDWidthBytes] & (1 << (7 - (x) % 8)))
|
---|
| 358 | #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)
|
---|
| 359 |
|
---|
| 360 | for (i = 0; i < nHeight; i++)
|
---|
| 361 | for (j = 0; j < pIcon->bmiHeader.biWidth; j++)
|
---|
| 362 | if (!aColorUsed[COLOR(j,i)] && !MASK(j,i))
|
---|
| 363 | {
|
---|
| 364 | aColorUsed[COLOR(j,i)] = TRUE;
|
---|
| 365 | nColorsUsed++;
|
---|
| 366 | }
|
---|
| 367 |
|
---|
| 368 | if (fprintf(fXPMFile, "/* XPM */\nstatic char *icon[] = {\n") <= 0)
|
---|
| 369 | goto error;
|
---|
| 370 | if (fprintf(fXPMFile, "\"%d %d %d %d\",\n",
|
---|
| 371 | (int) pIcon->bmiHeader.biWidth, nHeight, nColorsUsed + 1, 2) <=0)
|
---|
| 372 | goto error;
|
---|
| 373 |
|
---|
| 374 | for (i = 0; i < nColors; i++)
|
---|
| 375 | if (aColorUsed[i])
|
---|
| 376 | if (fprintf(fXPMFile, "\"%.2X c #%.2X%.2X%.2X\",\n", i, pIcon->bmiColors[i].rgbRed,
|
---|
| 377 | pIcon->bmiColors[i].rgbGreen, pIcon->bmiColors[i].rgbBlue) <= 0)
|
---|
| 378 | goto error;
|
---|
| 379 | if (fprintf(fXPMFile, "\" c None\"") <= 0)
|
---|
| 380 | goto error;
|
---|
| 381 |
|
---|
| 382 | for (i = 0; i < nHeight; i++)
|
---|
| 383 | {
|
---|
| 384 | if (fprintf(fXPMFile, ",\n\"") <= 0)
|
---|
| 385 | goto error;
|
---|
| 386 | for (j = 0; j < pIcon->bmiHeader.biWidth; j++)
|
---|
| 387 | {
|
---|
| 388 | if MASK(j,i)
|
---|
| 389 | {
|
---|
| 390 | if (fprintf(fXPMFile, " ") <= 0)
|
---|
| 391 | goto error;
|
---|
| 392 | }
|
---|
| 393 | else
|
---|
| 394 | if (fprintf(fXPMFile, "%.2X", COLOR(j,i)) <= 0)
|
---|
| 395 | goto error;
|
---|
| 396 | }
|
---|
| 397 | if (fprintf(fXPMFile, "\"") <= 0)
|
---|
| 398 | goto error;
|
---|
| 399 | }
|
---|
| 400 | if (fprintf(fXPMFile, "};\n") <= 0)
|
---|
| 401 | goto error;
|
---|
| 402 |
|
---|
| 403 | #undef MASK
|
---|
| 404 | #undef COLOR
|
---|
| 405 |
|
---|
| 406 | fclose(fXPMFile);
|
---|
| 407 | return 1;
|
---|
| 408 |
|
---|
| 409 | error:
|
---|
| 410 | fclose(fXPMFile);
|
---|
| 411 | unlink( szXPMFileName );
|
---|
| 412 | return 0;
|
---|
| 413 | }
|
---|
[6481] | 414 | #endif //__WIN32OS2__
|
---|
[4561] | 415 |
|
---|
| 416 | static BOOL CALLBACK EnumResNameProc(HANDLE hModule, const char *lpszType, char *lpszName, LONG lParam)
|
---|
| 417 | {
|
---|
[8048] | 418 | ENUMRESSTRUCT *sEnumRes = (ENUMRESSTRUCT *) lParam;
|
---|
| 419 |
|
---|
| 420 | if (!sEnumRes->nIndex--)
|
---|
| 421 | {
|
---|
| 422 | *sEnumRes->pResInfo = FindResourceA(hModule, lpszName, RT_GROUP_ICONA);
|
---|
| 423 | return FALSE;
|
---|
| 424 | }
|
---|
| 425 | else
|
---|
| 426 | return TRUE;
|
---|
[4561] | 427 | }
|
---|
| 428 |
|
---|
[8048] | 429 |
|
---|
[4561] | 430 | static int ExtractFromEXEDLL(const char *szFileName, int nIndex, const char *szXPMFileName)
|
---|
| 431 | {
|
---|
| 432 | HMODULE hModule;
|
---|
| 433 | HRSRC hResInfo;
|
---|
| 434 | char *lpName = NULL;
|
---|
| 435 | HGLOBAL hResData;
|
---|
| 436 | GRPICONDIR *pIconDir;
|
---|
| 437 | BITMAPINFO *pIcon;
|
---|
[8699] | 438 | ENUMRESSTRUCT sEnumRes;
|
---|
[4561] | 439 | int nMax = 0;
|
---|
| 440 | int i;
|
---|
| 441 |
|
---|
| 442 | if (!(hModule = LoadLibraryExA(szFileName, 0, LOAD_LIBRARY_AS_DATAFILE)))
|
---|
[5618] | 443 | {
|
---|
| 444 | TRACE("LoadLibraryExA (%s) failed, error %ld\n", szFileName, GetLastError());
|
---|
[4561] | 445 | goto error1;
|
---|
[5618] | 446 | }
|
---|
[4561] | 447 |
|
---|
[8699] | 448 | if (nIndex < 0)
|
---|
[5618] | 449 | {
|
---|
[8699] | 450 | hResInfo = FindResourceA(hModule, MAKEINTRESOURCEA(-nIndex), RT_GROUP_ICONA);
|
---|
[6486] | 451 | #ifdef __WIN32OS2__
|
---|
| 452 | if(!hResInfo) {
|
---|
[6709] | 453 | hResInfo = FindResourceA(hModule, MAKEINTRESOURCEA(nIndex), RT_ICONA);
|
---|
[6486] | 454 | if(hResInfo) {
|
---|
| 455 | GRPICONDIR icondir = {0};
|
---|
[6502] | 456 | BITMAPINFO *bmi;
|
---|
[6486] | 457 |
|
---|
[6709] | 458 | bmi = (BITMAPINFO *)LockResource(LoadResource(hModule, hResInfo));
|
---|
[6502] | 459 |
|
---|
[6486] | 460 | icondir.idReserved = 0;
|
---|
| 461 | icondir.idType = 1;
|
---|
| 462 | icondir.idCount = 1;
|
---|
| 463 | icondir.idEntries[0].nID = nIndex;
|
---|
[6502] | 464 | icondir.idEntries[0].bHeight = bmi->bmiHeader.biHeight/2;
|
---|
| 465 | icondir.idEntries[0].bWidth = bmi->bmiHeader.biWidth;
|
---|
| 466 | icondir.idEntries[0].wBitCount = bmi->bmiHeader.biBitCount;
|
---|
[6486] | 467 |
|
---|
| 468 | if(!SaveIconResAsOS2ICO(&icondir, hModule, szXPMFileName))
|
---|
| 469 | {
|
---|
| 470 | TRACE("Failed saving icon as XPM, error %ld\n", GetLastError());
|
---|
| 471 | goto error3;
|
---|
| 472 | }
|
---|
| 473 | goto done;
|
---|
| 474 | }
|
---|
| 475 | }
|
---|
| 476 | #endif
|
---|
[5618] | 477 | TRACE("FindResourceA (%s) called, return 0x%x, error %ld\n", szFileName, hResInfo, GetLastError());
|
---|
| 478 | }
|
---|
[4561] | 479 | else
|
---|
[8699] | 480 | {
|
---|
| 481 | sEnumRes.pResInfo = &hResInfo;
|
---|
| 482 | sEnumRes.nIndex = nIndex;
|
---|
| 483 | if (EnumResourceNamesA(hModule, RT_GROUP_ICONA, &EnumResNameProc, (LONG) &sEnumRes))
|
---|
[5618] | 484 | {
|
---|
| 485 | TRACE("EnumResourceNamesA failed, error %ld\n", GetLastError());
|
---|
[4561] | 486 | goto error2;
|
---|
[5618] | 487 | }
|
---|
[8699] | 488 | }
|
---|
[4561] | 489 |
|
---|
| 490 | if (!hResInfo)
|
---|
[5618] | 491 | {
|
---|
| 492 | TRACE("ExtractFromEXEDLL failed, error %ld\n", GetLastError());
|
---|
[4561] | 493 | goto error2;
|
---|
[5618] | 494 | }
|
---|
[4561] | 495 |
|
---|
| 496 | if (!(hResData = LoadResource(hModule, hResInfo)))
|
---|
[5618] | 497 | {
|
---|
| 498 | TRACE("LoadResource failed, error %ld\n", GetLastError());
|
---|
[4561] | 499 | goto error2;
|
---|
[5618] | 500 | }
|
---|
[4561] | 501 | if (!(pIconDir = LockResource(hResData)))
|
---|
[5618] | 502 | {
|
---|
| 503 | TRACE("LockResource failed, error %ld\n", GetLastError());
|
---|
[4561] | 504 | goto error3;
|
---|
[5618] | 505 | }
|
---|
[4561] | 506 |
|
---|
[6481] | 507 | #ifdef __WIN32OS2__
|
---|
| 508 | if(!SaveIconResAsOS2ICO(pIconDir, hModule, szXPMFileName))
|
---|
| 509 | {
|
---|
| 510 | TRACE("Failed saving icon as XPM, error %ld\n", GetLastError());
|
---|
| 511 | goto error3;
|
---|
| 512 | }
|
---|
| 513 | #else
|
---|
[4561] | 514 | for (i = 0; i < pIconDir->idCount; i++)
|
---|
[8048] | 515 | if ((pIconDir->idEntries[i].wBitCount >= nMaxBits) && (pIconDir->idEntries[i].wBitCount <= 8))
|
---|
[4561] | 516 | {
|
---|
[8048] | 517 | if (pIconDir->idEntries[i].wBitCount > nMaxBits)
|
---|
| 518 | {
|
---|
| 519 | nMaxBits = pIconDir->idEntries[i].wBitCount;
|
---|
| 520 | nMax = 0;
|
---|
| 521 | }
|
---|
| 522 | if ((pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth) > nMax)
|
---|
| 523 | {
|
---|
| 524 | lpName = MAKEINTRESOURCEA(pIconDir->idEntries[i].nID);
|
---|
| 525 | nMax = pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth;
|
---|
| 526 | }
|
---|
[4561] | 527 | }
|
---|
| 528 |
|
---|
| 529 | FreeResource(hResData);
|
---|
| 530 |
|
---|
| 531 | if (!(hResInfo = FindResourceA(hModule, lpName, RT_ICONA)))
|
---|
[5618] | 532 | {
|
---|
| 533 | TRACE("Second FindResourceA failed, error %ld\n", GetLastError());
|
---|
[4561] | 534 | goto error2;
|
---|
[5618] | 535 | }
|
---|
[4561] | 536 | if (!(hResData = LoadResource(hModule, hResInfo)))
|
---|
[5618] | 537 | {
|
---|
| 538 | TRACE("Second LoadResource failed, error %ld\n", GetLastError());
|
---|
[4561] | 539 | goto error2;
|
---|
[5618] | 540 | }
|
---|
[4561] | 541 | if (!(pIcon = LockResource(hResData)))
|
---|
[5618] | 542 | {
|
---|
| 543 | TRACE("Second LockResource failed, error %ld\n", GetLastError());
|
---|
[4561] | 544 | goto error3;
|
---|
[5618] | 545 | }
|
---|
[4561] | 546 |
|
---|
| 547 | if(!SaveIconResAsXPM(pIcon, szXPMFileName))
|
---|
[5618] | 548 | {
|
---|
| 549 | TRACE("Failed saving icon as XPM, error %ld\n", GetLastError());
|
---|
[4561] | 550 | goto error3;
|
---|
[5618] | 551 | }
|
---|
[6481] | 552 | #endif
|
---|
[6486] | 553 |
|
---|
| 554 | done:
|
---|
[8048] | 555 |
|
---|
[4561] | 556 | FreeResource(hResData);
|
---|
| 557 | FreeLibrary(hModule);
|
---|
| 558 |
|
---|
| 559 | return 1;
|
---|
| 560 |
|
---|
| 561 | error3:
|
---|
| 562 | FreeResource(hResData);
|
---|
| 563 | error2:
|
---|
| 564 | FreeLibrary(hModule);
|
---|
| 565 | error1:
|
---|
| 566 | return 0;
|
---|
| 567 | }
|
---|
| 568 |
|
---|
| 569 | static int ExtractFromICO(const char *szFileName, const char *szXPMFileName)
|
---|
| 570 | {
|
---|
[9851] | 571 | #ifdef __WIN32OS2__
|
---|
| 572 | if(!SaveIconFileAsOS2ICO(szFileName, szXPMFileName))
|
---|
| 573 | {
|
---|
| 574 | TRACE("Failed saving icon as XPM, error %ld\n", GetLastError());
|
---|
| 575 | return 0;
|
---|
| 576 | }
|
---|
| 577 | return 1;
|
---|
| 578 | #else
|
---|
[4561] | 579 | FILE *fICOFile;
|
---|
| 580 | ICONDIR iconDir;
|
---|
| 581 | ICONDIRENTRY *pIconDirEntry;
|
---|
| 582 | int nMax = 0;
|
---|
| 583 | int nIndex = 0;
|
---|
| 584 | void *pIcon;
|
---|
| 585 | int i;
|
---|
| 586 |
|
---|
| 587 | if (!(fICOFile = fopen(szFileName, "r")))
|
---|
| 588 | goto error1;
|
---|
| 589 |
|
---|
| 590 | if (fread(&iconDir, sizeof (ICONDIR), 1, fICOFile) != 1)
|
---|
| 591 | goto error2;
|
---|
| 592 | if ((iconDir.idReserved != 0) || (iconDir.idType != 1))
|
---|
| 593 | goto error2;
|
---|
| 594 |
|
---|
| 595 | if ((pIconDirEntry = malloc(iconDir.idCount * sizeof (ICONDIRENTRY))) == NULL)
|
---|
| 596 | goto error2;
|
---|
| 597 | if (fread(pIconDirEntry, sizeof (ICONDIRENTRY), iconDir.idCount, fICOFile) != iconDir.idCount)
|
---|
| 598 | goto error3;
|
---|
| 599 |
|
---|
| 600 | for (i = 0; i < iconDir.idCount; i++)
|
---|
| 601 | if ((pIconDirEntry[i].bHeight * pIconDirEntry[i].bWidth) > nMax)
|
---|
| 602 | {
|
---|
| 603 | nIndex = i;
|
---|
| 604 | nMax = pIconDirEntry[i].bHeight * pIconDirEntry[i].bWidth;
|
---|
| 605 | }
|
---|
| 606 | if ((pIcon = malloc(pIconDirEntry[nIndex].dwBytesInRes)) == NULL)
|
---|
| 607 | goto error3;
|
---|
| 608 | if (fseek(fICOFile, pIconDirEntry[nIndex].dwImageOffset, SEEK_SET))
|
---|
| 609 | goto error4;
|
---|
| 610 | if (fread(pIcon, pIconDirEntry[nIndex].dwBytesInRes, 1, fICOFile) != 1)
|
---|
| 611 | goto error4;
|
---|
| 612 |
|
---|
| 613 | if(!SaveIconResAsXPM(pIcon, szXPMFileName))
|
---|
| 614 | goto error4;
|
---|
| 615 |
|
---|
| 616 | free(pIcon);
|
---|
| 617 | free(pIconDirEntry);
|
---|
| 618 | fclose(fICOFile);
|
---|
| 619 |
|
---|
| 620 | return 1;
|
---|
| 621 |
|
---|
| 622 | error4:
|
---|
| 623 | free(pIcon);
|
---|
| 624 | error3:
|
---|
| 625 | free(pIconDirEntry);
|
---|
| 626 | error2:
|
---|
| 627 | fclose(fICOFile);
|
---|
| 628 | error1:
|
---|
| 629 | return 0;
|
---|
[9851] | 630 | #endif
|
---|
[4561] | 631 | }
|
---|
| 632 |
|
---|
[6481] | 633 | #ifndef __WIN32OS2__
|
---|
[4561] | 634 | /* get the Unix file name for a given path, allocating the string */
|
---|
| 635 | inline static char *get_unix_file_name( const char *dos )
|
---|
| 636 | {
|
---|
[5618] | 637 | char buffer[MAX_PATH];
|
---|
[4561] | 638 |
|
---|
[5618] | 639 | if (!wine_get_unix_file_name( dos, buffer, sizeof(buffer) )) return NULL;
|
---|
[8048] | 640 | return heap_strdup( buffer );
|
---|
[4561] | 641 | }
|
---|
| 642 |
|
---|
| 643 | static BOOL create_default_icon( const char *filename )
|
---|
| 644 | {
|
---|
| 645 | FILE *fXPM;
|
---|
| 646 | int i;
|
---|
| 647 |
|
---|
| 648 | if (!(fXPM = fopen(filename, "w"))) return FALSE;
|
---|
| 649 | fprintf(fXPM, "/* XPM */\nstatic char * icon[] = {");
|
---|
| 650 | for (i = 0; i < sizeof(wine_xpm)/sizeof(wine_xpm[0]); i++)
|
---|
| 651 | fprintf( fXPM, "\n\"%s\",", wine_xpm[i]);
|
---|
| 652 | fprintf( fXPM, "};\n" );
|
---|
| 653 | fclose( fXPM );
|
---|
| 654 | return TRUE;
|
---|
| 655 | }
|
---|
[6481] | 656 | #endif //__WIN32OS2__
|
---|
[4561] | 657 |
|
---|
| 658 | /* extract an icon from an exe or icon file; helper for IPersistFile_fnSave */
|
---|
[6481] | 659 | #ifdef __WIN32OS2__
|
---|
| 660 | static char *extract_icon( const char *path, char *filename, int index)
|
---|
[4561] | 661 | {
|
---|
[6481] | 662 | if (ExtractFromEXEDLL( path, index, filename )) return filename;
|
---|
| 663 | if (ExtractFromICO( path, filename )) return filename;
|
---|
| 664 | return NULL;
|
---|
| 665 | }
|
---|
| 666 | #else
|
---|
| 667 | static char *extract_icon( const char *path, int index)
|
---|
| 668 | {
|
---|
[8048] | 669 | char *filename = heap_strdup( tmpnam(NULL) );
|
---|
[4561] | 670 | if (ExtractFromEXEDLL( path, index, filename )) return filename;
|
---|
| 671 | if (ExtractFromICO( path, filename )) return filename;
|
---|
| 672 | if (create_default_icon( filename )) return filename;
|
---|
| 673 | HeapFree( GetProcessHeap(), 0, filename );
|
---|
| 674 | return NULL;
|
---|
| 675 | }
|
---|
[6481] | 676 | #endif
|
---|
[4561] | 677 |
|
---|
[8048] | 678 |
|
---|
[4121] | 679 | static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, BOOL fRemember)
|
---|
| 680 | {
|
---|
[4561] | 681 | HRESULT ret = NOERROR;
|
---|
| 682 | int pid, status;
|
---|
| 683 | char buffer[MAX_PATH], buff2[MAX_PATH];
|
---|
| 684 | char *filename, *link_name, *p;
|
---|
| 685 | char *shell_link_app = NULL;
|
---|
| 686 | char *icon_name = NULL;
|
---|
| 687 | char *path_name = NULL;
|
---|
| 688 | char *work_dir = NULL;
|
---|
| 689 | BOOL bDesktop;
|
---|
[5618] | 690 | HKEY hkey;
|
---|
[6481] | 691 | #ifdef __WIN32OS2__
|
---|
[9851] | 692 | char *tmp, szAppName[MAX_PATH];
|
---|
[6481] | 693 | #endif
|
---|
[4561] | 694 |
|
---|
| 695 | _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
|
---|
| 696 |
|
---|
| 697 | TRACE("(%p)->(%s)\n",This,debugstr_w(pszFileName));
|
---|
| 698 |
|
---|
| 699 | if (!pszFileName || !This->sPath)
|
---|
| 700 | return ERROR_UNKNOWN;
|
---|
| 701 |
|
---|
| 702 | /* check if ShellLinker configured */
|
---|
| 703 | #ifdef __WIN32OS2__
|
---|
[6481] | 704 | dprintf(("IPersistFile_fnSave %ls", pszFileName));
|
---|
| 705 | filename = link_name = NULL;
|
---|
| 706 | bDesktop = 0;
|
---|
| 707 |
|
---|
| 708 | if (!WideCharToMultiByte( CP_ACP, 0, pszFileName, -1, buffer, sizeof(buffer), NULL, NULL))
|
---|
| 709 | return ERROR_UNKNOWN;
|
---|
| 710 | GetFullPathNameA( buffer, sizeof(buff2), buff2, NULL );
|
---|
| 711 | filename = HEAP_strdupA( GetProcessHeap(), 0, buff2 );
|
---|
| 712 |
|
---|
| 713 | if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTUP, FALSE ))
|
---|
| 714 | {
|
---|
| 715 | /* ignore startup for now */
|
---|
| 716 | if (!strncasecmp( filename, buffer, strlen(buffer) )) goto done;
|
---|
| 717 | }
|
---|
| 718 | if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_DESKTOPDIRECTORY, FALSE ))
|
---|
| 719 | {
|
---|
| 720 | if (!strncasecmp( filename, buffer, strlen(buffer) ))
|
---|
| 721 | {
|
---|
| 722 | link_name = filename + strlen(buffer);
|
---|
| 723 | bDesktop = TRUE;
|
---|
| 724 | goto found;
|
---|
| 725 | }
|
---|
| 726 | }
|
---|
| 727 | if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTMENU, FALSE ))
|
---|
| 728 | {
|
---|
| 729 | if (!strncasecmp( filename, buffer, strlen(buffer) ))
|
---|
| 730 | {
|
---|
| 731 | link_name = filename + strlen(buffer);
|
---|
| 732 | bDesktop = FALSE;
|
---|
| 733 | goto found;
|
---|
| 734 | }
|
---|
| 735 | }
|
---|
[10547] | 736 | // not sure if this is correct, but it solves the problem of applications
|
---|
| 737 | // wanting to save the lnk files in an arbitrary directory
|
---|
| 738 | link_name = strrchr(filename, '\\');
|
---|
| 739 | if(link_name)
|
---|
| 740 | {
|
---|
| 741 | bDesktop = TRUE;
|
---|
| 742 | goto found;
|
---|
| 743 | }
|
---|
| 744 |
|
---|
[6481] | 745 | goto done;
|
---|
| 746 |
|
---|
| 747 | found:
|
---|
| 748 |
|
---|
| 749 | icon_name = HEAP_strdupA( GetProcessHeap(), 0, filename );
|
---|
| 750 | strupr(icon_name);
|
---|
| 751 | tmp = strstr(icon_name, ".LNK");
|
---|
| 752 | if(!tmp) {
|
---|
| 753 | dprintf(("ERROR: Unexpected name %s", icon_name));
|
---|
| 754 | goto done;
|
---|
| 755 | }
|
---|
| 756 | tmp[1] = 'I';
|
---|
| 757 | tmp[2] = 'C';
|
---|
| 758 | tmp[3] = 'O';
|
---|
| 759 | /* extract the icon */
|
---|
[6709] | 760 | if (!extract_icon( This->sIcoPath && strlen(This->sIcoPath) ?
|
---|
[6481] | 761 | This->sIcoPath : This->sPath,
|
---|
| 762 | icon_name, This->iIcoNdx)) goto done;
|
---|
| 763 |
|
---|
[9851] | 764 | if(SearchPathA( NULL, This->sPath, ".exe", sizeof(szAppName), szAppName, NULL) == NULL)
|
---|
| 765 | {
|
---|
| 766 | ret = E_INVALIDARG;
|
---|
| 767 | goto done;
|
---|
| 768 | }
|
---|
| 769 |
|
---|
| 770 | if(OSLibWinCreateObject(szAppName, This->sArgs, This->sWorkDir, filename,
|
---|
[6481] | 771 | This->sDescription, icon_name,
|
---|
[6709] | 772 | This->iIcoNdx, bDesktop) == FALSE)
|
---|
[6481] | 773 | {
|
---|
| 774 | ret = E_ACCESSDENIED;
|
---|
| 775 | }
|
---|
[6709] | 776 |
|
---|
[6481] | 777 | done:
|
---|
| 778 | if(shell_link_app) HeapFree( GetProcessHeap(), 0, shell_link_app );
|
---|
| 779 | if(filename) HeapFree( GetProcessHeap(), 0, filename );
|
---|
| 780 | if(icon_name) HeapFree( GetProcessHeap(), 0, icon_name );
|
---|
| 781 | if(path_name) HeapFree( GetProcessHeap(), 0, path_name );
|
---|
| 782 | if(work_dir) HeapFree( GetProcessHeap(), 0, work_dir );
|
---|
| 783 | return ret;
|
---|
| 784 |
|
---|
[4561] | 785 | #else
|
---|
[9851] | 786 |
|
---|
| 787 | /* check for .exe extension */
|
---|
| 788 | if (!(p = strrchr( This->sPath, '.' ))) return NOERROR;
|
---|
| 789 | if (strchr( p, '\\' ) || strchr( p, '/' )) return NOERROR;
|
---|
| 790 | if (strcasecmp( p, ".exe" )) return NOERROR;
|
---|
| 791 |
|
---|
[5618] | 792 | buffer[0] = 0;
|
---|
| 793 | if (!RegOpenKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Wine",
|
---|
| 794 | 0, KEY_ALL_ACCESS, &hkey ))
|
---|
| 795 | {
|
---|
| 796 | DWORD type, count = sizeof(buffer);
|
---|
| 797 | if (RegQueryValueExA( hkey, "ShellLinker", 0, &type, buffer, &count )) buffer[0] = 0;
|
---|
| 798 | RegCloseKey( hkey );
|
---|
| 799 | }
|
---|
[4561] | 800 | if (!*buffer) return NOERROR;
|
---|
[8048] | 801 | shell_link_app = heap_strdup( buffer );
|
---|
[4561] | 802 |
|
---|
| 803 | if (!WideCharToMultiByte( CP_ACP, 0, pszFileName, -1, buffer, sizeof(buffer), NULL, NULL))
|
---|
| 804 | return ERROR_UNKNOWN;
|
---|
| 805 | GetFullPathNameA( buffer, sizeof(buff2), buff2, NULL );
|
---|
[8048] | 806 | filename = heap_strdup( buff2 );
|
---|
[4561] | 807 |
|
---|
| 808 | if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTUP, FALSE ))
|
---|
| 809 | {
|
---|
| 810 | /* ignore startup for now */
|
---|
| 811 | if (!strncasecmp( filename, buffer, strlen(buffer) )) goto done;
|
---|
| 812 | }
|
---|
| 813 | if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_DESKTOPDIRECTORY, FALSE ))
|
---|
| 814 | {
|
---|
| 815 | if (!strncasecmp( filename, buffer, strlen(buffer) ))
|
---|
| 816 | {
|
---|
| 817 | link_name = filename + strlen(buffer);
|
---|
| 818 | bDesktop = TRUE;
|
---|
| 819 | goto found;
|
---|
| 820 | }
|
---|
| 821 | }
|
---|
| 822 | if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTMENU, FALSE ))
|
---|
| 823 | {
|
---|
| 824 | if (!strncasecmp( filename, buffer, strlen(buffer) ))
|
---|
| 825 | {
|
---|
| 826 | link_name = filename + strlen(buffer);
|
---|
| 827 | bDesktop = FALSE;
|
---|
| 828 | goto found;
|
---|
| 829 | }
|
---|
| 830 | }
|
---|
| 831 | goto done;
|
---|
| 832 |
|
---|
| 833 | found:
|
---|
| 834 | /* make link name a Unix name */
|
---|
| 835 | for (p = link_name; *p; p++) if (*p == '\\') *p = '/';
|
---|
| 836 | /* strip leading slashes */
|
---|
| 837 | while (*link_name == '/') link_name++;
|
---|
| 838 | /* remove extension */
|
---|
| 839 | if ((p = strrchr( link_name, '.' ))) *p = 0;
|
---|
| 840 |
|
---|
| 841 | /* convert app path name */
|
---|
| 842 | path_name = get_unix_file_name( This->sPath );
|
---|
| 843 |
|
---|
| 844 | /* convert app working dir */
|
---|
| 845 | if (This->sWorkDir) work_dir = get_unix_file_name( This->sWorkDir );
|
---|
| 846 |
|
---|
| 847 | /* extract the icon */
|
---|
[6709] | 848 | if (!(icon_name = extract_icon( This->sIcoPath && strlen(This->sIcoPath) ?
|
---|
[5618] | 849 | This->sIcoPath : This->sPath,
|
---|
| 850 | This->iIcoNdx ))) goto done;
|
---|
[4561] | 851 |
|
---|
[5618] | 852 |
|
---|
[4561] | 853 | TRACE("linker app='%s' link='%s' mode=%s path='%s' args='%s' icon='%s' workdir='%s' descr='%s'\n",
|
---|
| 854 | shell_link_app, link_name, bDesktop ? "desktop" : "menu", path_name,
|
---|
| 855 | This->sArgs ? This->sArgs : "", icon_name, work_dir ? work_dir : "",
|
---|
| 856 | This->sDescription ? This->sDescription : "" );
|
---|
| 857 |
|
---|
| 858 | if ((pid = fork()) == -1) goto done;
|
---|
| 859 | if (!pid)
|
---|
| 860 | {
|
---|
| 861 | int pos = 0;
|
---|
| 862 | char *argv[20];
|
---|
| 863 | argv[pos++] = shell_link_app;
|
---|
| 864 | argv[pos++] = "--link";
|
---|
| 865 | argv[pos++] = link_name;
|
---|
| 866 | argv[pos++] = "--path";
|
---|
| 867 | argv[pos++] = path_name;
|
---|
| 868 | argv[pos++] = bDesktop ? "--desktop" : "--menu";
|
---|
[5618] | 869 | if (This->sArgs && strlen(This->sArgs))
|
---|
[4561] | 870 | {
|
---|
| 871 | argv[pos++] = "--args";
|
---|
| 872 | argv[pos++] = This->sArgs;
|
---|
| 873 | }
|
---|
| 874 | if (icon_name)
|
---|
| 875 | {
|
---|
| 876 | argv[pos++] = "--icon";
|
---|
| 877 | argv[pos++] = icon_name;
|
---|
| 878 | }
|
---|
[5618] | 879 | if (This->sWorkDir && strlen(This->sWorkDir))
|
---|
[4561] | 880 | {
|
---|
| 881 | argv[pos++] = "--workdir";
|
---|
| 882 | argv[pos++] = This->sWorkDir;
|
---|
| 883 | }
|
---|
[5618] | 884 | if (This->sDescription && strlen(This->sDescription))
|
---|
[4561] | 885 | {
|
---|
| 886 | argv[pos++] = "--descr";
|
---|
| 887 | argv[pos++] = This->sDescription;
|
---|
| 888 | }
|
---|
| 889 | argv[pos] = NULL;
|
---|
| 890 | execvp( shell_link_app, argv );
|
---|
| 891 | _exit(1);
|
---|
| 892 | }
|
---|
| 893 |
|
---|
| 894 | while (waitpid( pid, &status, 0 ) == -1)
|
---|
| 895 | {
|
---|
| 896 | if (errno != EINTR)
|
---|
| 897 | {
|
---|
| 898 | ret = ERROR_UNKNOWN;
|
---|
| 899 | goto done;
|
---|
| 900 | }
|
---|
| 901 | }
|
---|
| 902 | if (status) ret = E_ACCESSDENIED;
|
---|
| 903 |
|
---|
| 904 | done:
|
---|
| 905 | if (icon_name) unlink( icon_name );
|
---|
| 906 | HeapFree( GetProcessHeap(), 0, shell_link_app );
|
---|
| 907 | HeapFree( GetProcessHeap(), 0, filename );
|
---|
| 908 | HeapFree( GetProcessHeap(), 0, icon_name );
|
---|
| 909 | HeapFree( GetProcessHeap(), 0, path_name );
|
---|
| 910 | HeapFree( GetProcessHeap(), 0, work_dir );
|
---|
| 911 | return ret;
|
---|
[5618] | 912 | #endif
|
---|
[4121] | 913 | }
|
---|
[4561] | 914 |
|
---|
[4121] | 915 | static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile* iface, LPCOLESTR pszFileName)
|
---|
| 916 | {
|
---|
[6709] | 917 | _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
|
---|
| 918 | FIXME("(%p)->(%s)\n",This,debugstr_w(pszFileName));
|
---|
| 919 | return NOERROR;
|
---|
[4121] | 920 | }
|
---|
| 921 | static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile* iface, LPOLESTR *ppszFileName)
|
---|
| 922 | {
|
---|
[6709] | 923 | _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
|
---|
| 924 | FIXME("(%p)\n",This);
|
---|
| 925 | return NOERROR;
|
---|
[4121] | 926 | }
|
---|
| 927 |
|
---|
[6709] | 928 | static ICOM_VTABLE(IPersistFile) pfvt =
|
---|
[4121] | 929 | {
|
---|
[6709] | 930 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
| 931 | IPersistFile_fnQueryInterface,
|
---|
| 932 | IPersistFile_fnAddRef,
|
---|
| 933 | IPersistFile_fnRelease,
|
---|
| 934 | IPersistFile_fnGetClassID,
|
---|
| 935 | IPersistFile_fnIsDirty,
|
---|
| 936 | IPersistFile_fnLoad,
|
---|
| 937 | IPersistFile_fnSave,
|
---|
| 938 | IPersistFile_fnSaveCompleted,
|
---|
| 939 | IPersistFile_fnGetCurFile
|
---|
[4121] | 940 | };
|
---|
| 941 |
|
---|
| 942 | /************************************************************************
|
---|
| 943 | * IPersistStream_QueryInterface
|
---|
| 944 | */
|
---|
| 945 | static HRESULT WINAPI IPersistStream_fnQueryInterface(
|
---|
[6709] | 946 | IPersistStream* iface,
|
---|
| 947 | REFIID riid,
|
---|
| 948 | VOID** ppvoid)
|
---|
[4121] | 949 | {
|
---|
[6709] | 950 | _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
---|
[4121] | 951 |
|
---|
[6709] | 952 | TRACE("(%p)\n",This);
|
---|
[4121] | 953 |
|
---|
[6709] | 954 | return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvoid);
|
---|
[4121] | 955 | }
|
---|
| 956 |
|
---|
| 957 | /************************************************************************
|
---|
| 958 | * IPersistStream_Release
|
---|
| 959 | */
|
---|
| 960 | static ULONG WINAPI IPersistStream_fnRelease(
|
---|
[6709] | 961 | IPersistStream* iface)
|
---|
[4121] | 962 | {
|
---|
[6709] | 963 | _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
---|
[4121] | 964 |
|
---|
[6709] | 965 | TRACE("(%p)\n",This);
|
---|
[4121] | 966 |
|
---|
[6709] | 967 | return IShellLinkA_Release((IShellLinkA*)This);
|
---|
[4121] | 968 | }
|
---|
| 969 |
|
---|
| 970 | /************************************************************************
|
---|
| 971 | * IPersistStream_AddRef
|
---|
| 972 | */
|
---|
| 973 | static ULONG WINAPI IPersistStream_fnAddRef(
|
---|
[6709] | 974 | IPersistStream* iface)
|
---|
[4121] | 975 | {
|
---|
[6709] | 976 | _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
---|
[4121] | 977 |
|
---|
[6709] | 978 | TRACE("(%p)\n",This);
|
---|
[4121] | 979 |
|
---|
[6709] | 980 | return IShellLinkA_AddRef((IShellLinkA*)This);
|
---|
| 981 | }
|
---|
[4121] | 982 |
|
---|
| 983 | /************************************************************************
|
---|
| 984 | * IPersistStream_GetClassID
|
---|
| 985 | *
|
---|
| 986 | */
|
---|
| 987 | static HRESULT WINAPI IPersistStream_fnGetClassID(
|
---|
[6709] | 988 | IPersistStream* iface,
|
---|
| 989 | CLSID* pClassID)
|
---|
[4121] | 990 | {
|
---|
[6709] | 991 | _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
---|
[4121] | 992 |
|
---|
[6709] | 993 | TRACE("(%p)\n", This);
|
---|
[4121] | 994 |
|
---|
[6709] | 995 | if (pClassID==0)
|
---|
| 996 | return E_POINTER;
|
---|
[4121] | 997 |
|
---|
[6709] | 998 | /* memcpy(pClassID, &CLSID_???, sizeof(CLSID_???)); */
|
---|
[4121] | 999 |
|
---|
[6709] | 1000 | return S_OK;
|
---|
[4121] | 1001 | }
|
---|
| 1002 |
|
---|
| 1003 | /************************************************************************
|
---|
| 1004 | * IPersistStream_IsDirty (IPersistStream)
|
---|
| 1005 | */
|
---|
| 1006 | static HRESULT WINAPI IPersistStream_fnIsDirty(
|
---|
[6709] | 1007 | IPersistStream* iface)
|
---|
[4121] | 1008 | {
|
---|
[6709] | 1009 | _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
---|
[4121] | 1010 |
|
---|
[6709] | 1011 | TRACE("(%p)\n", This);
|
---|
[4121] | 1012 |
|
---|
[6709] | 1013 | return S_OK;
|
---|
[4121] | 1014 | }
|
---|
| 1015 | /************************************************************************
|
---|
| 1016 | * IPersistStream_Load (IPersistStream)
|
---|
| 1017 | */
|
---|
| 1018 |
|
---|
| 1019 | static HRESULT WINAPI IPersistStream_fnLoad(
|
---|
[6709] | 1020 | IPersistStream* iface,
|
---|
| 1021 | IStream* pLoadStream)
|
---|
[4121] | 1022 | {
|
---|
[6709] | 1023 | PLINK_HEADER lpLinkHeader = HeapAlloc(GetProcessHeap(), 0, LINK_HEADER_SIZE);
|
---|
| 1024 | ULONG dwBytesRead;
|
---|
| 1025 | DWORD ret = E_FAIL;
|
---|
| 1026 | char sTemp[MAX_PATH];
|
---|
| 1027 |
|
---|
| 1028 | _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
---|
[4121] | 1029 |
|
---|
[6709] | 1030 | TRACE("(%p)(%p)\n", This, pLoadStream);
|
---|
[4121] | 1031 |
|
---|
[6709] | 1032 | if ( ! pLoadStream)
|
---|
| 1033 | {
|
---|
| 1034 | return STG_E_INVALIDPOINTER;
|
---|
| 1035 | }
|
---|
| 1036 |
|
---|
| 1037 | IStream_AddRef (pLoadStream);
|
---|
| 1038 | if(lpLinkHeader)
|
---|
| 1039 | {
|
---|
| 1040 | if (SUCCEEDED(IStream_Read(pLoadStream, lpLinkHeader, LINK_HEADER_SIZE, &dwBytesRead)))
|
---|
| 1041 | {
|
---|
| 1042 | if ((lpLinkHeader->MagicStr == 0x0000004CL) && IsEqualIID(&lpLinkHeader->MagicGuid, &CLSID_ShellLink))
|
---|
| 1043 | {
|
---|
| 1044 | lpLinkHeader = HeapReAlloc(GetProcessHeap(), 0, lpLinkHeader, LINK_HEADER_SIZE+lpLinkHeader->PidlSize);
|
---|
| 1045 | if (lpLinkHeader)
|
---|
| 1046 | {
|
---|
| 1047 | if (SUCCEEDED(IStream_Read(pLoadStream, &(lpLinkHeader->Pidl), lpLinkHeader->PidlSize, &dwBytesRead)))
|
---|
| 1048 | {
|
---|
| 1049 | if (pcheck (&lpLinkHeader->Pidl))
|
---|
| 1050 | {
|
---|
| 1051 | This->pPidl = ILClone (&lpLinkHeader->Pidl);
|
---|
[4121] | 1052 |
|
---|
[6709] | 1053 | SHGetPathFromIDListA(&lpLinkHeader->Pidl, sTemp);
|
---|
[8048] | 1054 | This->sPath = heap_strdup( sTemp );
|
---|
[6709] | 1055 | }
|
---|
| 1056 | This->wHotKey = lpLinkHeader->wHotKey;
|
---|
| 1057 | FileTimeToSystemTime (&lpLinkHeader->Time1, &This->time1);
|
---|
| 1058 | FileTimeToSystemTime (&lpLinkHeader->Time2, &This->time2);
|
---|
| 1059 | FileTimeToSystemTime (&lpLinkHeader->Time3, &This->time3);
|
---|
[4121] | 1060 | #if 1
|
---|
[6709] | 1061 | GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time1, NULL, sTemp, 256);
|
---|
| 1062 | TRACE("-- time1: %s\n", sTemp);
|
---|
| 1063 | GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time2, NULL, sTemp, 256);
|
---|
| 1064 | TRACE("-- time1: %s\n", sTemp);
|
---|
| 1065 | GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time3, NULL, sTemp, 256);
|
---|
| 1066 | TRACE("-- time1: %s\n", sTemp);
|
---|
| 1067 | pdump (This->pPidl);
|
---|
| 1068 | #endif
|
---|
| 1069 | ret = S_OK;
|
---|
| 1070 | }
|
---|
| 1071 | }
|
---|
| 1072 | }
|
---|
| 1073 | else
|
---|
| 1074 | {
|
---|
| 1075 | WARN("stream contains no link!\n");
|
---|
| 1076 | }
|
---|
| 1077 | }
|
---|
| 1078 | }
|
---|
[4121] | 1079 |
|
---|
[6709] | 1080 | IStream_Release (pLoadStream);
|
---|
[4121] | 1081 |
|
---|
[6709] | 1082 | pdump(This->pPidl);
|
---|
| 1083 |
|
---|
| 1084 | HeapFree(GetProcessHeap(), 0, lpLinkHeader);
|
---|
[4121] | 1085 |
|
---|
[6709] | 1086 | return ret;
|
---|
[4121] | 1087 | }
|
---|
| 1088 |
|
---|
| 1089 | /************************************************************************
|
---|
| 1090 | * IPersistStream_Save (IPersistStream)
|
---|
| 1091 | */
|
---|
| 1092 | static HRESULT WINAPI IPersistStream_fnSave(
|
---|
[6709] | 1093 | IPersistStream* iface,
|
---|
| 1094 | IStream* pOutStream,
|
---|
| 1095 | BOOL fClearDirty)
|
---|
[4121] | 1096 | {
|
---|
[6709] | 1097 | _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
---|
| 1098 |
|
---|
| 1099 | TRACE("(%p) %p %x\n", This, pOutStream, fClearDirty);
|
---|
[4121] | 1100 |
|
---|
[6709] | 1101 | return E_NOTIMPL;
|
---|
[4121] | 1102 | }
|
---|
| 1103 |
|
---|
| 1104 | /************************************************************************
|
---|
| 1105 | * IPersistStream_GetSizeMax (IPersistStream)
|
---|
| 1106 | */
|
---|
| 1107 | static HRESULT WINAPI IPersistStream_fnGetSizeMax(
|
---|
[6709] | 1108 | IPersistStream* iface,
|
---|
| 1109 | ULARGE_INTEGER* pcbSize)
|
---|
[4121] | 1110 | {
|
---|
[6709] | 1111 | _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
|
---|
| 1112 |
|
---|
| 1113 | TRACE("(%p)\n", This);
|
---|
[4121] | 1114 |
|
---|
[6709] | 1115 | return E_NOTIMPL;
|
---|
[4121] | 1116 | }
|
---|
| 1117 |
|
---|
| 1118 | static ICOM_VTABLE(IPersistStream) psvt =
|
---|
| 1119 | {
|
---|
[6709] | 1120 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
| 1121 | IPersistStream_fnQueryInterface,
|
---|
| 1122 | IPersistStream_fnAddRef,
|
---|
| 1123 | IPersistStream_fnRelease,
|
---|
| 1124 | IPersistStream_fnGetClassID,
|
---|
| 1125 | IPersistStream_fnIsDirty,
|
---|
| 1126 | IPersistStream_fnLoad,
|
---|
| 1127 | IPersistStream_fnSave,
|
---|
| 1128 | IPersistStream_fnGetSizeMax
|
---|
[4121] | 1129 | };
|
---|
| 1130 |
|
---|
| 1131 | /**************************************************************************
|
---|
[6709] | 1132 | * IShellLink_Constructor
|
---|
[4121] | 1133 | */
|
---|
[6709] | 1134 | IShellLinkA * IShellLink_Constructor(BOOL bUnicode)
|
---|
| 1135 | { IShellLinkImpl * sl;
|
---|
[4121] | 1136 |
|
---|
[6709] | 1137 | sl = (IShellLinkImpl *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellLinkImpl));
|
---|
| 1138 | sl->ref = 1;
|
---|
| 1139 | ICOM_VTBL(sl) = &slvt;
|
---|
| 1140 | sl->lpvtblw = &slvtw;
|
---|
| 1141 | sl->lpvtblPersistFile = &pfvt;
|
---|
| 1142 | sl->lpvtblPersistStream = &psvt;
|
---|
| 1143 |
|
---|
| 1144 | TRACE("(%p)->()\n",sl);
|
---|
| 1145 | shell32_ObjCount++;
|
---|
| 1146 | return bUnicode ? (IShellLinkA *) &(sl->lpvtblw) : (IShellLinkA *)sl;
|
---|
[4121] | 1147 | }
|
---|
| 1148 |
|
---|
| 1149 | /**************************************************************************
|
---|
| 1150 | * IShellLinkA_QueryInterface
|
---|
| 1151 | */
|
---|
| 1152 | static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID riid, LPVOID *ppvObj)
|
---|
| 1153 | {
|
---|
[6709] | 1154 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1155 |
|
---|
| 1156 | TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
|
---|
[4121] | 1157 |
|
---|
[6709] | 1158 | *ppvObj = NULL;
|
---|
[4121] | 1159 |
|
---|
[6709] | 1160 | if(IsEqualIID(riid, &IID_IUnknown) ||
|
---|
| 1161 | IsEqualIID(riid, &IID_IShellLinkA))
|
---|
| 1162 | {
|
---|
| 1163 | *ppvObj = This;
|
---|
| 1164 | }
|
---|
| 1165 | else if(IsEqualIID(riid, &IID_IShellLinkW))
|
---|
| 1166 | {
|
---|
| 1167 | *ppvObj = (IShellLinkW *)&(This->lpvtblw);
|
---|
| 1168 | }
|
---|
| 1169 | else if(IsEqualIID(riid, &IID_IPersistFile))
|
---|
| 1170 | {
|
---|
| 1171 | *ppvObj = (IPersistFile *)&(This->lpvtblPersistFile);
|
---|
| 1172 | }
|
---|
| 1173 | else if(IsEqualIID(riid, &IID_IPersistStream))
|
---|
| 1174 | {
|
---|
| 1175 | *ppvObj = (IPersistStream *)&(This->lpvtblPersistStream);
|
---|
| 1176 | }
|
---|
[4121] | 1177 |
|
---|
[6709] | 1178 | if(*ppvObj)
|
---|
| 1179 | {
|
---|
| 1180 | IUnknown_AddRef((IUnknown*)(*ppvObj));
|
---|
| 1181 | TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
|
---|
| 1182 | return S_OK;
|
---|
| 1183 | }
|
---|
| 1184 | TRACE("-- Interface: E_NOINTERFACE\n");
|
---|
| 1185 | return E_NOINTERFACE;
|
---|
| 1186 | }
|
---|
[4121] | 1187 | /******************************************************************************
|
---|
| 1188 | * IShellLinkA_AddRef
|
---|
| 1189 | */
|
---|
| 1190 | static ULONG WINAPI IShellLinkA_fnAddRef(IShellLinkA * iface)
|
---|
| 1191 | {
|
---|
[6709] | 1192 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1193 |
|
---|
| 1194 | TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
---|
[4121] | 1195 |
|
---|
[6709] | 1196 | shell32_ObjCount++;
|
---|
| 1197 | return ++(This->ref);
|
---|
[4121] | 1198 | }
|
---|
| 1199 | /******************************************************************************
|
---|
[6709] | 1200 | * IShellLinkA_Release
|
---|
[4121] | 1201 | */
|
---|
| 1202 | static ULONG WINAPI IShellLinkA_fnRelease(IShellLinkA * iface)
|
---|
| 1203 | {
|
---|
[6709] | 1204 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1205 |
|
---|
| 1206 | TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
---|
[4121] | 1207 |
|
---|
[6709] | 1208 | shell32_ObjCount--;
|
---|
| 1209 | if (!--(This->ref))
|
---|
| 1210 | { TRACE("-- destroying IShellLink(%p)\n",This);
|
---|
| 1211 |
|
---|
| 1212 | if (This->sIcoPath)
|
---|
| 1213 | HeapFree(GetProcessHeap(), 0, This->sIcoPath);
|
---|
| 1214 |
|
---|
| 1215 | if (This->sArgs)
|
---|
| 1216 | HeapFree(GetProcessHeap(), 0, This->sArgs);
|
---|
[4121] | 1217 |
|
---|
[6709] | 1218 | if (This->sWorkDir)
|
---|
| 1219 | HeapFree(GetProcessHeap(), 0, This->sWorkDir);
|
---|
| 1220 |
|
---|
| 1221 | if (This->sDescription)
|
---|
| 1222 | HeapFree(GetProcessHeap(), 0, This->sDescription);
|
---|
[4561] | 1223 |
|
---|
[6709] | 1224 | if (This->sPath)
|
---|
| 1225 | HeapFree(GetProcessHeap(),0,This->sPath);
|
---|
[4121] | 1226 |
|
---|
[6709] | 1227 | if (This->pPidl)
|
---|
| 1228 | SHFree(This->pPidl);
|
---|
[4121] | 1229 |
|
---|
[6709] | 1230 | if (This->lpFileStream)
|
---|
| 1231 | IStream_Release(This->lpFileStream);
|
---|
| 1232 |
|
---|
| 1233 | This->iIcoNdx = 0;
|
---|
[4121] | 1234 |
|
---|
[6709] | 1235 | HeapFree(GetProcessHeap(),0,This);
|
---|
| 1236 | return 0;
|
---|
| 1237 | }
|
---|
| 1238 | return This->ref;
|
---|
[4121] | 1239 | }
|
---|
| 1240 |
|
---|
| 1241 | static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA * iface, LPSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
|
---|
| 1242 | {
|
---|
[6709] | 1243 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1244 |
|
---|
| 1245 | TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)(%s)\n",This, pszFile, cchMaxPath, pfd, fFlags, debugstr_a(This->sPath));
|
---|
[4121] | 1246 |
|
---|
[6709] | 1247 | if (This->sPath)
|
---|
| 1248 | lstrcpynA(pszFile,This->sPath, cchMaxPath);
|
---|
| 1249 | else
|
---|
| 1250 | return E_FAIL;
|
---|
[4121] | 1251 |
|
---|
[6709] | 1252 | return NOERROR;
|
---|
[4121] | 1253 | }
|
---|
| 1254 | static HRESULT WINAPI IShellLinkA_fnGetIDList(IShellLinkA * iface, LPITEMIDLIST * ppidl)
|
---|
| 1255 | {
|
---|
[6709] | 1256 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1257 |
|
---|
| 1258 | TRACE("(%p)->(ppidl=%p)\n",This, ppidl);
|
---|
[4121] | 1259 |
|
---|
[6709] | 1260 | *ppidl = ILClone(This->pPidl);
|
---|
| 1261 | return NOERROR;
|
---|
[4121] | 1262 | }
|
---|
| 1263 | static HRESULT WINAPI IShellLinkA_fnSetIDList(IShellLinkA * iface, LPCITEMIDLIST pidl)
|
---|
| 1264 | {
|
---|
[6709] | 1265 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1266 |
|
---|
| 1267 | TRACE("(%p)->(pidl=%p)\n",This, pidl);
|
---|
[4121] | 1268 |
|
---|
[6709] | 1269 | if (This->pPidl)
|
---|
| 1270 | SHFree(This->pPidl);
|
---|
| 1271 | This->pPidl = ILClone (pidl);
|
---|
| 1272 | return NOERROR;
|
---|
[4121] | 1273 | }
|
---|
| 1274 | static HRESULT WINAPI IShellLinkA_fnGetDescription(IShellLinkA * iface, LPSTR pszName,INT cchMaxName)
|
---|
| 1275 | {
|
---|
[6709] | 1276 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1277 |
|
---|
| 1278 | FIXME("(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
|
---|
| 1279 | lstrcpynA(pszName,"Description, FIXME",cchMaxName);
|
---|
| 1280 | return NOERROR;
|
---|
[4121] | 1281 | }
|
---|
| 1282 | static HRESULT WINAPI IShellLinkA_fnSetDescription(IShellLinkA * iface, LPCSTR pszName)
|
---|
| 1283 | {
|
---|
[6709] | 1284 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1285 |
|
---|
| 1286 | TRACE("(%p)->(pName=%s)\n", This, pszName);
|
---|
[4561] | 1287 |
|
---|
[6709] | 1288 | if (This->sDescription)
|
---|
| 1289 | HeapFree(GetProcessHeap(), 0, This->sDescription);
|
---|
[8048] | 1290 | if (!(This->sDescription = heap_strdup(pszName)))
|
---|
[6709] | 1291 | return E_OUTOFMEMORY;
|
---|
[4561] | 1292 |
|
---|
[6709] | 1293 | return NOERROR;
|
---|
[4121] | 1294 | }
|
---|
| 1295 | static HRESULT WINAPI IShellLinkA_fnGetWorkingDirectory(IShellLinkA * iface, LPSTR pszDir,INT cchMaxPath)
|
---|
| 1296 | {
|
---|
[6709] | 1297 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1298 |
|
---|
| 1299 | TRACE("(%p)->(%p len=%u)\n", This, pszDir, cchMaxPath);
|
---|
[5618] | 1300 |
|
---|
[6709] | 1301 | lstrcpynA( pszDir, This->sWorkDir ? This->sWorkDir : "", cchMaxPath );
|
---|
[5618] | 1302 |
|
---|
[6709] | 1303 | return NOERROR;
|
---|
[4121] | 1304 | }
|
---|
| 1305 | static HRESULT WINAPI IShellLinkA_fnSetWorkingDirectory(IShellLinkA * iface, LPCSTR pszDir)
|
---|
| 1306 | {
|
---|
[6709] | 1307 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1308 |
|
---|
| 1309 | TRACE("(%p)->(dir=%s)\n",This, pszDir);
|
---|
[4561] | 1310 |
|
---|
[6709] | 1311 | if (This->sWorkDir)
|
---|
| 1312 | HeapFree(GetProcessHeap(), 0, This->sWorkDir);
|
---|
[8048] | 1313 | if (!(This->sWorkDir = heap_strdup(pszDir)))
|
---|
[6709] | 1314 | return E_OUTOFMEMORY;
|
---|
[4561] | 1315 |
|
---|
[6709] | 1316 | return NOERROR;
|
---|
[4121] | 1317 | }
|
---|
| 1318 | static HRESULT WINAPI IShellLinkA_fnGetArguments(IShellLinkA * iface, LPSTR pszArgs,INT cchMaxPath)
|
---|
| 1319 | {
|
---|
[6709] | 1320 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1321 |
|
---|
| 1322 | TRACE("(%p)->(%p len=%u)\n", This, pszArgs, cchMaxPath);
|
---|
[5618] | 1323 |
|
---|
[6709] | 1324 | lstrcpynA( pszArgs, This->sArgs ? This->sArgs : "", cchMaxPath );
|
---|
[5618] | 1325 |
|
---|
[6709] | 1326 | return NOERROR;
|
---|
[4121] | 1327 | }
|
---|
| 1328 | static HRESULT WINAPI IShellLinkA_fnSetArguments(IShellLinkA * iface, LPCSTR pszArgs)
|
---|
| 1329 | {
|
---|
[6709] | 1330 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1331 |
|
---|
| 1332 | TRACE("(%p)->(args=%s)\n",This, pszArgs);
|
---|
[4121] | 1333 |
|
---|
[6709] | 1334 | if (This->sArgs)
|
---|
| 1335 | HeapFree(GetProcessHeap(), 0, This->sArgs);
|
---|
[8048] | 1336 | if (!(This->sArgs = heap_strdup(pszArgs)))
|
---|
[6709] | 1337 | return E_OUTOFMEMORY;
|
---|
[4561] | 1338 |
|
---|
[6709] | 1339 | return NOERROR;
|
---|
[4121] | 1340 | }
|
---|
| 1341 | static HRESULT WINAPI IShellLinkA_fnGetHotkey(IShellLinkA * iface, WORD *pwHotkey)
|
---|
| 1342 | {
|
---|
[6709] | 1343 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1344 |
|
---|
| 1345 | TRACE("(%p)->(%p)(0x%08x)\n",This, pwHotkey, This->wHotKey);
|
---|
[4121] | 1346 |
|
---|
[6709] | 1347 | *pwHotkey = This->wHotKey;
|
---|
[4121] | 1348 |
|
---|
[6709] | 1349 | return NOERROR;
|
---|
[4121] | 1350 | }
|
---|
| 1351 | static HRESULT WINAPI IShellLinkA_fnSetHotkey(IShellLinkA * iface, WORD wHotkey)
|
---|
| 1352 | {
|
---|
[6709] | 1353 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1354 |
|
---|
| 1355 | TRACE("(%p)->(hotkey=%x)\n",This, wHotkey);
|
---|
| 1356 |
|
---|
| 1357 | This->wHotKey = wHotkey;
|
---|
[4121] | 1358 |
|
---|
[6709] | 1359 | return NOERROR;
|
---|
[4121] | 1360 | }
|
---|
| 1361 | static HRESULT WINAPI IShellLinkA_fnGetShowCmd(IShellLinkA * iface, INT *piShowCmd)
|
---|
| 1362 | {
|
---|
[6709] | 1363 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1364 |
|
---|
| 1365 | FIXME("(%p)->(%p)\n",This, piShowCmd);
|
---|
| 1366 | *piShowCmd=0;
|
---|
| 1367 | return NOERROR;
|
---|
[4121] | 1368 | }
|
---|
| 1369 | static HRESULT WINAPI IShellLinkA_fnSetShowCmd(IShellLinkA * iface, INT iShowCmd)
|
---|
| 1370 | {
|
---|
[6709] | 1371 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1372 |
|
---|
| 1373 | FIXME("(%p)->(showcmd=%x)\n",This, iShowCmd);
|
---|
| 1374 | return NOERROR;
|
---|
[4121] | 1375 | }
|
---|
| 1376 | static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR pszIconPath,INT cchIconPath,INT *piIcon)
|
---|
| 1377 | {
|
---|
[6709] | 1378 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1379 |
|
---|
| 1380 | TRACE("(%p)->(%p len=%u iicon=%p)\n", This, pszIconPath, cchIconPath, piIcon);
|
---|
[5618] | 1381 |
|
---|
[6709] | 1382 | lstrcpynA( pszIconPath, This->sIcoPath ? This->sIcoPath : "", cchIconPath );
|
---|
| 1383 | *piIcon = This->iIcoNdx;
|
---|
[5618] | 1384 |
|
---|
[6709] | 1385 | return NOERROR;
|
---|
[4121] | 1386 | }
|
---|
| 1387 | static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA * iface, LPCSTR pszIconPath,INT iIcon)
|
---|
| 1388 | {
|
---|
[6709] | 1389 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1390 |
|
---|
| 1391 | TRACE("(%p)->(path=%s iicon=%u)\n",This, pszIconPath, iIcon);
|
---|
| 1392 |
|
---|
| 1393 | if (This->sIcoPath)
|
---|
| 1394 | HeapFree(GetProcessHeap(), 0, This->sIcoPath);
|
---|
[8048] | 1395 | if (!(This->sIcoPath = heap_strdup(pszIconPath)))
|
---|
[6709] | 1396 | return E_OUTOFMEMORY;
|
---|
| 1397 | This->iIcoNdx = iIcon;
|
---|
| 1398 |
|
---|
| 1399 | return NOERROR;
|
---|
[4121] | 1400 | }
|
---|
| 1401 | static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA * iface, LPCSTR pszPathRel, DWORD dwReserved)
|
---|
| 1402 | {
|
---|
[6709] | 1403 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1404 |
|
---|
| 1405 | FIXME("(%p)->(path=%s %lx)\n",This, pszPathRel, dwReserved);
|
---|
| 1406 | return NOERROR;
|
---|
[4121] | 1407 | }
|
---|
| 1408 | static HRESULT WINAPI IShellLinkA_fnResolve(IShellLinkA * iface, HWND hwnd, DWORD fFlags)
|
---|
| 1409 | {
|
---|
[6709] | 1410 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1411 |
|
---|
| 1412 | FIXME("(%p)->(hwnd=%x flags=%lx)\n",This, hwnd, fFlags);
|
---|
| 1413 | return NOERROR;
|
---|
[4121] | 1414 | }
|
---|
| 1415 | static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA * iface, LPCSTR pszFile)
|
---|
| 1416 | {
|
---|
[6709] | 1417 | ICOM_THIS(IShellLinkImpl, iface);
|
---|
| 1418 |
|
---|
| 1419 | TRACE("(%p)->(path=%s)\n",This, pszFile);
|
---|
[4561] | 1420 |
|
---|
[6709] | 1421 | if (This->sPath)
|
---|
| 1422 | HeapFree(GetProcessHeap(), 0, This->sPath);
|
---|
[8048] | 1423 | if (!(This->sPath = heap_strdup(pszFile)))
|
---|
[6709] | 1424 | return E_OUTOFMEMORY;
|
---|
| 1425 |
|
---|
| 1426 | return NOERROR;
|
---|
[4121] | 1427 | }
|
---|
| 1428 |
|
---|
| 1429 | /**************************************************************************
|
---|
| 1430 | * IShellLink Implementation
|
---|
| 1431 | */
|
---|
| 1432 |
|
---|
[6709] | 1433 | static ICOM_VTABLE(IShellLinkA) slvt =
|
---|
| 1434 | {
|
---|
| 1435 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
| 1436 | IShellLinkA_fnQueryInterface,
|
---|
| 1437 | IShellLinkA_fnAddRef,
|
---|
| 1438 | IShellLinkA_fnRelease,
|
---|
| 1439 | IShellLinkA_fnGetPath,
|
---|
| 1440 | IShellLinkA_fnGetIDList,
|
---|
| 1441 | IShellLinkA_fnSetIDList,
|
---|
| 1442 | IShellLinkA_fnGetDescription,
|
---|
| 1443 | IShellLinkA_fnSetDescription,
|
---|
| 1444 | IShellLinkA_fnGetWorkingDirectory,
|
---|
| 1445 | IShellLinkA_fnSetWorkingDirectory,
|
---|
| 1446 | IShellLinkA_fnGetArguments,
|
---|
| 1447 | IShellLinkA_fnSetArguments,
|
---|
| 1448 | IShellLinkA_fnGetHotkey,
|
---|
| 1449 | IShellLinkA_fnSetHotkey,
|
---|
| 1450 | IShellLinkA_fnGetShowCmd,
|
---|
| 1451 | IShellLinkA_fnSetShowCmd,
|
---|
| 1452 | IShellLinkA_fnGetIconLocation,
|
---|
| 1453 | IShellLinkA_fnSetIconLocation,
|
---|
| 1454 | IShellLinkA_fnSetRelativePath,
|
---|
| 1455 | IShellLinkA_fnResolve,
|
---|
| 1456 | IShellLinkA_fnSetPath
|
---|
[4121] | 1457 | };
|
---|
| 1458 |
|
---|
| 1459 |
|
---|
| 1460 | /**************************************************************************
|
---|
| 1461 | * IShellLinkW_fnQueryInterface
|
---|
| 1462 | */
|
---|
| 1463 | static HRESULT WINAPI IShellLinkW_fnQueryInterface(
|
---|
| 1464 | IShellLinkW * iface, REFIID riid, LPVOID *ppvObj)
|
---|
| 1465 | {
|
---|
[6709] | 1466 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1467 |
|
---|
| 1468 | return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObj);
|
---|
[4121] | 1469 | }
|
---|
| 1470 |
|
---|
| 1471 | /******************************************************************************
|
---|
| 1472 | * IShellLinkW_fnAddRef
|
---|
| 1473 | */
|
---|
| 1474 | static ULONG WINAPI IShellLinkW_fnAddRef(IShellLinkW * iface)
|
---|
| 1475 | {
|
---|
[6709] | 1476 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1477 |
|
---|
| 1478 | TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
---|
[4121] | 1479 |
|
---|
[6709] | 1480 | return IShellLinkA_AddRef((IShellLinkA*)This);
|
---|
[4121] | 1481 | }
|
---|
| 1482 | /******************************************************************************
|
---|
| 1483 | * IShellLinkW_fnRelease
|
---|
| 1484 | */
|
---|
| 1485 |
|
---|
| 1486 | static ULONG WINAPI IShellLinkW_fnRelease(IShellLinkW * iface)
|
---|
| 1487 | {
|
---|
[6709] | 1488 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1489 |
|
---|
| 1490 | TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
---|
[4121] | 1491 |
|
---|
[6709] | 1492 | return IShellLinkA_Release((IShellLinkA*)This);
|
---|
[4121] | 1493 | }
|
---|
| 1494 |
|
---|
| 1495 | static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
|
---|
| 1496 | {
|
---|
[6709] | 1497 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1498 |
|
---|
| 1499 | FIXME("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This, pszFile, cchMaxPath, pfd, fFlags);
|
---|
[5618] | 1500 | MultiByteToWideChar( CP_ACP, 0, "c:\\foo.bar", -1, pszFile, cchMaxPath );
|
---|
[6709] | 1501 | return NOERROR;
|
---|
[4121] | 1502 | }
|
---|
| 1503 |
|
---|
| 1504 | static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST * ppidl)
|
---|
| 1505 | {
|
---|
[6709] | 1506 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1507 |
|
---|
| 1508 | FIXME("(%p)->(ppidl=%p)\n",This, ppidl);
|
---|
| 1509 | *ppidl = _ILCreateDesktop();
|
---|
| 1510 | return NOERROR;
|
---|
[4121] | 1511 | }
|
---|
| 1512 |
|
---|
| 1513 | static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST pidl)
|
---|
| 1514 | {
|
---|
[6709] | 1515 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1516 |
|
---|
| 1517 | FIXME("(%p)->(pidl=%p)\n",This, pidl);
|
---|
| 1518 | return NOERROR;
|
---|
[4121] | 1519 | }
|
---|
| 1520 |
|
---|
| 1521 | static HRESULT WINAPI IShellLinkW_fnGetDescription(IShellLinkW * iface, LPWSTR pszName,INT cchMaxName)
|
---|
| 1522 | {
|
---|
[6709] | 1523 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1524 |
|
---|
| 1525 | FIXME("(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
|
---|
[5618] | 1526 | MultiByteToWideChar( CP_ACP, 0, "Description, FIXME", -1, pszName, cchMaxName );
|
---|
[6709] | 1527 | return NOERROR;
|
---|
[4121] | 1528 | }
|
---|
| 1529 |
|
---|
| 1530 | static HRESULT WINAPI IShellLinkW_fnSetDescription(IShellLinkW * iface, LPCWSTR pszName)
|
---|
| 1531 | {
|
---|
[6709] | 1532 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1533 |
|
---|
| 1534 | TRACE("(%p)->(desc=%s)\n",This, debugstr_w(pszName));
|
---|
[4561] | 1535 |
|
---|
[6709] | 1536 | if (This->sDescription)
|
---|
| 1537 | HeapFree(GetProcessHeap(), 0, This->sDescription);
|
---|
| 1538 | if (!(This->sDescription = HEAP_strdupWtoA(GetProcessHeap(), 0, pszName)))
|
---|
| 1539 | return E_OUTOFMEMORY;
|
---|
| 1540 |
|
---|
| 1541 | return NOERROR;
|
---|
[4121] | 1542 | }
|
---|
| 1543 |
|
---|
| 1544 | static HRESULT WINAPI IShellLinkW_fnGetWorkingDirectory(IShellLinkW * iface, LPWSTR pszDir,INT cchMaxPath)
|
---|
| 1545 | {
|
---|
[6709] | 1546 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1547 |
|
---|
| 1548 | TRACE("(%p)->(%p len %u)\n", This, pszDir, cchMaxPath);
|
---|
[5618] | 1549 |
|
---|
[6709] | 1550 | MultiByteToWideChar( CP_ACP, 0, This->sWorkDir ? This->sWorkDir : "", -1, pszDir, cchMaxPath );
|
---|
[5618] | 1551 |
|
---|
[6709] | 1552 | return NOERROR;
|
---|
[4121] | 1553 | }
|
---|
| 1554 |
|
---|
| 1555 | static HRESULT WINAPI IShellLinkW_fnSetWorkingDirectory(IShellLinkW * iface, LPCWSTR pszDir)
|
---|
| 1556 | {
|
---|
[6709] | 1557 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1558 |
|
---|
| 1559 | TRACE("(%p)->(dir=%s)\n",This, debugstr_w(pszDir));
|
---|
[4561] | 1560 |
|
---|
[6709] | 1561 | if (This->sWorkDir)
|
---|
| 1562 | HeapFree(GetProcessHeap(), 0, This->sWorkDir);
|
---|
| 1563 | if (!(This->sWorkDir = HEAP_strdupWtoA(GetProcessHeap(), 0, pszDir)))
|
---|
| 1564 | return E_OUTOFMEMORY;
|
---|
[4561] | 1565 |
|
---|
[6709] | 1566 | return NOERROR;
|
---|
[4121] | 1567 | }
|
---|
| 1568 |
|
---|
| 1569 | static HRESULT WINAPI IShellLinkW_fnGetArguments(IShellLinkW * iface, LPWSTR pszArgs,INT cchMaxPath)
|
---|
| 1570 | {
|
---|
[6709] | 1571 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1572 |
|
---|
| 1573 | TRACE("(%p)->(%p len=%u)\n", This, pszArgs, cchMaxPath);
|
---|
[5618] | 1574 |
|
---|
[6709] | 1575 | MultiByteToWideChar( CP_ACP, 0, This->sArgs ? This->sArgs : "", -1, pszArgs, cchMaxPath );
|
---|
[5618] | 1576 |
|
---|
[6709] | 1577 | return NOERROR;
|
---|
[4121] | 1578 | }
|
---|
| 1579 |
|
---|
| 1580 | static HRESULT WINAPI IShellLinkW_fnSetArguments(IShellLinkW * iface, LPCWSTR pszArgs)
|
---|
| 1581 | {
|
---|
[6709] | 1582 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1583 |
|
---|
| 1584 | TRACE("(%p)->(args=%s)\n",This, debugstr_w(pszArgs));
|
---|
| 1585 |
|
---|
| 1586 | if (This->sArgs)
|
---|
| 1587 | HeapFree(GetProcessHeap(), 0, This->sArgs);
|
---|
| 1588 | if (!(This->sArgs = HEAP_strdupWtoA(GetProcessHeap(), 0, pszArgs)))
|
---|
| 1589 | return E_OUTOFMEMORY;
|
---|
| 1590 |
|
---|
| 1591 | return NOERROR;
|
---|
[4121] | 1592 | }
|
---|
| 1593 |
|
---|
| 1594 | static HRESULT WINAPI IShellLinkW_fnGetHotkey(IShellLinkW * iface, WORD *pwHotkey)
|
---|
| 1595 | {
|
---|
[6709] | 1596 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1597 |
|
---|
| 1598 | FIXME("(%p)->(%p)\n",This, pwHotkey);
|
---|
| 1599 | *pwHotkey=0x0;
|
---|
| 1600 | return NOERROR;
|
---|
[4121] | 1601 | }
|
---|
| 1602 |
|
---|
| 1603 | static HRESULT WINAPI IShellLinkW_fnSetHotkey(IShellLinkW * iface, WORD wHotkey)
|
---|
| 1604 | {
|
---|
[6709] | 1605 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1606 |
|
---|
| 1607 | FIXME("(%p)->(hotkey=%x)\n",This, wHotkey);
|
---|
| 1608 | return NOERROR;
|
---|
[4121] | 1609 | }
|
---|
| 1610 |
|
---|
| 1611 | static HRESULT WINAPI IShellLinkW_fnGetShowCmd(IShellLinkW * iface, INT *piShowCmd)
|
---|
| 1612 | {
|
---|
[6709] | 1613 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1614 |
|
---|
| 1615 | FIXME("(%p)->(%p)\n",This, piShowCmd);
|
---|
| 1616 | *piShowCmd=0;
|
---|
| 1617 | return NOERROR;
|
---|
[4121] | 1618 | }
|
---|
| 1619 |
|
---|
| 1620 | static HRESULT WINAPI IShellLinkW_fnSetShowCmd(IShellLinkW * iface, INT iShowCmd)
|
---|
| 1621 | {
|
---|
[6709] | 1622 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1623 |
|
---|
| 1624 | FIXME("(%p)->(showcmd=%x)\n",This, iShowCmd);
|
---|
| 1625 | return NOERROR;
|
---|
[4121] | 1626 | }
|
---|
| 1627 |
|
---|
| 1628 | static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR pszIconPath,INT cchIconPath,INT *piIcon)
|
---|
| 1629 | {
|
---|
[6709] | 1630 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1631 |
|
---|
| 1632 | TRACE("(%p)->(%p len=%u iicon=%p)\n", This, pszIconPath, cchIconPath, piIcon);
|
---|
[5618] | 1633 |
|
---|
| 1634 | MultiByteToWideChar( CP_ACP, 0, This->sIcoPath ? This->sIcoPath : "", -1, pszIconPath, cchIconPath );
|
---|
[6709] | 1635 | *piIcon = This->iIcoNdx;
|
---|
[5618] | 1636 |
|
---|
[6709] | 1637 | return NOERROR;
|
---|
[4121] | 1638 | }
|
---|
| 1639 |
|
---|
| 1640 | static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath,INT iIcon)
|
---|
| 1641 | {
|
---|
[6709] | 1642 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1643 |
|
---|
| 1644 | TRACE("(%p)->(path=%s iicon=%u)\n",This, debugstr_w(pszIconPath), iIcon);
|
---|
[4561] | 1645 |
|
---|
[6709] | 1646 | if (This->sIcoPath)
|
---|
| 1647 | HeapFree(GetProcessHeap(), 0, This->sIcoPath);
|
---|
| 1648 | if (!(This->sIcoPath = HEAP_strdupWtoA(GetProcessHeap(), 0, pszIconPath)))
|
---|
| 1649 | return E_OUTOFMEMORY;
|
---|
| 1650 | This->iIcoNdx = iIcon;
|
---|
[4561] | 1651 |
|
---|
[6709] | 1652 | return NOERROR;
|
---|
[4121] | 1653 | }
|
---|
| 1654 |
|
---|
| 1655 | static HRESULT WINAPI IShellLinkW_fnSetRelativePath(IShellLinkW * iface, LPCWSTR pszPathRel, DWORD dwReserved)
|
---|
| 1656 | {
|
---|
[6709] | 1657 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1658 |
|
---|
| 1659 | FIXME("(%p)->(path=%s %lx)\n",This, debugstr_w(pszPathRel), dwReserved);
|
---|
| 1660 | return NOERROR;
|
---|
[4121] | 1661 | }
|
---|
| 1662 |
|
---|
| 1663 | static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWORD fFlags)
|
---|
| 1664 | {
|
---|
[6709] | 1665 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1666 |
|
---|
| 1667 | FIXME("(%p)->(hwnd=%x flags=%lx)\n",This, hwnd, fFlags);
|
---|
| 1668 | return NOERROR;
|
---|
[4121] | 1669 | }
|
---|
| 1670 |
|
---|
| 1671 | static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile)
|
---|
| 1672 | {
|
---|
[6709] | 1673 | _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
|
---|
| 1674 |
|
---|
| 1675 | TRACE("(%p)->(path=%s)\n",This, debugstr_w(pszFile));
|
---|
| 1676 |
|
---|
| 1677 | if (This->sPath)
|
---|
| 1678 | HeapFree(GetProcessHeap(), 0, This->sPath);
|
---|
| 1679 | if (!(This->sPath = HEAP_strdupWtoA(GetProcessHeap(), 0, pszFile)))
|
---|
| 1680 | return E_OUTOFMEMORY;
|
---|
| 1681 |
|
---|
| 1682 | return NOERROR;
|
---|
[4121] | 1683 | }
|
---|
| 1684 |
|
---|
| 1685 | /**************************************************************************
|
---|
| 1686 | * IShellLinkW Implementation
|
---|
| 1687 | */
|
---|
| 1688 |
|
---|
[6709] | 1689 | static ICOM_VTABLE(IShellLinkW) slvtw =
|
---|
| 1690 | {
|
---|
| 1691 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
| 1692 | IShellLinkW_fnQueryInterface,
|
---|
| 1693 | IShellLinkW_fnAddRef,
|
---|
| 1694 | IShellLinkW_fnRelease,
|
---|
| 1695 | IShellLinkW_fnGetPath,
|
---|
| 1696 | IShellLinkW_fnGetIDList,
|
---|
| 1697 | IShellLinkW_fnSetIDList,
|
---|
| 1698 | IShellLinkW_fnGetDescription,
|
---|
| 1699 | IShellLinkW_fnSetDescription,
|
---|
| 1700 | IShellLinkW_fnGetWorkingDirectory,
|
---|
| 1701 | IShellLinkW_fnSetWorkingDirectory,
|
---|
| 1702 | IShellLinkW_fnGetArguments,
|
---|
| 1703 | IShellLinkW_fnSetArguments,
|
---|
| 1704 | IShellLinkW_fnGetHotkey,
|
---|
| 1705 | IShellLinkW_fnSetHotkey,
|
---|
| 1706 | IShellLinkW_fnGetShowCmd,
|
---|
| 1707 | IShellLinkW_fnSetShowCmd,
|
---|
| 1708 | IShellLinkW_fnGetIconLocation,
|
---|
| 1709 | IShellLinkW_fnSetIconLocation,
|
---|
| 1710 | IShellLinkW_fnSetRelativePath,
|
---|
| 1711 | IShellLinkW_fnResolve,
|
---|
| 1712 | IShellLinkW_fnSetPath
|
---|
[4121] | 1713 | };
|
---|
| 1714 |
|
---|