2008-08-03 11:18:26 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Damjan Jovanovic
|
|
|
|
*
|
|
|
|
* ShellLink's barely documented cousin that handles URLs.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO:
|
|
|
|
* Implement the IShellLinkA/W interfaces
|
|
|
|
* Handle the SetURL flags
|
|
|
|
* Implement any other interfaces? Does any software actually use them?
|
|
|
|
*
|
|
|
|
* The installer for the Zuma Deluxe Popcap game is good for testing.
|
|
|
|
*/
|
|
|
|
|
2010-11-04 23:26:34 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2015-03-12 11:11:10 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2011-07-23 18:40:54 +02:00
|
|
|
#include "ieframe.h"
|
|
|
|
|
|
|
|
#include "shlobj.h"
|
2008-08-03 11:18:26 +02:00
|
|
|
#include "shobjidl.h"
|
|
|
|
#include "intshcut.h"
|
2010-11-04 23:25:09 +01:00
|
|
|
#include "shellapi.h"
|
|
|
|
#include "winreg.h"
|
2010-11-04 23:26:34 +01:00
|
|
|
#include "shlwapi.h"
|
2011-07-23 18:40:54 +02:00
|
|
|
#include "shlguid.h"
|
2008-08-03 11:18:26 +02:00
|
|
|
|
2011-07-23 18:40:54 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
|
2008-08-03 11:18:26 +02:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2011-04-08 11:58:00 +02:00
|
|
|
IUniformResourceLocatorA IUniformResourceLocatorA_iface;
|
|
|
|
IUniformResourceLocatorW IUniformResourceLocatorW_iface;
|
|
|
|
IPersistFile IPersistFile_iface;
|
2010-11-20 04:54:26 +01:00
|
|
|
IPropertySetStorage IPropertySetStorage_iface;
|
2008-08-03 11:18:26 +02:00
|
|
|
|
|
|
|
LONG refCount;
|
|
|
|
|
2010-11-20 04:54:26 +01:00
|
|
|
IPropertySetStorage *property_set_storage;
|
2008-08-03 11:18:26 +02:00
|
|
|
WCHAR *url;
|
|
|
|
BOOLEAN isDirty;
|
|
|
|
LPOLESTR currentFile;
|
|
|
|
} InternetShortcut;
|
|
|
|
|
|
|
|
/* utility functions */
|
|
|
|
|
|
|
|
static inline InternetShortcut* impl_from_IUniformResourceLocatorA(IUniformResourceLocatorA *iface)
|
|
|
|
{
|
2011-04-08 11:58:00 +02:00
|
|
|
return CONTAINING_RECORD(iface, InternetShortcut, IUniformResourceLocatorA_iface);
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline InternetShortcut* impl_from_IUniformResourceLocatorW(IUniformResourceLocatorW *iface)
|
|
|
|
{
|
2011-04-08 11:58:00 +02:00
|
|
|
return CONTAINING_RECORD(iface, InternetShortcut, IUniformResourceLocatorW_iface);
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline InternetShortcut* impl_from_IPersistFile(IPersistFile *iface)
|
|
|
|
{
|
2011-04-08 11:58:00 +02:00
|
|
|
return CONTAINING_RECORD(iface, InternetShortcut, IPersistFile_iface);
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
2010-11-20 04:54:26 +01:00
|
|
|
static inline InternetShortcut* impl_from_IPropertySetStorage(IPropertySetStorage *iface)
|
|
|
|
{
|
2011-09-25 23:33:28 +02:00
|
|
|
return CONTAINING_RECORD(iface, InternetShortcut, IPropertySetStorage_iface);
|
2010-11-20 04:54:26 +01:00
|
|
|
}
|
|
|
|
|
2009-10-27 11:22:32 +01:00
|
|
|
static BOOL run_winemenubuilder( const WCHAR *args )
|
2008-11-13 07:19:25 +01:00
|
|
|
{
|
2009-10-27 11:22:32 +01:00
|
|
|
static const WCHAR menubuilder[] = {'\\','w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e',0};
|
2008-11-13 07:19:25 +01:00
|
|
|
LONG len;
|
|
|
|
LPWSTR buffer;
|
|
|
|
STARTUPINFOW si;
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
BOOL ret;
|
2009-10-27 11:22:32 +01:00
|
|
|
WCHAR app[MAX_PATH];
|
2010-03-29 15:48:17 +02:00
|
|
|
void *redir;
|
2008-11-13 07:19:25 +01:00
|
|
|
|
2018-08-16 20:19:29 +02:00
|
|
|
GetSystemDirectoryW( app, MAX_PATH - ARRAY_SIZE( menubuilder ));
|
2019-06-05 08:39:04 +02:00
|
|
|
lstrcatW( app, menubuilder );
|
2009-10-27 11:22:32 +01:00
|
|
|
|
2019-06-05 08:39:04 +02:00
|
|
|
len = (lstrlenW( app ) + lstrlenW( args ) + 1) * sizeof(WCHAR);
|
2008-11-13 07:19:25 +01:00
|
|
|
buffer = heap_alloc( len );
|
|
|
|
if( !buffer )
|
|
|
|
return FALSE;
|
|
|
|
|
2019-06-05 08:39:04 +02:00
|
|
|
lstrcpyW( buffer, app );
|
|
|
|
lstrcatW( buffer, args );
|
2008-11-13 07:19:25 +01:00
|
|
|
|
|
|
|
TRACE("starting %s\n",debugstr_w(buffer));
|
|
|
|
|
|
|
|
memset(&si, 0, sizeof(si));
|
|
|
|
si.cb = sizeof(si);
|
|
|
|
|
2010-03-29 15:48:17 +02:00
|
|
|
Wow64DisableWow64FsRedirection( &redir );
|
2013-01-14 21:20:06 +01:00
|
|
|
ret = CreateProcessW( app, buffer, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi );
|
2010-03-29 15:48:17 +02:00
|
|
|
Wow64RevertWow64FsRedirection( redir );
|
2008-11-13 07:19:25 +01:00
|
|
|
|
2009-10-27 11:22:32 +01:00
|
|
|
heap_free( buffer );
|
2008-11-13 07:19:25 +01:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
CloseHandle( pi.hProcess );
|
|
|
|
CloseHandle( pi.hThread );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-10-27 11:22:32 +01:00
|
|
|
static BOOL StartLinkProcessor( LPCOLESTR szLink )
|
|
|
|
{
|
|
|
|
static const WCHAR szFormat[] = { ' ','-','w',' ','-','u',' ','"','%','s','"',0 };
|
|
|
|
LONG len;
|
|
|
|
LPWSTR buffer;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
len = sizeof(szFormat) + lstrlenW( szLink ) * sizeof(WCHAR);
|
|
|
|
buffer = heap_alloc( len );
|
|
|
|
if( !buffer )
|
|
|
|
return FALSE;
|
|
|
|
|
2019-06-05 08:39:04 +02:00
|
|
|
swprintf( buffer, len / sizeof(WCHAR), szFormat, szLink );
|
2009-10-27 11:22:32 +01:00
|
|
|
ret = run_winemenubuilder( buffer );
|
|
|
|
heap_free( buffer );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-08-03 11:18:26 +02:00
|
|
|
/* interface functions */
|
|
|
|
|
2008-11-25 16:42:43 +01:00
|
|
|
static HRESULT Unknown_QueryInterface(InternetShortcut *This, REFIID riid, PVOID *ppvObject)
|
2008-08-03 11:18:26 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObject);
|
|
|
|
*ppvObject = NULL;
|
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid))
|
2011-04-08 11:58:00 +02:00
|
|
|
*ppvObject = &This->IUniformResourceLocatorA_iface;
|
2008-08-03 11:18:26 +02:00
|
|
|
else if (IsEqualGUID(&IID_IUniformResourceLocatorA, riid))
|
2011-04-08 11:58:00 +02:00
|
|
|
*ppvObject = &This->IUniformResourceLocatorA_iface;
|
2008-08-03 11:18:26 +02:00
|
|
|
else if (IsEqualGUID(&IID_IUniformResourceLocatorW, riid))
|
2011-04-08 11:58:00 +02:00
|
|
|
*ppvObject = &This->IUniformResourceLocatorW_iface;
|
2008-08-03 11:18:26 +02:00
|
|
|
else if (IsEqualGUID(&IID_IPersistFile, riid))
|
2011-04-08 11:58:00 +02:00
|
|
|
*ppvObject = &This->IPersistFile_iface;
|
2010-11-20 04:54:26 +01:00
|
|
|
else if (IsEqualGUID(&IID_IPropertySetStorage, riid))
|
|
|
|
*ppvObject = &This->IPropertySetStorage_iface;
|
2008-08-03 11:18:26 +02:00
|
|
|
else if (IsEqualGUID(&IID_IShellLinkA, riid))
|
|
|
|
{
|
|
|
|
FIXME("The IShellLinkA interface is not yet supported by InternetShortcut\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&IID_IShellLinkW, riid))
|
|
|
|
{
|
|
|
|
FIXME("The IShellLinkW interface is not yet supported by InternetShortcut\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Interface with GUID %s not yet implemented by InternetShortcut\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObject);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-11-25 16:42:43 +01:00
|
|
|
static ULONG Unknown_AddRef(InternetShortcut *This)
|
2008-08-03 11:18:26 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return InterlockedIncrement(&This->refCount);
|
|
|
|
}
|
|
|
|
|
2008-11-25 16:42:43 +01:00
|
|
|
static ULONG Unknown_Release(InternetShortcut *This)
|
2008-08-03 11:18:26 +02:00
|
|
|
{
|
|
|
|
ULONG count;
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
count = InterlockedDecrement(&This->refCount);
|
|
|
|
if (count == 0)
|
|
|
|
{
|
|
|
|
CoTaskMemFree(This->url);
|
|
|
|
CoTaskMemFree(This->currentFile);
|
2010-11-20 04:54:26 +01:00
|
|
|
IPropertySetStorage_Release(This->property_set_storage);
|
2008-08-03 11:18:26 +02:00
|
|
|
heap_free(This);
|
2011-07-23 18:40:54 +02:00
|
|
|
unlock_module();
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UniformResourceLocatorW_QueryInterface(IUniformResourceLocatorW *url, REFIID riid, PVOID *ppvObject)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IUniformResourceLocatorW(url);
|
|
|
|
TRACE("(%p, %s, %p)\n", url, debugstr_guid(riid), ppvObject);
|
|
|
|
return Unknown_QueryInterface(This, riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI UniformResourceLocatorW_AddRef(IUniformResourceLocatorW *url)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IUniformResourceLocatorW(url);
|
|
|
|
TRACE("(%p)\n", url);
|
|
|
|
return Unknown_AddRef(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI UniformResourceLocatorW_Release(IUniformResourceLocatorW *url)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IUniformResourceLocatorW(url);
|
|
|
|
TRACE("(%p)\n", url);
|
|
|
|
return Unknown_Release(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UniformResourceLocatorW_SetUrl(IUniformResourceLocatorW *url, LPCWSTR pcszURL, DWORD dwInFlags)
|
|
|
|
{
|
|
|
|
WCHAR *newURL = NULL;
|
|
|
|
InternetShortcut *This = impl_from_IUniformResourceLocatorW(url);
|
2022-02-11 08:39:53 +01:00
|
|
|
TRACE("(%p, %s, 0x%lx)\n", url, debugstr_w(pcszURL), dwInFlags);
|
2008-08-03 11:18:26 +02:00
|
|
|
if (dwInFlags != 0)
|
2022-02-11 08:39:53 +01:00
|
|
|
FIXME("ignoring unsupported flags 0x%lx\n", dwInFlags);
|
2008-08-03 11:18:26 +02:00
|
|
|
if (pcszURL != NULL)
|
|
|
|
{
|
|
|
|
newURL = co_strdupW(pcszURL);
|
|
|
|
if (newURL == NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
CoTaskMemFree(This->url);
|
|
|
|
This->url = newURL;
|
|
|
|
This->isDirty = TRUE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UniformResourceLocatorW_GetUrl(IUniformResourceLocatorW *url, LPWSTR *ppszURL)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IUniformResourceLocatorW(url);
|
2011-04-08 11:59:43 +02:00
|
|
|
|
2008-08-03 11:18:26 +02:00
|
|
|
TRACE("(%p, %p)\n", url, ppszURL);
|
2011-04-08 11:59:43 +02:00
|
|
|
|
|
|
|
if (!This->url) {
|
2008-08-03 11:18:26 +02:00
|
|
|
*ppszURL = NULL;
|
2011-04-08 11:59:43 +02:00
|
|
|
return S_FALSE;
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
2011-04-08 11:59:43 +02:00
|
|
|
|
|
|
|
*ppszURL = co_strdupW(This->url);
|
|
|
|
if (!*ppszURL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return S_OK;
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UniformResourceLocatorW_InvokeCommand(IUniformResourceLocatorW *url, PURLINVOKECOMMANDINFOW pCommandInfo)
|
|
|
|
{
|
2010-11-04 23:25:09 +01:00
|
|
|
InternetShortcut *This = impl_from_IUniformResourceLocatorW(url);
|
|
|
|
WCHAR app[64];
|
|
|
|
HKEY hkey;
|
|
|
|
static const WCHAR wszURLProtocol[] = {'U','R','L',' ','P','r','o','t','o','c','o','l',0};
|
|
|
|
SHELLEXECUTEINFOW sei;
|
|
|
|
DWORD res, type;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%p %p\n", This, pCommandInfo );
|
|
|
|
|
|
|
|
if (pCommandInfo->dwcbSize < sizeof (URLINVOKECOMMANDINFOW))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (pCommandInfo->dwFlags != IURL_INVOKECOMMAND_FL_USE_DEFAULT_VERB)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p): non-default verbs not implemented\n", url, pCommandInfo);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-08-16 20:19:29 +02:00
|
|
|
hres = CoInternetParseUrl(This->url, PARSE_SCHEMA, 0, app, ARRAY_SIZE(app), NULL, 0);
|
2010-11-04 23:25:09 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
res = RegOpenKeyW(HKEY_CLASSES_ROOT, app, &hkey);
|
|
|
|
if(res != ERROR_SUCCESS)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
res = RegQueryValueExW(hkey, wszURLProtocol, NULL, &type, NULL, NULL);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
if(res != ERROR_SUCCESS || type != REG_SZ)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
memset(&sei, 0, sizeof(sei));
|
|
|
|
sei.cbSize = sizeof(sei);
|
|
|
|
sei.lpFile = This->url;
|
|
|
|
sei.nShow = SW_SHOW;
|
|
|
|
|
|
|
|
if( ShellExecuteExW(&sei) )
|
|
|
|
return S_OK;
|
|
|
|
else
|
|
|
|
return E_FAIL;
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UniformResourceLocatorA_QueryInterface(IUniformResourceLocatorA *url, REFIID riid, PVOID *ppvObject)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IUniformResourceLocatorA(url);
|
|
|
|
TRACE("(%p, %s, %p)\n", url, debugstr_guid(riid), ppvObject);
|
|
|
|
return Unknown_QueryInterface(This, riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI UniformResourceLocatorA_AddRef(IUniformResourceLocatorA *url)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IUniformResourceLocatorA(url);
|
|
|
|
TRACE("(%p)\n", url);
|
|
|
|
return Unknown_AddRef(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI UniformResourceLocatorA_Release(IUniformResourceLocatorA *url)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IUniformResourceLocatorA(url);
|
|
|
|
TRACE("(%p)\n", url);
|
|
|
|
return Unknown_Release(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UniformResourceLocatorA_SetUrl(IUniformResourceLocatorA *url, LPCSTR pcszURL, DWORD dwInFlags)
|
|
|
|
{
|
|
|
|
WCHAR *newURL = NULL;
|
|
|
|
InternetShortcut *This = impl_from_IUniformResourceLocatorA(url);
|
2022-02-11 08:39:53 +01:00
|
|
|
TRACE("(%p, %s, 0x%lx)\n", url, debugstr_a(pcszURL), dwInFlags);
|
2008-08-03 11:18:26 +02:00
|
|
|
if (dwInFlags != 0)
|
2022-02-11 08:39:53 +01:00
|
|
|
FIXME("ignoring unsupported flags 0x%lx\n", dwInFlags);
|
2008-08-03 11:18:26 +02:00
|
|
|
if (pcszURL != NULL)
|
|
|
|
{
|
|
|
|
newURL = co_strdupAtoW(pcszURL);
|
|
|
|
if (newURL == NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
CoTaskMemFree(This->url);
|
|
|
|
This->url = newURL;
|
|
|
|
This->isDirty = TRUE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UniformResourceLocatorA_GetUrl(IUniformResourceLocatorA *url, LPSTR *ppszURL)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IUniformResourceLocatorA(url);
|
2011-04-08 11:59:43 +02:00
|
|
|
|
2008-08-03 11:18:26 +02:00
|
|
|
TRACE("(%p, %p)\n", url, ppszURL);
|
2011-04-08 11:59:43 +02:00
|
|
|
|
|
|
|
if (!This->url) {
|
2008-08-03 11:18:26 +02:00
|
|
|
*ppszURL = NULL;
|
2011-04-08 11:59:43 +02:00
|
|
|
return S_FALSE;
|
|
|
|
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
2011-04-08 11:59:43 +02:00
|
|
|
|
|
|
|
*ppszURL = co_strdupWtoA(This->url);
|
|
|
|
if (!*ppszURL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return S_OK;
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UniformResourceLocatorA_InvokeCommand(IUniformResourceLocatorA *url, PURLINVOKECOMMANDINFOA pCommandInfo)
|
|
|
|
{
|
2010-11-04 23:25:09 +01:00
|
|
|
URLINVOKECOMMANDINFOW wideCommandInfo;
|
|
|
|
int len;
|
|
|
|
WCHAR *wideVerb;
|
|
|
|
HRESULT res;
|
|
|
|
InternetShortcut *This = impl_from_IUniformResourceLocatorA(url);
|
|
|
|
|
|
|
|
wideCommandInfo.dwcbSize = sizeof wideCommandInfo;
|
|
|
|
wideCommandInfo.dwFlags = pCommandInfo->dwFlags;
|
|
|
|
wideCommandInfo.hwndParent = pCommandInfo->hwndParent;
|
|
|
|
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pCommandInfo->pcszVerb, -1, NULL, 0);
|
|
|
|
wideVerb = heap_alloc(len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pCommandInfo->pcszVerb, -1, wideVerb, len);
|
|
|
|
|
|
|
|
wideCommandInfo.pcszVerb = wideVerb;
|
|
|
|
|
2011-04-08 11:58:00 +02:00
|
|
|
res = UniformResourceLocatorW_InvokeCommand(&This->IUniformResourceLocatorW_iface, &wideCommandInfo);
|
2010-11-04 23:25:09 +01:00
|
|
|
heap_free(wideVerb);
|
|
|
|
|
|
|
|
return res;
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_QueryInterface(IPersistFile *pFile, REFIID riid, PVOID *ppvObject)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IPersistFile(pFile);
|
|
|
|
TRACE("(%p, %s, %p)\n", pFile, debugstr_guid(riid), ppvObject);
|
|
|
|
return Unknown_QueryInterface(This, riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PersistFile_AddRef(IPersistFile *pFile)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IPersistFile(pFile);
|
|
|
|
TRACE("(%p)\n", pFile);
|
|
|
|
return Unknown_AddRef(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PersistFile_Release(IPersistFile *pFile)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IPersistFile(pFile);
|
|
|
|
TRACE("(%p)\n", pFile);
|
|
|
|
return Unknown_Release(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_GetClassID(IPersistFile *pFile, CLSID *pClassID)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p)\n", pFile, pClassID);
|
|
|
|
*pClassID = CLSID_InternetShortcut;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_IsDirty(IPersistFile *pFile)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IPersistFile(pFile);
|
|
|
|
TRACE("(%p)\n", pFile);
|
|
|
|
return This->isDirty ? S_OK : S_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-04-11 21:14:54 +02:00
|
|
|
/* Returns allocated profile string and a standard return code. */
|
|
|
|
static HRESULT get_profile_string(LPCWSTR lpAppName, LPCWSTR lpKeyName,
|
2010-11-24 23:47:50 +01:00
|
|
|
LPCWSTR lpFileName, WCHAR **rString )
|
|
|
|
{
|
|
|
|
DWORD r = 0;
|
2010-12-07 10:13:02 +01:00
|
|
|
DWORD len = 128;
|
|
|
|
WCHAR *buffer;
|
2010-11-24 23:47:50 +01:00
|
|
|
|
2016-04-11 21:14:54 +02:00
|
|
|
*rString = NULL;
|
2010-12-07 10:13:02 +01:00
|
|
|
buffer = CoTaskMemAlloc(len * sizeof(*buffer));
|
2016-04-11 21:14:54 +02:00
|
|
|
if (!buffer)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
r = GetPrivateProfileStringW(lpAppName, lpKeyName, NULL, buffer, len, lpFileName);
|
|
|
|
while (r == len-1)
|
2010-11-24 23:47:50 +01:00
|
|
|
{
|
2016-04-11 21:14:54 +02:00
|
|
|
WCHAR *realloc_buf;
|
|
|
|
|
|
|
|
len *= 2;
|
|
|
|
realloc_buf = CoTaskMemRealloc(buffer, len * sizeof(*buffer));
|
|
|
|
if (realloc_buf == NULL)
|
2010-11-24 23:47:50 +01:00
|
|
|
{
|
2016-04-11 21:14:54 +02:00
|
|
|
CoTaskMemFree(buffer);
|
|
|
|
return E_OUTOFMEMORY;
|
2010-11-24 23:47:50 +01:00
|
|
|
}
|
2016-04-11 21:14:54 +02:00
|
|
|
buffer = realloc_buf;
|
|
|
|
|
|
|
|
r = GetPrivateProfileStringW(lpAppName, lpKeyName, NULL, buffer, len, lpFileName);
|
2010-11-24 23:47:50 +01:00
|
|
|
}
|
|
|
|
|
2010-12-07 10:13:02 +01:00
|
|
|
*rString = buffer;
|
2016-04-11 21:14:54 +02:00
|
|
|
return r ? S_OK : E_FAIL;
|
2010-11-24 23:47:50 +01:00
|
|
|
}
|
|
|
|
|
2008-08-03 11:18:26 +02:00
|
|
|
static HRESULT WINAPI PersistFile_Load(IPersistFile *pFile, LPCOLESTR pszFileName, DWORD dwMode)
|
|
|
|
{
|
2018-12-04 09:14:01 +01:00
|
|
|
static const WCHAR str_header[] = {'I','n','t','e','r','n','e','t','S','h','o','r','t','c','u','t',0};
|
|
|
|
static const WCHAR str_URL[] = {'U','R','L',0};
|
|
|
|
static const WCHAR str_iconfile[] = {'i','c','o','n','f','i','l','e',0};
|
|
|
|
static const WCHAR str_iconindex[] = {'i','c','o','n','i','n','d','e','x',0};
|
2016-04-11 21:14:54 +02:00
|
|
|
InternetShortcut *This = impl_from_IPersistFile(pFile);
|
2008-11-13 07:19:25 +01:00
|
|
|
WCHAR *filename = NULL;
|
2016-04-11 21:14:54 +02:00
|
|
|
WCHAR *url;
|
2008-11-13 07:19:25 +01:00
|
|
|
HRESULT hr;
|
2016-04-11 21:14:54 +02:00
|
|
|
IPropertyStorage *pPropStg;
|
|
|
|
WCHAR *iconfile;
|
|
|
|
WCHAR *iconindexstring;
|
|
|
|
|
2022-02-11 08:39:53 +01:00
|
|
|
TRACE("(%p, %s, 0x%lx)\n", pFile, debugstr_w(pszFileName), dwMode);
|
2016-04-11 21:14:54 +02:00
|
|
|
|
2008-11-13 07:19:25 +01:00
|
|
|
if (dwMode != 0)
|
2022-02-11 08:39:53 +01:00
|
|
|
FIXME("ignoring unimplemented mode 0x%lx\n", dwMode);
|
2016-04-11 21:14:54 +02:00
|
|
|
|
2008-11-13 07:19:25 +01:00
|
|
|
filename = co_strdupW(pszFileName);
|
2016-04-11 21:14:54 +02:00
|
|
|
if (!filename)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = get_profile_string(str_header, str_URL, pszFileName, &url)))
|
2008-11-13 07:19:25 +01:00
|
|
|
{
|
2016-04-11 21:14:54 +02:00
|
|
|
CoTaskMemFree(filename);
|
|
|
|
return hr;
|
|
|
|
}
|
2010-11-24 23:47:50 +01:00
|
|
|
|
2016-04-11 21:14:56 +02:00
|
|
|
hr = IPropertySetStorage_Open(This->property_set_storage, &FMTID_Intshcut,
|
|
|
|
STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &pPropStg);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
CoTaskMemFree(filename);
|
|
|
|
CoTaskMemFree(url);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2016-04-11 21:14:54 +02:00
|
|
|
CoTaskMemFree(This->currentFile);
|
|
|
|
This->currentFile = filename;
|
|
|
|
CoTaskMemFree(This->url);
|
|
|
|
This->url = url;
|
|
|
|
This->isDirty = FALSE;
|
2010-11-24 23:47:50 +01:00
|
|
|
|
2016-04-11 21:14:54 +02:00
|
|
|
/* Now we're going to read in the iconfile and iconindex.
|
|
|
|
If we don't find them, that's not a failure case -- it's possible
|
|
|
|
that they just aren't in there. */
|
2010-11-24 23:47:50 +01:00
|
|
|
|
2016-04-11 21:14:54 +02:00
|
|
|
if (get_profile_string(str_header, str_iconfile, pszFileName, &iconfile) == S_OK)
|
|
|
|
{
|
|
|
|
PROPSPEC ps;
|
|
|
|
PROPVARIANT pv;
|
|
|
|
ps.ulKind = PRSPEC_PROPID;
|
|
|
|
ps.u.propid = PID_IS_ICONFILE;
|
|
|
|
pv.vt = VT_LPWSTR;
|
2021-03-22 18:31:46 +01:00
|
|
|
pv.pwszVal = iconfile;
|
2016-04-11 21:14:54 +02:00
|
|
|
hr = IPropertyStorage_WriteMultiple(pPropStg, 1, &ps, &pv, 0);
|
|
|
|
if (FAILED(hr))
|
2022-02-11 08:39:53 +01:00
|
|
|
TRACE("Failed to store the iconfile to our property storage. hr = 0x%lx\n", hr);
|
2008-11-13 07:19:25 +01:00
|
|
|
}
|
2016-04-11 21:14:54 +02:00
|
|
|
CoTaskMemFree(iconfile);
|
|
|
|
|
|
|
|
if (get_profile_string(str_header, str_iconindex, pszFileName, &iconindexstring) == S_OK)
|
|
|
|
{
|
|
|
|
int iconindex;
|
|
|
|
PROPSPEC ps;
|
|
|
|
PROPVARIANT pv;
|
2019-06-05 08:39:04 +02:00
|
|
|
iconindex = wcstol(iconindexstring, NULL, 10);
|
2016-04-11 21:14:54 +02:00
|
|
|
ps.ulKind = PRSPEC_PROPID;
|
|
|
|
ps.u.propid = PID_IS_ICONINDEX;
|
|
|
|
pv.vt = VT_I4;
|
2021-03-22 18:31:46 +01:00
|
|
|
pv.iVal = iconindex;
|
2016-04-11 21:14:54 +02:00
|
|
|
hr = IPropertyStorage_WriteMultiple(pPropStg, 1, &ps, &pv, 0);
|
|
|
|
if (FAILED(hr))
|
2022-02-11 08:39:53 +01:00
|
|
|
TRACE("Failed to store the iconindex to our property storage. hr = 0x%lx\n", hr);
|
2016-04-11 21:14:54 +02:00
|
|
|
}
|
|
|
|
CoTaskMemFree(iconindexstring);
|
|
|
|
|
|
|
|
IPropertyStorage_Release(pPropStg);
|
2008-11-13 07:19:25 +01:00
|
|
|
return hr;
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_Save(IPersistFile *pFile, LPCOLESTR pszFileName, BOOL fRemember)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
INT len;
|
|
|
|
CHAR *url;
|
|
|
|
InternetShortcut *This = impl_from_IPersistFile(pFile);
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %d)\n", pFile, debugstr_w(pszFileName), fRemember);
|
|
|
|
|
|
|
|
if (pszFileName != NULL && fRemember)
|
|
|
|
{
|
|
|
|
LPOLESTR oldFile = This->currentFile;
|
|
|
|
This->currentFile = co_strdupW(pszFileName);
|
|
|
|
if (This->currentFile == NULL)
|
|
|
|
{
|
|
|
|
This->currentFile = oldFile;
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
CoTaskMemFree(oldFile);
|
|
|
|
}
|
|
|
|
if (This->url == NULL)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/* Windows seems to always write:
|
|
|
|
* ASCII "[InternetShortcut]" headers
|
|
|
|
* ASCII names in "name=value" pairs
|
|
|
|
* An ASCII (probably UTF8?) value in "URL=..."
|
|
|
|
*/
|
|
|
|
len = WideCharToMultiByte(CP_UTF8, 0, This->url, -1, NULL, 0, 0, 0);
|
|
|
|
url = heap_alloc(len);
|
|
|
|
if (url != NULL)
|
|
|
|
{
|
|
|
|
HANDLE file;
|
|
|
|
WideCharToMultiByte(CP_UTF8, 0, This->url, -1, url, len, 0, 0);
|
|
|
|
file = CreateFileW(pszFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
if (file != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
2018-12-04 09:14:01 +01:00
|
|
|
static const char str_header[] = "[InternetShortcut]";
|
|
|
|
static const char str_URL[] = "URL=";
|
|
|
|
static const char str_ICONFILE[] = "ICONFILE=";
|
|
|
|
static const char str_eol[] = "\r\n";
|
2008-08-03 11:18:26 +02:00
|
|
|
DWORD bytesWritten;
|
2010-11-20 05:02:26 +01:00
|
|
|
char *iconfile;
|
|
|
|
IPropertyStorage *pPropStgRead;
|
|
|
|
PROPSPEC ps[2];
|
|
|
|
PROPVARIANT pvread[2];
|
|
|
|
ps[0].ulKind = PRSPEC_PROPID;
|
2010-12-11 14:20:50 +01:00
|
|
|
ps[0].u.propid = PID_IS_ICONFILE;
|
2010-11-20 05:02:26 +01:00
|
|
|
ps[1].ulKind = PRSPEC_PROPID;
|
2010-12-11 14:20:50 +01:00
|
|
|
ps[1].u.propid = PID_IS_ICONINDEX;
|
2008-08-03 11:18:26 +02:00
|
|
|
|
2018-12-04 09:14:01 +01:00
|
|
|
WriteFile(file, str_header, ARRAY_SIZE(str_header) - 1, &bytesWritten, NULL);
|
|
|
|
WriteFile(file, str_eol, ARRAY_SIZE(str_eol) - 1, &bytesWritten, NULL);
|
|
|
|
WriteFile(file, str_URL, ARRAY_SIZE(str_URL) - 1, &bytesWritten, NULL);
|
2008-08-03 11:18:26 +02:00
|
|
|
WriteFile(file, url, lstrlenA(url), &bytesWritten, NULL);
|
2018-12-04 09:14:01 +01:00
|
|
|
WriteFile(file, str_eol, ARRAY_SIZE(str_eol) - 1, &bytesWritten, NULL);
|
2010-11-20 05:02:26 +01:00
|
|
|
|
|
|
|
hr = IPropertySetStorage_Open(This->property_set_storage, &FMTID_Intshcut, STGM_READ|STGM_SHARE_EXCLUSIVE, &pPropStgRead);
|
2013-02-06 10:59:50 +01:00
|
|
|
if (SUCCEEDED(hr))
|
2010-11-20 05:02:26 +01:00
|
|
|
{
|
|
|
|
hr = IPropertyStorage_ReadMultiple(pPropStgRead, 2, ps, pvread);
|
2010-12-23 13:19:40 +01:00
|
|
|
if (hr == S_FALSE)
|
|
|
|
{
|
|
|
|
/* None of the properties are present, that's ok */
|
|
|
|
hr = S_OK;
|
|
|
|
IPropertyStorage_Release(pPropStgRead);
|
|
|
|
}
|
2013-02-06 10:59:50 +01:00
|
|
|
else if (SUCCEEDED(hr))
|
2010-11-20 05:02:26 +01:00
|
|
|
{
|
|
|
|
char indexString[50];
|
2021-03-22 18:31:46 +01:00
|
|
|
len = WideCharToMultiByte(CP_UTF8, 0, pvread[0].pwszVal, -1, NULL, 0, 0, 0);
|
2010-11-20 05:02:26 +01:00
|
|
|
iconfile = heap_alloc(len);
|
|
|
|
if (iconfile != NULL)
|
|
|
|
{
|
2021-03-22 18:31:46 +01:00
|
|
|
WideCharToMultiByte(CP_UTF8, 0, pvread[0].pwszVal, -1, iconfile, len, 0, 0);
|
2010-11-20 05:02:26 +01:00
|
|
|
WriteFile(file, str_ICONFILE, lstrlenA(str_ICONFILE), &bytesWritten, NULL);
|
|
|
|
WriteFile(file, iconfile, lstrlenA(iconfile), &bytesWritten, NULL);
|
|
|
|
WriteFile(file, str_eol, lstrlenA(str_eol), &bytesWritten, NULL);
|
2020-12-18 09:39:49 +01:00
|
|
|
heap_free(iconfile);
|
2010-11-20 05:02:26 +01:00
|
|
|
}
|
|
|
|
|
2021-03-22 18:31:46 +01:00
|
|
|
sprintf(indexString, "ICONINDEX=%d", pvread[1].iVal);
|
2010-11-20 05:02:26 +01:00
|
|
|
WriteFile(file, indexString, lstrlenA(indexString), &bytesWritten, NULL);
|
|
|
|
WriteFile(file, str_eol, lstrlenA(str_eol), &bytesWritten, NULL);
|
|
|
|
|
|
|
|
IPropertyStorage_Release(pPropStgRead);
|
|
|
|
PropVariantClear(&pvread[0]);
|
|
|
|
PropVariantClear(&pvread[1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Unable to read properties.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Unable to get the IPropertyStorage.\n");
|
|
|
|
}
|
|
|
|
|
2008-08-03 11:18:26 +02:00
|
|
|
CloseHandle(file);
|
|
|
|
if (pszFileName == NULL || fRemember)
|
|
|
|
This->isDirty = FALSE;
|
2008-11-13 07:19:25 +01:00
|
|
|
StartLinkProcessor(pszFileName);
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_FAIL;
|
|
|
|
heap_free(url);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_SaveCompleted(IPersistFile *pFile, LPCOLESTR pszFileName)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p): stub\n", pFile, pszFileName);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistFile_GetCurFile(IPersistFile *pFile, LPOLESTR *ppszFileName)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
InternetShortcut *This = impl_from_IPersistFile(pFile);
|
|
|
|
TRACE("(%p, %p)\n", pFile, ppszFileName);
|
|
|
|
if (This->currentFile == NULL)
|
|
|
|
*ppszFileName = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*ppszFileName = co_strdupW(This->currentFile);
|
|
|
|
if (*ppszFileName == NULL)
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-11-20 04:54:26 +01:00
|
|
|
static HRESULT WINAPI PropertySetStorage_QueryInterface(IPropertySetStorage *iface, REFIID riid, PVOID *ppvObject)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IPropertySetStorage(iface);
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
return Unknown_QueryInterface(This, riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PropertySetStorage_AddRef(IPropertySetStorage *iface)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IPropertySetStorage(iface);
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
return Unknown_AddRef(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PropertySetStorage_Release(IPropertySetStorage *iface)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IPropertySetStorage(iface);
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
return Unknown_Release(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PropertySetStorage_Create(
|
|
|
|
IPropertySetStorage* iface,
|
|
|
|
REFFMTID rfmtid,
|
|
|
|
const CLSID *pclsid,
|
|
|
|
DWORD grfFlags,
|
|
|
|
DWORD grfMode,
|
|
|
|
IPropertyStorage **ppprstg)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IPropertySetStorage(iface);
|
2022-02-11 08:39:53 +01:00
|
|
|
TRACE("(%s, %p, 0x%lx, 0x%lx, %p)\n", debugstr_guid(rfmtid), pclsid, grfFlags, grfMode, ppprstg);
|
2010-11-20 04:54:26 +01:00
|
|
|
|
|
|
|
return IPropertySetStorage_Create(This->property_set_storage,
|
|
|
|
rfmtid,
|
|
|
|
pclsid,
|
|
|
|
grfFlags,
|
|
|
|
grfMode,
|
|
|
|
ppprstg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PropertySetStorage_Open(
|
|
|
|
IPropertySetStorage* iface,
|
|
|
|
REFFMTID rfmtid,
|
|
|
|
DWORD grfMode,
|
|
|
|
IPropertyStorage **ppprstg)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IPropertySetStorage(iface);
|
2022-02-11 08:39:53 +01:00
|
|
|
TRACE("(%s, 0x%lx, %p)\n", debugstr_guid(rfmtid), grfMode, ppprstg);
|
2010-11-20 04:54:26 +01:00
|
|
|
|
|
|
|
/* Note: The |STGM_SHARE_EXCLUSIVE is to cope with a bug in the implementation. Should be fixed in ole32. */
|
|
|
|
return IPropertySetStorage_Open(This->property_set_storage,
|
|
|
|
rfmtid,
|
|
|
|
grfMode|STGM_SHARE_EXCLUSIVE,
|
|
|
|
ppprstg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PropertySetStorage_Delete(IPropertySetStorage *iface, REFFMTID rfmtid)
|
|
|
|
{
|
|
|
|
InternetShortcut *This = impl_from_IPropertySetStorage(iface);
|
|
|
|
TRACE("(%s)\n", debugstr_guid(rfmtid));
|
|
|
|
|
2008-08-03 11:18:26 +02:00
|
|
|
|
2010-11-20 04:54:26 +01:00
|
|
|
return IPropertySetStorage_Delete(This->property_set_storage,
|
|
|
|
rfmtid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PropertySetStorage_Enum(IPropertySetStorage *iface, IEnumSTATPROPSETSTG **ppenum)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", ppenum);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2008-08-03 11:18:26 +02:00
|
|
|
|
|
|
|
static const IUniformResourceLocatorWVtbl uniformResourceLocatorWVtbl = {
|
|
|
|
UniformResourceLocatorW_QueryInterface,
|
|
|
|
UniformResourceLocatorW_AddRef,
|
|
|
|
UniformResourceLocatorW_Release,
|
|
|
|
UniformResourceLocatorW_SetUrl,
|
|
|
|
UniformResourceLocatorW_GetUrl,
|
|
|
|
UniformResourceLocatorW_InvokeCommand
|
|
|
|
};
|
|
|
|
|
|
|
|
static const IUniformResourceLocatorAVtbl uniformResourceLocatorAVtbl = {
|
|
|
|
UniformResourceLocatorA_QueryInterface,
|
|
|
|
UniformResourceLocatorA_AddRef,
|
|
|
|
UniformResourceLocatorA_Release,
|
|
|
|
UniformResourceLocatorA_SetUrl,
|
|
|
|
UniformResourceLocatorA_GetUrl,
|
|
|
|
UniformResourceLocatorA_InvokeCommand
|
|
|
|
};
|
|
|
|
|
|
|
|
static const IPersistFileVtbl persistFileVtbl = {
|
|
|
|
PersistFile_QueryInterface,
|
|
|
|
PersistFile_AddRef,
|
|
|
|
PersistFile_Release,
|
|
|
|
PersistFile_GetClassID,
|
|
|
|
PersistFile_IsDirty,
|
|
|
|
PersistFile_Load,
|
|
|
|
PersistFile_Save,
|
|
|
|
PersistFile_SaveCompleted,
|
|
|
|
PersistFile_GetCurFile
|
|
|
|
};
|
|
|
|
|
2010-11-20 04:54:26 +01:00
|
|
|
static const IPropertySetStorageVtbl propertySetStorageVtbl = {
|
|
|
|
PropertySetStorage_QueryInterface,
|
|
|
|
PropertySetStorage_AddRef,
|
|
|
|
PropertySetStorage_Release,
|
|
|
|
PropertySetStorage_Create,
|
|
|
|
PropertySetStorage_Open,
|
|
|
|
PropertySetStorage_Delete,
|
|
|
|
PropertySetStorage_Enum
|
|
|
|
};
|
|
|
|
|
2010-11-04 23:26:34 +01:00
|
|
|
static InternetShortcut *create_shortcut(void)
|
|
|
|
{
|
|
|
|
InternetShortcut *newshortcut;
|
|
|
|
|
|
|
|
newshortcut = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(InternetShortcut));
|
|
|
|
if (newshortcut)
|
|
|
|
{
|
2010-11-20 04:54:26 +01:00
|
|
|
HRESULT hr;
|
|
|
|
IPropertyStorage *dummy;
|
|
|
|
|
2011-04-08 11:58:00 +02:00
|
|
|
newshortcut->IUniformResourceLocatorA_iface.lpVtbl = &uniformResourceLocatorAVtbl;
|
|
|
|
newshortcut->IUniformResourceLocatorW_iface.lpVtbl = &uniformResourceLocatorWVtbl;
|
|
|
|
newshortcut->IPersistFile_iface.lpVtbl = &persistFileVtbl;
|
2010-11-20 04:54:26 +01:00
|
|
|
newshortcut->IPropertySetStorage_iface.lpVtbl = &propertySetStorageVtbl;
|
2011-07-23 18:40:54 +02:00
|
|
|
newshortcut->refCount = 1;
|
2011-05-26 13:27:55 +02:00
|
|
|
hr = StgCreateStorageEx(NULL, STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_DELETEONRELEASE,
|
|
|
|
STGFMT_STORAGE, 0, NULL, NULL, &IID_IPropertySetStorage, (void **) &newshortcut->property_set_storage);
|
2013-02-06 10:59:50 +01:00
|
|
|
if (FAILED(hr))
|
2010-11-20 04:54:26 +01:00
|
|
|
{
|
|
|
|
TRACE("Failed to create the storage object needed for the shortcut.\n");
|
|
|
|
heap_free(newshortcut);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IPropertySetStorage_Create(newshortcut->property_set_storage, &FMTID_Intshcut, NULL, PROPSETFLAG_DEFAULT, STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &dummy);
|
2013-02-06 10:59:50 +01:00
|
|
|
if (FAILED(hr))
|
2010-11-20 04:54:26 +01:00
|
|
|
{
|
|
|
|
TRACE("Failed to create the property object needed for the shortcut.\n");
|
|
|
|
IPropertySetStorage_Release(newshortcut->property_set_storage);
|
|
|
|
heap_free(newshortcut);
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-07-27 11:00:34 +02:00
|
|
|
IPropertyStorage_Release(dummy);
|
2010-11-04 23:26:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return newshortcut;
|
|
|
|
}
|
|
|
|
|
2011-07-23 18:40:54 +02:00
|
|
|
HRESULT WINAPI InternetShortcut_Create(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
|
2008-08-03 11:18:26 +02:00
|
|
|
{
|
|
|
|
InternetShortcut *This;
|
2011-07-23 18:40:54 +02:00
|
|
|
HRESULT hres;
|
2008-08-03 11:18:26 +02:00
|
|
|
|
2011-07-23 18:40:54 +02:00
|
|
|
TRACE("(%p, %s, %p)\n", outer, debugstr_guid(riid), ppv);
|
2008-08-03 11:18:26 +02:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
2011-07-23 18:40:54 +02:00
|
|
|
if(outer)
|
2008-08-03 11:18:26 +02:00
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2010-11-04 23:26:34 +01:00
|
|
|
This = create_shortcut();
|
2011-07-23 18:40:54 +02:00
|
|
|
if(!This)
|
2008-08-03 11:18:26 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2011-07-23 18:40:54 +02:00
|
|
|
|
|
|
|
hres = Unknown_QueryInterface(This, riid, ppv);
|
|
|
|
Unknown_Release(This);
|
|
|
|
return hres;
|
2008-08-03 11:18:26 +02:00
|
|
|
}
|
2010-11-04 23:26:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2011-07-23 18:40:54 +02:00
|
|
|
* OpenURL (ieframe.@)
|
2010-11-04 23:26:34 +01:00
|
|
|
*/
|
|
|
|
void WINAPI OpenURL(HWND hWnd, HINSTANCE hInst, LPCSTR lpcstrUrl, int nShowCmd)
|
|
|
|
{
|
|
|
|
InternetShortcut *shortcut;
|
|
|
|
WCHAR* urlfilepath = NULL;
|
2011-07-23 18:40:54 +02:00
|
|
|
int len;
|
2010-11-04 23:26:34 +01:00
|
|
|
|
2011-07-23 18:40:54 +02:00
|
|
|
shortcut = create_shortcut();
|
2010-11-04 23:26:34 +01:00
|
|
|
|
2011-07-23 18:40:54 +02:00
|
|
|
if(!shortcut)
|
|
|
|
return;
|
2010-11-04 23:26:34 +01:00
|
|
|
|
2011-07-23 18:40:54 +02:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, lpcstrUrl, -1, NULL, 0);
|
|
|
|
urlfilepath = heap_alloc(len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpcstrUrl, -1, urlfilepath, len);
|
2010-11-04 23:26:34 +01:00
|
|
|
|
2011-07-23 18:40:54 +02:00
|
|
|
if(SUCCEEDED(IPersistFile_Load(&shortcut->IPersistFile_iface, urlfilepath, 0))) {
|
|
|
|
URLINVOKECOMMANDINFOW ici;
|
2010-11-04 23:26:34 +01:00
|
|
|
|
2011-07-23 18:40:54 +02:00
|
|
|
memset( &ici, 0, sizeof ici );
|
|
|
|
ici.dwcbSize = sizeof ici;
|
|
|
|
ici.dwFlags = IURL_INVOKECOMMAND_FL_USE_DEFAULT_VERB;
|
|
|
|
ici.hwndParent = hWnd;
|
2010-11-04 23:26:34 +01:00
|
|
|
|
2011-07-23 18:40:54 +02:00
|
|
|
if(FAILED(UniformResourceLocatorW_InvokeCommand(&shortcut->IUniformResourceLocatorW_iface, (PURLINVOKECOMMANDINFOW) &ici)))
|
|
|
|
TRACE("failed to open URL: %s\n", debugstr_a(lpcstrUrl));
|
2010-11-04 23:26:34 +01:00
|
|
|
}
|
2011-07-23 18:40:54 +02:00
|
|
|
|
|
|
|
heap_free(urlfilepath);
|
|
|
|
Unknown_Release(shortcut);
|
2010-11-04 23:26:34 +01:00
|
|
|
}
|