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