[HLINK]
authorChristoph von Wittich <christoph_vw@reactos.org>
Sun, 21 Mar 2010 19:28:13 +0000 (19:28 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Sun, 21 Mar 2010 19:28:13 +0000 (19:28 +0000)
sync hlink with wine 1.1.41

svn path=/trunk/; revision=46319

reactos/dll/win32/hlink/browse_ctx.c
reactos/dll/win32/hlink/hlink_main.c
reactos/dll/win32/hlink/link.c

index a5b73c1..1e15c13 100644 (file)
@@ -155,6 +155,9 @@ static HRESULT WINAPI IHlinkBC_SetBrowseWindowInfo(IHlinkBrowseContext* iface,
     HlinkBCImpl  *This = (HlinkBCImpl*)iface;
     TRACE("(%p)->(%p)\n", This, phlbwi);
 
+    if(!phlbwi)
+        return E_INVALIDARG;
+
     heap_free(This->BrowseWindowInfo);
     This->BrowseWindowInfo = heap_alloc(phlbwi->cbSize);
     memcpy(This->BrowseWindowInfo, phlbwi, phlbwi->cbSize);
@@ -165,8 +168,18 @@ static HRESULT WINAPI IHlinkBC_SetBrowseWindowInfo(IHlinkBrowseContext* iface,
 static HRESULT WINAPI IHlinkBC_GetBrowseWindowInfo(IHlinkBrowseContext* iface,
         HLBWINFO *phlbwi)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    HlinkBCImpl  *This = (HlinkBCImpl*)iface;
+    TRACE("(%p)->(%p)\n", This, phlbwi);
+
+    if(!phlbwi)
+        return E_INVALIDARG;
+
+    if(!This->BrowseWindowInfo)
+        phlbwi->cbSize = 0;
+    else
+        memcpy(phlbwi, This->BrowseWindowInfo, This->BrowseWindowInfo->cbSize);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI IHlinkBC_SetInitialHlink(IHlinkBrowseContext* iface,
index d07901a..e96f206 100644 (file)
@@ -99,6 +99,8 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation,
 {
     IHlink *hl = NULL;
     HRESULT r = S_OK;
+    WCHAR *hash, *tgt;
+    const WCHAR *loc;
 
     TRACE("%s %s %s %p %i %p %s %p\n", debugstr_w(pwzTarget),
             debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), pihlsite,
@@ -108,8 +110,44 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation,
     if (FAILED(r))
         return r;
 
-    IHlink_SetStringReference(hl, HLINKSETF_TARGET | HLINKSETF_LOCATION,
-            pwzTarget, pwzLocation);
+    if (pwzTarget)
+    {
+        hash = strchrW(pwzTarget, '#');
+        if (hash)
+        {
+            if (hash == pwzTarget)
+                tgt = NULL;
+            else
+            {
+                int tgt_len = hash - pwzTarget;
+                tgt = heap_alloc((tgt_len + 1) * sizeof(WCHAR));
+                if (!tgt)
+                    return E_OUTOFMEMORY;
+                memcpy(tgt, pwzTarget, tgt_len * sizeof(WCHAR));
+                tgt[tgt_len] = 0;
+            }
+            if (!pwzLocation)
+                loc = hash + 1;
+            else
+                loc = pwzLocation;
+        }
+        else
+        {
+            tgt = hlink_strdupW(pwzTarget);
+            if (!tgt)
+                return E_OUTOFMEMORY;
+            loc = pwzLocation;
+        }
+    }
+    else
+    {
+        tgt = NULL;
+        loc = pwzLocation;
+    }
+
+    IHlink_SetStringReference(hl, HLINKSETF_TARGET | HLINKSETF_LOCATION, tgt, loc);
+
+    heap_free(tgt);
 
     if (pwzFriendlyName)
         IHlink_SetFriendlyName(hl, pwzFriendlyName);
index 52197cc..ffd3cda 100644 (file)
@@ -291,7 +291,9 @@ static HRESULT WINAPI IHlink_fnSetStringReference(IHlink* iface,
     if (grfHLSETF & HLINKSETF_LOCATION)
     {
         heap_free(This->Location);
-        This->Location = hlink_strdupW( pwzLocation );
+        This->Location = NULL;
+        if (pwzLocation && *pwzLocation)
+            This->Location = hlink_strdupW( pwzLocation );
     }
 
     return S_OK;