Implement UniformResourceLocatorW_InvokeCommand and UniformResourceLocatorA_InvokeCommand for the default verb.

Andrew Bogott andrew at CodeWeavers.com
Thu Nov 4 17:25:09 CDT 2010


---
 dlls/shdocvw/intshcut.c |   69 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 65 insertions(+), 4 deletions(-)

diff --git a/dlls/shdocvw/intshcut.c b/dlls/shdocvw/intshcut.c
index 8c17873..6484de1 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,28 @@ 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 = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+    MultiByteToWideChar(CP_ACP, 0, pCommandInfo->pcszVerb, -1, wideVerb, len);
+
+    wideCommandInfo.pcszVerb = wideVerb;
+
+    res = UniformResourceLocatorW_InvokeCommand(&This->uniformResourceLocatorW, &wideCommandInfo);
+
+    if (wideVerb)
+        heap_free(wideVerb);
+
+    return res;
 }
 
 static HRESULT WINAPI PersistFile_QueryInterface(IPersistFile *pFile, REFIID riid, PVOID *ppvObject)
-- 
1.6.5


--------------000306040508040605060707--



More information about the wine-patches mailing list