https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cf0112a6e6ce8f2a576c840f04964aecbff04f23

commit cf0112a6e6ce8f2a576c840f04964aecbff04f23
Author:     Pierre Schweitzer <[email protected]>
AuthorDate: Tue Sep 11 08:08:56 2018 +0200
Commit:     Pierre Schweitzer <[email protected]>
CommitDate: Tue Sep 11 08:30:23 2018 +0200

    [MPR] Implement WNetClearConnections()
    
    This has been submitted upstream.
    
    CORE-15012
---
 dll/win32/mpr/mpr.spec |  1 +
 dll/win32/mpr/wnet.c   | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)

diff --git a/dll/win32/mpr/mpr.spec b/dll/win32/mpr/mpr.spec
index ec17ebdb24..b75900bafd 100644
--- a/dll/win32/mpr/mpr.spec
+++ b/dll/win32/mpr/mpr.spec
@@ -55,6 +55,7 @@
 @ stdcall WNetCancelConnection2W(wstr long long)
 @ stdcall WNetCancelConnectionA(str long)
 @ stdcall WNetCancelConnectionW(wstr long)
+@ stdcall WNetClearConnections(long)
 @ stdcall WNetCloseEnum(long)
 @ stdcall WNetConnectionDialog1A(ptr)
 @ stdcall WNetConnectionDialog1W(ptr)
diff --git a/dll/win32/mpr/wnet.c b/dll/win32/mpr/wnet.c
index 82c9302849..75d6aef987 100644
--- a/dll/win32/mpr/wnet.c
+++ b/dll/win32/mpr/wnet.c
@@ -2646,6 +2646,64 @@ DWORD WINAPI WNetGetUniversalNameW ( LPCWSTR 
lpLocalPath, DWORD dwInfoLevel,
     return err;
 }
 
+#ifdef __REACTOS__
+/*****************************************************************
+ * WNetClearConnections [MPR.@]
+ */
+DWORD WINAPI WNetClearConnections ( DWORD unknown )
+{
+    HANDLE connected;
+    DWORD ret, size, count;
+    NETRESOURCEW * resources, * iter;
+
+    ret = WNetOpenEnumW(RESOURCE_CONNECTED, RESOURCETYPE_ANY, 0, NULL, 
&connected);
+    if (ret != WN_SUCCESS)
+    {
+        if (ret != WN_NO_NETWORK)
+        {
+            return ret;
+        }
+
+        /* Means no provider, then, clearing is OK */
+        return WN_SUCCESS;
+    }
+
+    size = 0x1000;
+    resources = HeapAlloc(GetProcessHeap(), 0, size);
+    if (!resources)
+    {
+        WNetCloseEnum(connected);
+        return WN_OUT_OF_MEMORY;
+    }
+
+    do
+    {
+        size = 0x1000;
+        count = -1;
+
+        memset(resources, 0, size);
+        ret = WNetEnumResourceW(connected, &count, resources, &size);
+        if (ret == WN_SUCCESS || ret == WN_MORE_DATA)
+        {
+            iter = resources;
+            for (; count; count--)
+            {
+                WNetCancelConnection2W(iter->lpLocalName, 0, TRUE);
+
+                iter++;
+            }
+        }
+        else
+            break;
+    } while (ret != WN_NO_MORE_ENTRIES);
+
+    HeapFree(GetProcessHeap(), 0, resources);
+    WNetCloseEnum(connected);
+
+    return ret;
+}
+#endif
+
 
 
 /*

Reply via email to