ReactOS 0.4.17-dev-1071-gb2116d0
intshcut.c
Go to the documentation of this file.
1/*
2 * Copyright 2008 Damjan Jovanovic
3 *
4 * ShellLink's barely documented cousin that handles URLs.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21/*
22 * TODO:
23 * Implement the IShellLinkA/W interfaces
24 * Handle the SetURL flags
25 * Implement any other interfaces? Does any software actually use them?
26 *
27 * The installer for the Zuma Deluxe Popcap game is good for testing.
28 */
29
30#include <stdio.h>
31
32#include "ieframe.h"
33
34#include "shlobj.h"
35#include "shobjidl.h"
36#include "intshcut.h"
37#include "shellapi.h"
38#include "winreg.h"
39#include "shlwapi.h"
40#include "shlguid.h"
41
42#include "wine/debug.h"
43
45
46typedef struct
47{
48 IUniformResourceLocatorA IUniformResourceLocatorA_iface;
49 IUniformResourceLocatorW IUniformResourceLocatorW_iface;
52
54
58 LPOLESTR currentFile;
60
61/* utility functions */
62
63static inline InternetShortcut* impl_from_IUniformResourceLocatorA(IUniformResourceLocatorA *iface)
64{
65 return CONTAINING_RECORD(iface, InternetShortcut, IUniformResourceLocatorA_iface);
66}
67
68static inline InternetShortcut* impl_from_IUniformResourceLocatorW(IUniformResourceLocatorW *iface)
69{
70 return CONTAINING_RECORD(iface, InternetShortcut, IUniformResourceLocatorW_iface);
71}
72
74{
75 return CONTAINING_RECORD(iface, InternetShortcut, IPersistFile_iface);
76}
77
79{
80 return CONTAINING_RECORD(iface, InternetShortcut, IPropertySetStorage_iface);
81}
82
84{
85 static const WCHAR menubuilder[] = {'\\','w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e',0};
86 LONG len;
90 BOOL ret;
91 WCHAR app[MAX_PATH];
92 void *redir;
93
94 GetSystemDirectoryW( app, MAX_PATH - ARRAY_SIZE( menubuilder ));
95 lstrcatW( app, menubuilder );
96
97 len = (lstrlenW( app ) + lstrlenW( args ) + 1) * sizeof(WCHAR);
98 buffer = malloc( len );
99 if( !buffer )
100 return FALSE;
101
102 lstrcpyW( buffer, app );
103 lstrcatW( buffer, args );
104
105 TRACE("starting %s\n",debugstr_w(buffer));
106
107 memset(&si, 0, sizeof(si));
108 si.cb = sizeof(si);
109
113
114 free( buffer );
115
116 if (ret)
117 {
120 }
121
122 return ret;
123}
124
125static BOOL StartLinkProcessor( LPCOLESTR szLink )
126{
127 static const WCHAR szFormat[] = { ' ','-','w',' ','-','u',' ','"','%','s','"',0 };
128 LONG len;
130 BOOL ret;
131
132 len = sizeof(szFormat) + lstrlenW( szLink ) * sizeof(WCHAR);
133 buffer = malloc( len );
134 if( !buffer )
135 return FALSE;
136
137 swprintf( buffer, len / sizeof(WCHAR), szFormat, szLink );
139 free( buffer );
140 return ret;
141}
142
143/* interface functions */
144
146{
147 TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObject);
148 *ppvObject = NULL;
150 *ppvObject = &This->IUniformResourceLocatorA_iface;
151 else if (IsEqualGUID(&IID_IUniformResourceLocatorA, riid))
152 *ppvObject = &This->IUniformResourceLocatorA_iface;
153 else if (IsEqualGUID(&IID_IUniformResourceLocatorW, riid))
154 *ppvObject = &This->IUniformResourceLocatorW_iface;
156 *ppvObject = &This->IPersistFile_iface;
157 else if (IsEqualGUID(&IID_IPropertySetStorage, riid))
158 *ppvObject = &This->IPropertySetStorage_iface;
159 else if (IsEqualGUID(&IID_IShellLinkA, riid))
160 {
161 FIXME("The IShellLinkA interface is not yet supported by InternetShortcut\n");
162 return E_NOINTERFACE;
163 }
164 else if (IsEqualGUID(&IID_IShellLinkW, riid))
165 {
166 FIXME("The IShellLinkW interface is not yet supported by InternetShortcut\n");
167 return E_NOINTERFACE;
168 }
169 else
170 {
171 FIXME("Interface with GUID %s not yet implemented by InternetShortcut\n", debugstr_guid(riid));
172 return E_NOINTERFACE;
173 }
174 IUnknown_AddRef((IUnknown*)*ppvObject);
175 return S_OK;
176}
177
179{
180 TRACE("(%p)\n", This);
181 return InterlockedIncrement(&This->refCount);
182}
183
185{
186 ULONG count;
187 TRACE("(%p)\n", This);
188 count = InterlockedDecrement(&This->refCount);
189 if (count == 0)
190 {
191 CoTaskMemFree(This->url);
192 CoTaskMemFree(This->currentFile);
193 IPropertySetStorage_Release(This->property_set_storage);
194 free(This);
196 }
197 return count;
198}
199
200static HRESULT WINAPI UniformResourceLocatorW_QueryInterface(IUniformResourceLocatorW *url, REFIID riid, PVOID *ppvObject)
201{
203 TRACE("(%p, %s, %p)\n", url, debugstr_guid(riid), ppvObject);
204 return Unknown_QueryInterface(This, riid, ppvObject);
205}
206
207static ULONG WINAPI UniformResourceLocatorW_AddRef(IUniformResourceLocatorW *url)
208{
210 TRACE("(%p)\n", url);
211 return Unknown_AddRef(This);
212}
213
214static ULONG WINAPI UniformResourceLocatorW_Release(IUniformResourceLocatorW *url)
215{
217 TRACE("(%p)\n", url);
218 return Unknown_Release(This);
219}
220
221static HRESULT WINAPI UniformResourceLocatorW_SetUrl(IUniformResourceLocatorW *url, LPCWSTR pcszURL, DWORD dwInFlags)
222{
223 WCHAR *newURL = NULL;
225 TRACE("(%p, %s, 0x%lx)\n", url, debugstr_w(pcszURL), dwInFlags);
226 if (dwInFlags != 0)
227 FIXME("ignoring unsupported flags 0x%lx\n", dwInFlags);
228 if (pcszURL != NULL)
229 {
230 newURL = co_strdupW(pcszURL);
231 if (newURL == NULL)
232 return E_OUTOFMEMORY;
233 }
234 CoTaskMemFree(This->url);
235 This->url = newURL;
236 This->isDirty = TRUE;
237 return S_OK;
238}
239
240static HRESULT WINAPI UniformResourceLocatorW_GetUrl(IUniformResourceLocatorW *url, LPWSTR *ppszURL)
241{
243
244 TRACE("(%p, %p)\n", url, ppszURL);
245
246 if (!This->url) {
247 *ppszURL = NULL;
248 return S_FALSE;
249 }
250
251 *ppszURL = co_strdupW(This->url);
252 if (!*ppszURL)
253 return E_OUTOFMEMORY;
254
255 return S_OK;
256}
257
259{
261 WCHAR app[64];
262 HKEY hkey;
263 static const WCHAR wszURLProtocol[] = {'U','R','L',' ','P','r','o','t','o','c','o','l',0};
265 DWORD res, type;
267
268 TRACE("%p %p\n", This, pCommandInfo );
269
270 if (pCommandInfo->dwcbSize < sizeof (URLINVOKECOMMANDINFOW))
271 return E_INVALIDARG;
272
274 {
275 FIXME("(%p, %p): non-default verbs not implemented\n", url, pCommandInfo);
276 return E_NOTIMPL;
277 }
278
279 hres = CoInternetParseUrl(This->url, PARSE_SCHEMA, 0, app, ARRAY_SIZE(app), NULL, 0);
280 if(FAILED(hres))
281 return E_FAIL;
282
283 res = RegOpenKeyW(HKEY_CLASSES_ROOT, app, &hkey);
284 if(res != ERROR_SUCCESS)
285 return E_FAIL;
286
287 res = RegQueryValueExW(hkey, wszURLProtocol, NULL, &type, NULL, NULL);
288 RegCloseKey(hkey);
289 if(res != ERROR_SUCCESS || type != REG_SZ)
290 return E_FAIL;
291
292 memset(&sei, 0, sizeof(sei));
293 sei.cbSize = sizeof(sei);
294 sei.lpFile = This->url;
295 sei.nShow = SW_SHOW;
296
297 if( ShellExecuteExW(&sei) )
298 return S_OK;
299 else
300 return E_FAIL;
301}
302
303static HRESULT WINAPI UniformResourceLocatorA_QueryInterface(IUniformResourceLocatorA *url, REFIID riid, PVOID *ppvObject)
304{
306 TRACE("(%p, %s, %p)\n", url, debugstr_guid(riid), ppvObject);
307 return Unknown_QueryInterface(This, riid, ppvObject);
308}
309
310static ULONG WINAPI UniformResourceLocatorA_AddRef(IUniformResourceLocatorA *url)
311{
313 TRACE("(%p)\n", url);
314 return Unknown_AddRef(This);
315}
316
317static ULONG WINAPI UniformResourceLocatorA_Release(IUniformResourceLocatorA *url)
318{
320 TRACE("(%p)\n", url);
321 return Unknown_Release(This);
322}
323
324static HRESULT WINAPI UniformResourceLocatorA_SetUrl(IUniformResourceLocatorA *url, LPCSTR pcszURL, DWORD dwInFlags)
325{
326 WCHAR *newURL = NULL;
328 TRACE("(%p, %s, 0x%lx)\n", url, debugstr_a(pcszURL), dwInFlags);
329 if (dwInFlags != 0)
330 FIXME("ignoring unsupported flags 0x%lx\n", dwInFlags);
331 if (pcszURL != NULL)
332 {
333 newURL = co_strdupAtoW(pcszURL);
334 if (newURL == NULL)
335 return E_OUTOFMEMORY;
336 }
337 CoTaskMemFree(This->url);
338 This->url = newURL;
339 This->isDirty = TRUE;
340 return S_OK;
341}
342
343static HRESULT WINAPI UniformResourceLocatorA_GetUrl(IUniformResourceLocatorA *url, LPSTR *ppszURL)
344{
346
347 TRACE("(%p, %p)\n", url, ppszURL);
348
349 if (!This->url) {
350 *ppszURL = NULL;
351 return S_FALSE;
352
353 }
354
355 *ppszURL = co_strdupWtoA(This->url);
356 if (!*ppszURL)
357 return E_OUTOFMEMORY;
358
359 return S_OK;
360}
361
363{
364 URLINVOKECOMMANDINFOW wideCommandInfo;
365 int len;
366 WCHAR *wideVerb;
367 HRESULT res;
369
370 wideCommandInfo.dwcbSize = sizeof wideCommandInfo;
371 wideCommandInfo.dwFlags = pCommandInfo->dwFlags;
372 wideCommandInfo.hwndParent = pCommandInfo->hwndParent;
373
374 len = MultiByteToWideChar(CP_ACP, 0, pCommandInfo->pcszVerb, -1, NULL, 0);
375 wideVerb = malloc(len * sizeof(WCHAR));
376 MultiByteToWideChar(CP_ACP, 0, pCommandInfo->pcszVerb, -1, wideVerb, len);
377
378 wideCommandInfo.pcszVerb = wideVerb;
379
380 res = UniformResourceLocatorW_InvokeCommand(&This->IUniformResourceLocatorW_iface, &wideCommandInfo);
381 free(wideVerb);
382
383 return res;
384}
385
387{
389 TRACE("(%p, %s, %p)\n", pFile, debugstr_guid(riid), ppvObject);
390 return Unknown_QueryInterface(This, riid, ppvObject);
391}
392
394{
396 TRACE("(%p)\n", pFile);
397 return Unknown_AddRef(This);
398}
399
401{
403 TRACE("(%p)\n", pFile);
404 return Unknown_Release(This);
405}
406
408{
409 TRACE("(%p, %p)\n", pFile, pClassID);
410 *pClassID = CLSID_InternetShortcut;
411 return S_OK;
412}
413
415{
417 TRACE("(%p)\n", pFile);
418 return This->isDirty ? S_OK : S_FALSE;
419}
420
421/* Returns allocated profile string and a standard return code. */
422static HRESULT get_profile_string(LPCWSTR lpAppName, LPCWSTR lpKeyName,
423 LPCWSTR lpFileName, WCHAR **rString )
424{
425 DWORD r = 0;
426 DWORD len = 128;
427 WCHAR *buffer;
428
429 *rString = NULL;
430 buffer = CoTaskMemAlloc(len * sizeof(*buffer));
431 if (!buffer)
432 return E_OUTOFMEMORY;
433
434 r = GetPrivateProfileStringW(lpAppName, lpKeyName, NULL, buffer, len, lpFileName);
435 while (r == len-1)
436 {
437 WCHAR *realloc_buf;
438
439 len *= 2;
440 realloc_buf = CoTaskMemRealloc(buffer, len * sizeof(*buffer));
441 if (realloc_buf == NULL)
442 {
444 return E_OUTOFMEMORY;
445 }
446 buffer = realloc_buf;
447
448 r = GetPrivateProfileStringW(lpAppName, lpKeyName, NULL, buffer, len, lpFileName);
449 }
450
451 *rString = buffer;
452 return r ? S_OK : E_FAIL;
453}
454
456{
457 static const WCHAR str_header[] = {'I','n','t','e','r','n','e','t','S','h','o','r','t','c','u','t',0};
458 static const WCHAR str_URL[] = {'U','R','L',0};
459 static const WCHAR str_iconfile[] = {'i','c','o','n','f','i','l','e',0};
460 static const WCHAR str_iconindex[] = {'i','c','o','n','i','n','d','e','x',0};
463 WCHAR *url;
464 HRESULT hr;
465 IPropertyStorage *pPropStg;
466 WCHAR *iconfile;
467 WCHAR *iconindexstring;
468
469 TRACE("(%p, %s, 0x%lx)\n", pFile, debugstr_w(pszFileName), dwMode);
470
471 if (dwMode != 0)
472 FIXME("ignoring unimplemented mode 0x%lx\n", dwMode);
473
475 if (!filename)
476 return E_OUTOFMEMORY;
477
478 if (FAILED(hr = get_profile_string(str_header, str_URL, pszFileName, &url)))
479 {
481 return hr;
482 }
483
484 hr = IPropertySetStorage_Open(This->property_set_storage, &FMTID_Intshcut,
486 if (FAILED(hr))
487 {
490 return hr;
491 }
492
493 CoTaskMemFree(This->currentFile);
494 This->currentFile = filename;
495 CoTaskMemFree(This->url);
496 This->url = url;
497 This->isDirty = FALSE;
498
499 /* Now we're going to read in the iconfile and iconindex.
500 If we don't find them, that's not a failure case -- it's possible
501 that they just aren't in there. */
502
503 if (get_profile_string(str_header, str_iconfile, pszFileName, &iconfile) == S_OK)
504 {
505 PROPSPEC ps;
506 PROPVARIANT pv;
507 ps.ulKind = PRSPEC_PROPID;
508 ps.propid = PID_IS_ICONFILE;
509 pv.vt = VT_LPWSTR;
510 pv.pwszVal = iconfile;
511 hr = IPropertyStorage_WriteMultiple(pPropStg, 1, &ps, &pv, 0);
512 if (FAILED(hr))
513 TRACE("Failed to store the iconfile to our property storage. hr = 0x%lx\n", hr);
514 }
515 CoTaskMemFree(iconfile);
516
517 if (get_profile_string(str_header, str_iconindex, pszFileName, &iconindexstring) == S_OK)
518 {
519 int iconindex;
520 PROPSPEC ps;
521 PROPVARIANT pv;
522 iconindex = wcstol(iconindexstring, NULL, 10);
523 ps.ulKind = PRSPEC_PROPID;
524 ps.propid = PID_IS_ICONINDEX;
525 pv.vt = VT_I4;
526 pv.iVal = iconindex;
527 hr = IPropertyStorage_WriteMultiple(pPropStg, 1, &ps, &pv, 0);
528 if (FAILED(hr))
529 TRACE("Failed to store the iconindex to our property storage. hr = 0x%lx\n", hr);
530 }
531 CoTaskMemFree(iconindexstring);
532
533 IPropertyStorage_Release(pPropStg);
534 return hr;
535}
536
538{
539 HRESULT hr = S_OK;
540 INT len;
541 CHAR *url;
543
544 TRACE("(%p, %s, %d)\n", pFile, debugstr_w(pszFileName), fRemember);
545
546 if (pszFileName != NULL && fRemember)
547 {
548 LPOLESTR oldFile = This->currentFile;
549 This->currentFile = co_strdupW(pszFileName);
550 if (This->currentFile == NULL)
551 {
552 This->currentFile = oldFile;
553 return E_OUTOFMEMORY;
554 }
555 CoTaskMemFree(oldFile);
556 }
557 if (This->url == NULL)
558 return E_FAIL;
559
560 /* Windows seems to always write:
561 * ASCII "[InternetShortcut]" headers
562 * ASCII names in "name=value" pairs
563 * An ASCII (probably UTF8?) value in "URL=..."
564 */
565 len = WideCharToMultiByte(CP_UTF8, 0, This->url, -1, NULL, 0, 0, 0);
566 url = malloc(len);
567 if (url != NULL)
568 {
569 HANDLE file;
570 WideCharToMultiByte(CP_UTF8, 0, This->url, -1, url, len, 0, 0);
573 {
574 static const char str_header[] = "[InternetShortcut]";
575 static const char str_URL[] = "URL=";
576 static const char str_ICONFILE[] = "ICONFILE=";
577 static const char str_eol[] = "\r\n";
579 char *iconfile;
580 IPropertyStorage *pPropStgRead;
581 PROPSPEC ps[2];
582 PROPVARIANT pvread[2];
583 ps[0].ulKind = PRSPEC_PROPID;
584 ps[0].propid = PID_IS_ICONFILE;
585 ps[1].ulKind = PRSPEC_PROPID;
586 ps[1].propid = PID_IS_ICONINDEX;
587
588 WriteFile(file, str_header, ARRAY_SIZE(str_header) - 1, &bytesWritten, NULL);
589 WriteFile(file, str_eol, ARRAY_SIZE(str_eol) - 1, &bytesWritten, NULL);
590 WriteFile(file, str_URL, ARRAY_SIZE(str_URL) - 1, &bytesWritten, NULL);
592 WriteFile(file, str_eol, ARRAY_SIZE(str_eol) - 1, &bytesWritten, NULL);
593
594 hr = IPropertySetStorage_Open(This->property_set_storage, &FMTID_Intshcut, STGM_READ|STGM_SHARE_EXCLUSIVE, &pPropStgRead);
595 if (SUCCEEDED(hr))
596 {
597 hr = IPropertyStorage_ReadMultiple(pPropStgRead, 2, ps, pvread);
598 if (hr == S_FALSE)
599 {
600 /* None of the properties are present, that's ok */
601 hr = S_OK;
602 IPropertyStorage_Release(pPropStgRead);
603 }
604 else if (SUCCEEDED(hr))
605 {
606 char indexString[50];
607 len = WideCharToMultiByte(CP_UTF8, 0, pvread[0].pwszVal, -1, NULL, 0, 0, 0);
608 iconfile = malloc(len);
609 if (iconfile != NULL)
610 {
611 WideCharToMultiByte(CP_UTF8, 0, pvread[0].pwszVal, -1, iconfile, len, 0, 0);
612 WriteFile(file, str_ICONFILE, lstrlenA(str_ICONFILE), &bytesWritten, NULL);
613 WriteFile(file, iconfile, lstrlenA(iconfile), &bytesWritten, NULL);
614 WriteFile(file, str_eol, lstrlenA(str_eol), &bytesWritten, NULL);
615 free(iconfile);
616 }
617
618 sprintf(indexString, "ICONINDEX=%d", pvread[1].iVal);
619 WriteFile(file, indexString, lstrlenA(indexString), &bytesWritten, NULL);
620 WriteFile(file, str_eol, lstrlenA(str_eol), &bytesWritten, NULL);
621
622 IPropertyStorage_Release(pPropStgRead);
623 PropVariantClear(&pvread[0]);
624 PropVariantClear(&pvread[1]);
625 }
626 else
627 {
628 TRACE("Unable to read properties.\n");
629 }
630 }
631 else
632 {
633 TRACE("Unable to get the IPropertyStorage.\n");
634 }
635
637 if (pszFileName == NULL || fRemember)
638 This->isDirty = FALSE;
640 }
641 else
642 hr = E_FAIL;
643 free(url);
644 }
645 else
647
648 return hr;
649}
650
652{
653 FIXME("(%p, %p): stub\n", pFile, pszFileName);
654 return E_NOTIMPL;
655}
656
658{
659 HRESULT hr = S_OK;
661 TRACE("(%p, %p)\n", pFile, ppszFileName);
662 if (This->currentFile == NULL)
663 *ppszFileName = NULL;
664 else
665 {
666 *ppszFileName = co_strdupW(This->currentFile);
667 if (*ppszFileName == NULL)
669 }
670 return hr;
671}
672
674{
676 TRACE("(%p)\n", iface);
677 return Unknown_QueryInterface(This, riid, ppvObject);
678}
679
681{
683 TRACE("(%p)\n", iface);
684 return Unknown_AddRef(This);
685}
686
688{
690 TRACE("(%p)\n", iface);
691 return Unknown_Release(This);
692}
693
695 IPropertySetStorage* iface,
696 REFFMTID rfmtid,
697 const CLSID *pclsid,
698 DWORD grfFlags,
699 DWORD grfMode,
700 IPropertyStorage **ppprstg)
701{
703 TRACE("(%s, %p, 0x%lx, 0x%lx, %p)\n", debugstr_guid(rfmtid), pclsid, grfFlags, grfMode, ppprstg);
704
705 return IPropertySetStorage_Create(This->property_set_storage,
706 rfmtid,
707 pclsid,
708 grfFlags,
709 grfMode,
710 ppprstg);
711}
712
714 IPropertySetStorage* iface,
715 REFFMTID rfmtid,
716 DWORD grfMode,
717 IPropertyStorage **ppprstg)
718{
719 const DWORD STGM_ACCESS_MASK = 0x0000000f;
721 TRACE("(%s, 0x%lx, %p)\n", debugstr_guid(rfmtid), grfMode, ppprstg);
722
723 /* ole32 doesn't like STGM_WRITE */
724 if ((grfMode & STGM_ACCESS_MASK) == STGM_WRITE)
725 grfMode = (grfMode & ~STGM_ACCESS_MASK) | STGM_READWRITE;
726
727 /* Note: The |STGM_SHARE_EXCLUSIVE is to cope with a bug in the implementation. Should be fixed in ole32. */
728 return IPropertySetStorage_Open(This->property_set_storage,
729 rfmtid,
730 grfMode|STGM_SHARE_EXCLUSIVE,
731 ppprstg);
732}
733
735{
737 TRACE("(%s)\n", debugstr_guid(rfmtid));
738
739
740 return IPropertySetStorage_Delete(This->property_set_storage,
741 rfmtid);
742}
743
744static HRESULT WINAPI PropertySetStorage_Enum(IPropertySetStorage *iface, IEnumSTATPROPSETSTG **ppenum)
745{
746 FIXME("(%p): stub\n", ppenum);
747 return E_NOTIMPL;
748}
749
750static const IUniformResourceLocatorWVtbl uniformResourceLocatorWVtbl = {
757};
758
759static const IUniformResourceLocatorAVtbl uniformResourceLocatorAVtbl = {
766};
767
768static const IPersistFileVtbl persistFileVtbl = {
778};
779
780static const IPropertySetStorageVtbl propertySetStorageVtbl = {
788};
789
791{
792 InternetShortcut *newshortcut;
793
794 newshortcut = calloc(1, sizeof(InternetShortcut));
795 if (newshortcut)
796 {
797 HRESULT hr;
799
802 newshortcut->IPersistFile_iface.lpVtbl = &persistFileVtbl;
804 newshortcut->refCount = 1;
806 STGFMT_STORAGE, 0, NULL, NULL, &IID_IPropertySetStorage, (void **) &newshortcut->property_set_storage);
807 if (FAILED(hr))
808 {
809 TRACE("Failed to create the storage object needed for the shortcut.\n");
810 free(newshortcut);
811 return NULL;
812 }
813
814 hr = IPropertySetStorage_Create(newshortcut->property_set_storage, &FMTID_Intshcut, NULL, PROPSETFLAG_DEFAULT, STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &dummy);
815 if (FAILED(hr))
816 {
817 TRACE("Failed to create the property object needed for the shortcut.\n");
818 IPropertySetStorage_Release(newshortcut->property_set_storage);
819 free(newshortcut);
820 return NULL;
821 }
822 IPropertyStorage_Release(dummy);
823 }
824
825 return newshortcut;
826}
827
829{
832
833 TRACE("(%p, %s, %p)\n", outer, debugstr_guid(riid), ppv);
834
835 *ppv = NULL;
836
837 if(outer)
839
841 if(!This)
842 return E_OUTOFMEMORY;
843
846 return hres;
847}
848
849
850/**********************************************************************
851 * OpenURL (ieframe.@)
852 */
853void WINAPI OpenURL(HWND hWnd, HINSTANCE hInst, LPCSTR lpcstrUrl, int nShowCmd)
854{
855 InternetShortcut *shortcut;
856 WCHAR* urlfilepath = NULL;
857 int len;
858
859 shortcut = create_shortcut();
860
861 if(!shortcut)
862 return;
863
864 len = MultiByteToWideChar(CP_ACP, 0, lpcstrUrl, -1, NULL, 0);
865 urlfilepath = malloc(len * sizeof(WCHAR));
866 MultiByteToWideChar(CP_ACP, 0, lpcstrUrl, -1, urlfilepath, len);
867
868 if(SUCCEEDED(IPersistFile_Load(&shortcut->IPersistFile_iface, urlfilepath, 0))) {
870
871 memset( &ici, 0, sizeof ici );
872 ici.dwcbSize = sizeof ici;
874 ici.hwndParent = hWnd;
875
877 TRACE("failed to open URL: %s\n", debugstr_a(lpcstrUrl));
878 }
879
880 free(urlfilepath);
881 Unknown_Release(shortcut);
882}
unsigned char BOOLEAN
Definition: actypes.h:127
#define REG_SZ
Definition: layer.c:22
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
const GUID IID_IUnknown
#define RegCloseKey(hKey)
Definition: registry.h:49
IPersistFile IPersistFile_iface
Definition: intshcut.c:50
IUniformResourceLocatorA IUniformResourceLocatorA_iface
Definition: intshcut.c:48
IUniformResourceLocatorW IUniformResourceLocatorW_iface
Definition: intshcut.c:49
BOOLEAN isDirty
Definition: intshcut.c:57
IPropertySetStorage IPropertySetStorage_iface
Definition: intshcut.c:51
IPropertySetStorage * property_set_storage
Definition: intshcut.c:55
WCHAR * url
Definition: intshcut.c:56
LPOLESTR currentFile
Definition: intshcut.c:58
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
HRESULT hr
Definition: delayimp.cpp:582
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
Definition: combase.c:709
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
void *WINAPI CoTaskMemRealloc(void *ptr, SIZE_T size)
Definition: malloc.c:397
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
#define CloseHandle
Definition: compat.h:739
#define CP_ACP
Definition: compat.h:109
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define lstrcpyW
Definition: compat.h:749
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define FILE_SHARE_READ
Definition: compat.h:136
@ VT_LPWSTR
Definition: compat.h:2325
@ VT_I4
Definition: compat.h:2298
#define lstrlenW
Definition: compat.h:750
static HRESULT WINAPI UniformResourceLocatorW_GetUrl(IUniformResourceLocatorW *url, LPWSTR *ppszURL)
Definition: intshcut.c:240
static HRESULT WINAPI PersistFile_Save(IPersistFile *pFile, LPCOLESTR pszFileName, BOOL fRemember)
Definition: intshcut.c:537
static HRESULT WINAPI UniformResourceLocatorA_GetUrl(IUniformResourceLocatorA *url, LPSTR *ppszURL)
Definition: intshcut.c:343
static HRESULT WINAPI PropertySetStorage_QueryInterface(IPropertySetStorage *iface, REFIID riid, PVOID *ppvObject)
Definition: intshcut.c:673
static ULONG WINAPI PropertySetStorage_Release(IPropertySetStorage *iface)
Definition: intshcut.c:687
static HRESULT WINAPI UniformResourceLocatorA_QueryInterface(IUniformResourceLocatorA *url, REFIID riid, PVOID *ppvObject)
Definition: intshcut.c:303
static HRESULT WINAPI PersistFile_Load(IPersistFile *pFile, LPCOLESTR pszFileName, DWORD dwMode)
Definition: intshcut.c:455
static const IUniformResourceLocatorWVtbl uniformResourceLocatorWVtbl
Definition: intshcut.c:750
static HRESULT WINAPI UniformResourceLocatorA_InvokeCommand(IUniformResourceLocatorA *url, PURLINVOKECOMMANDINFOA pCommandInfo)
Definition: intshcut.c:362
static ULONG WINAPI UniformResourceLocatorW_Release(IUniformResourceLocatorW *url)
Definition: intshcut.c:214
static ULONG WINAPI UniformResourceLocatorW_AddRef(IUniformResourceLocatorW *url)
Definition: intshcut.c:207
static HRESULT WINAPI PersistFile_GetClassID(IPersistFile *pFile, CLSID *pClassID)
Definition: intshcut.c:407
static ULONG Unknown_Release(InternetShortcut *This)
Definition: intshcut.c:184
static const IPersistFileVtbl persistFileVtbl
Definition: intshcut.c:768
static ULONG WINAPI PropertySetStorage_AddRef(IPropertySetStorage *iface)
Definition: intshcut.c:680
static BOOL run_winemenubuilder(const WCHAR *args)
Definition: intshcut.c:83
static HRESULT get_profile_string(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpFileName, WCHAR **rString)
Definition: intshcut.c:422
static InternetShortcut * impl_from_IPersistFile(IPersistFile *iface)
Definition: intshcut.c:73
static HRESULT WINAPI PropertySetStorage_Delete(IPropertySetStorage *iface, REFFMTID rfmtid)
Definition: intshcut.c:734
static ULONG WINAPI UniformResourceLocatorA_Release(IUniformResourceLocatorA *url)
Definition: intshcut.c:317
static ULONG WINAPI UniformResourceLocatorA_AddRef(IUniformResourceLocatorA *url)
Definition: intshcut.c:310
static HRESULT WINAPI PersistFile_SaveCompleted(IPersistFile *pFile, LPCOLESTR pszFileName)
Definition: intshcut.c:651
static HRESULT WINAPI PropertySetStorage_Enum(IPropertySetStorage *iface, IEnumSTATPROPSETSTG **ppenum)
Definition: intshcut.c:744
static ULONG WINAPI PersistFile_AddRef(IPersistFile *pFile)
Definition: intshcut.c:393
static InternetShortcut * create_shortcut(void)
Definition: intshcut.c:790
static InternetShortcut * impl_from_IPropertySetStorage(IPropertySetStorage *iface)
Definition: intshcut.c:78
static ULONG WINAPI PersistFile_Release(IPersistFile *pFile)
Definition: intshcut.c:400
static HRESULT WINAPI UniformResourceLocatorA_SetUrl(IUniformResourceLocatorA *url, LPCSTR pcszURL, DWORD dwInFlags)
Definition: intshcut.c:324
static HRESULT WINAPI PersistFile_IsDirty(IPersistFile *pFile)
Definition: intshcut.c:414
static const IUniformResourceLocatorAVtbl uniformResourceLocatorAVtbl
Definition: intshcut.c:759
static InternetShortcut * impl_from_IUniformResourceLocatorW(IUniformResourceLocatorW *iface)
Definition: intshcut.c:68
static HRESULT WINAPI PropertySetStorage_Create(IPropertySetStorage *iface, REFFMTID rfmtid, const CLSID *pclsid, DWORD grfFlags, DWORD grfMode, IPropertyStorage **ppprstg)
Definition: intshcut.c:694
static HRESULT WINAPI PropertySetStorage_Open(IPropertySetStorage *iface, REFFMTID rfmtid, DWORD grfMode, IPropertyStorage **ppprstg)
Definition: intshcut.c:713
static const IPropertySetStorageVtbl propertySetStorageVtbl
Definition: intshcut.c:780
static HRESULT WINAPI UniformResourceLocatorW_SetUrl(IUniformResourceLocatorW *url, LPCWSTR pcszURL, DWORD dwInFlags)
Definition: intshcut.c:221
static HRESULT WINAPI UniformResourceLocatorW_QueryInterface(IUniformResourceLocatorW *url, REFIID riid, PVOID *ppvObject)
Definition: intshcut.c:200
static HRESULT WINAPI UniformResourceLocatorW_InvokeCommand(IUniformResourceLocatorW *url, PURLINVOKECOMMANDINFOW pCommandInfo)
Definition: intshcut.c:258
static HRESULT Unknown_QueryInterface(InternetShortcut *This, REFIID riid, PVOID *ppvObject)
Definition: intshcut.c:145
static HRESULT WINAPI PersistFile_GetCurFile(IPersistFile *pFile, LPOLESTR *ppszFileName)
Definition: intshcut.c:657
static ULONG Unknown_AddRef(InternetShortcut *This)
Definition: intshcut.c:178
static BOOL StartLinkProcessor(LPCOLESTR szLink)
Definition: intshcut.c:125
static InternetShortcut * impl_from_IUniformResourceLocatorA(IUniformResourceLocatorA *iface)
Definition: intshcut.c:63
static HRESULT WINAPI PersistFile_QueryInterface(IPersistFile *pFile, REFIID riid, PVOID *ppvObject)
Definition: intshcut.c:386
HRESULT WINAPI InternetShortcut_Create(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: intshcut.c:828
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2331
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4491
BOOL WINAPI Wow64RevertWow64FsRedirection(IN PVOID OldValue)
Definition: utils.c:836
BOOL WINAPI Wow64DisableWow64FsRedirection(IN PVOID *OldValue)
Definition: utils.c:813
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
_ACRTIMP __msvcrt_long __cdecl wcstol(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2752
HRESULT WINAPI StgCreateStorageEx(const WCHAR *pwcsName, DWORD grfMode, DWORD stgfmt, DWORD grfAttrs, STGOPTIONS *pStgOptions, void *reserved, REFIID riid, void **ppObjectOpen)
Definition: storage32.c:8618
HRESULT WINAPI CoInternetParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwFlags, LPWSTR pszResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
Definition: internet.c:325
#define swprintf
Definition: precomp.h:40
return ret
Definition: mutex.c:147
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
MdFileObject pFile
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint buffer
Definition: glext.h:5915
GLuint res
Definition: glext.h:9613
GLenum GLsizei GLuint GLint * bytesWritten
Definition: glext.h:11123
GLenum GLsizei len
Definition: glext.h:6722
static LPWSTR co_strdupAtoW(LPCSTR str)
Definition: ieframe.h:358
static void unlock_module(void)
Definition: ieframe.h:346
static LPSTR co_strdupWtoA(LPCWSTR str)
Definition: ieframe.h:369
static LPWSTR co_strdupW(LPCWSTR str)
Definition: ieframe.h:350
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
@ IURL_INVOKECOMMAND_FL_USE_DEFAULT_VERB
Definition: intshcut.h:43
const char * filename
Definition: ioapi.h:137
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static void OpenURL(void)
Definition: main.c:233
#define CREATE_ALWAYS
Definition: disk.h:72
#define sprintf
Definition: sprintf.c:45
static const WCHAR url[]
Definition: encode.c:1384
HRESULT hres
Definition: protocol.c:432
static PROCESS_INFORMATION pi
Definition: debugger.c:2303
static SYSTEM_INFO si
Definition: virtual.c:39
static IUnknown * outer
Definition: compobj.c:82
#define GENERIC_WRITE
Definition: nt_native.h:90
#define STGM_CREATE
Definition: objbase.h:945
#define STGM_READWRITE
Definition: objbase.h:938
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:942
#define STGM_DELETEONRELEASE
Definition: objbase.h:944
#define STGM_WRITE
Definition: objbase.h:937
#define STGM_READ
Definition: objbase.h:936
#define STGFMT_STORAGE
Definition: objbase.h:952
const GUID IID_IPersistFile
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
char CHAR
Definition: pedump.c:57
#define REFFMTID
Definition: guiddef.h:119
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define SW_SHOW
Definition: winuser.h:786
#define calloc
Definition: rosglue.h:14
#define CP_UTF8
Definition: nls.h:20
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2732
#define PID_IS_ICONINDEX
Definition: shlobj.h:2511
#define PID_IS_ICONFILE
Definition: shlobj.h:2512
#define TRACE(s)
Definition: solgame.cpp:4
Definition: match.c:390
Definition: fci.c:123
const char * LPCSTR
Definition: typedefs.h:52
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56
char * LPSTR
Definition: typedefs.h:51
int32_t INT
Definition: typedefs.h:58
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
_In_ LPCSTR lpFileName
Definition: winbase.h:2800
#define DETACHED_PROCESS
Definition: winbase.h:184
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:3451
#define E_NOINTERFACE
Definition: winerror.h:3479
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList