From 44f929fc25ade04e0f38203fa7c8f6c9ca8f0de8 Mon Sep 17 00:00:00 2001 From: Andrew Bogott Date: Thu, 4 Nov 2010 17:25:09 -0500 Subject: [PATCH] shdocvw: Implement UniformResourceLocatorW_InvokeCommand and UniformResourceLocatorA_InvokeCommand for the default verb. --- dlls/shdocvw/intshcut.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/dlls/shdocvw/intshcut.c b/dlls/shdocvw/intshcut.c index 8c17873453a..2f1cad81d80 100644 --- a/dlls/shdocvw/intshcut.c +++ b/dlls/shdocvw/intshcut.c @@ -32,6 +32,8 @@ #include "objidl.h" #include "shobjidl.h" #include "intshcut.h" +#include "shellapi.h" +#include "winreg.h" WINE_DEFAULT_DEBUG_CHANNEL(shdocvw); @@ -237,8 +239,47 @@ static HRESULT WINAPI UniformResourceLocatorW_GetUrl(IUniformResourceLocatorW *u static HRESULT WINAPI UniformResourceLocatorW_InvokeCommand(IUniformResourceLocatorW *url, PURLINVOKECOMMANDINFOW pCommandInfo) { - FIXME("(%p, %p): stub\n", url, pCommandInfo); - return E_NOTIMPL; + 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; + } + + hres = CoInternetParseUrl(This->url, PARSE_SCHEMA, 0, app, sizeof(app)/sizeof(WCHAR), NULL, 0); + 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; } static HRESULT WINAPI UniformResourceLocatorA_QueryInterface(IUniformResourceLocatorA *url, REFIID riid, PVOID *ppvObject) @@ -299,8 +340,26 @@ static HRESULT WINAPI UniformResourceLocatorA_GetUrl(IUniformResourceLocatorA *u static HRESULT WINAPI UniformResourceLocatorA_InvokeCommand(IUniformResourceLocatorA *url, PURLINVOKECOMMANDINFOA pCommandInfo) { - FIXME("(%p, %p): stub\n", url, pCommandInfo); - return E_NOTIMPL; + 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; + + res = UniformResourceLocatorW_InvokeCommand(&This->uniformResourceLocatorW, &wideCommandInfo); + heap_free(wideVerb); + + return res; } static HRESULT WINAPI PersistFile_QueryInterface(IPersistFile *pFile, REFIID riid, PVOID *ppvObject) -- 2.11.4.GIT