Pierre Schweitzer : mpr: Implement WNetClearConnections().
Alexandre Julliard
julliard at winehq.org
Thu Sep 13 15:14:48 CDT 2018
Module: wine
Branch: master
Commit: 0799550075654094a3bed080aac722b9bea01307
URL: https://source.winehq.org/git/wine.git/?a=commit;h=0799550075654094a3bed080aac722b9bea01307
Author: Pierre Schweitzer <pierre at reactos.org>
Date: Sun Sep 9 15:48:00 2018 +0200
mpr: Implement WNetClearConnections().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45802
Signed-off-by: Pierre Schweitzer <pierre at reactos.org>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mpr/mpr.spec | 1 +
dlls/mpr/wnet.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/dlls/mpr/mpr.spec b/dlls/mpr/mpr.spec
index 4df3db3..2f102ab 100644
--- a/dlls/mpr/mpr.spec
+++ b/dlls/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/dlls/mpr/wnet.c b/dlls/mpr/wnet.c
index a2f8a04..8d83bd6 100644
--- a/dlls/mpr/wnet.c
+++ b/dlls/mpr/wnet.c
@@ -4,7 +4,7 @@
* Copyright 1999 Ulrich Weigand
* Copyright 2004 Juan Lang
* Copyright 2007 Maarten Lankhorst
- * Copyright 2016 Pierre Schweitzer
+ * Copyright 2016-2018 Pierre Schweitzer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -2407,6 +2407,56 @@ DWORD WINAPI WNetGetUniversalNameW ( LPCWSTR lpLocalPath, DWORD dwInfoLevel,
return err;
}
+/*****************************************************************
+ * WNetClearConnections [MPR.@]
+ */
+DWORD WINAPI WNetClearConnections ( HWND owner )
+{
+ 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;
+ }
+
+ for (;;)
+ {
+ size = 0x1000;
+ count = -1;
+
+ memset(resources, 0, size);
+ ret = WNetEnumResourceW(connected, &count, resources, &size);
+ if (ret == WN_SUCCESS || ret == WN_MORE_DATA)
+ {
+ for (iter = resources; count; count--, iter++)
+ WNetCancelConnection2W(iter->lpLocalName, 0, TRUE);
+ }
+ else
+ break;
+ }
+
+ HeapFree(GetProcessHeap(), 0, resources);
+ WNetCloseEnum(connected);
+
+ return ret;
+}
/*
More information about the wine-cvs
mailing list