[MPR] Import Wine commit: 773ff2e83b0547540639c6d4aeb9f817b621fb2f
authorPierre Schweitzer <pierre@reactos.org>
Thu, 6 Dec 2018 21:44:43 +0000 (22:44 +0100)
committerPierre Schweitzer <pierre@reactos.org>
Thu, 6 Dec 2018 21:44:43 +0000 (22:44 +0100)
Implement support for deleting persistent connections.

dll/win32/mpr/wnet.c

index b16ec98..bc492c2 100644 (file)
@@ -2298,37 +2298,23 @@ DWORD WINAPI WNetCancelConnection2W( LPCWSTR lpName, DWORD dwFlags, BOOL fForce
             }
         }
     }
-#ifdef __REACTOS__
 
-    if (dwFlags & CONNECT_UPDATE_PROFILE)
+    if (ret == WN_SUCCESS && dwFlags & CONNECT_UPDATE_PROFILE)
     {
         HKEY user_profile;
-        WCHAR *coma = strchrW(lpName, ':');
 
-        if (coma && RegOpenCurrentUser(KEY_ALL_ACCESS, &user_profile) == ERROR_SUCCESS)
+        /* FIXME: Only remove it if that's a drive letter */
+        if (isalphaW(lpName[0]) && lpName[1] == ':' &&
+            RegOpenCurrentUser(KEY_ALL_ACCESS, &user_profile) == ERROR_SUCCESS)
         {
-            WCHAR  *subkey;
-            DWORD len;
-
-            len = (ULONG_PTR)coma - (ULONG_PTR)lpName + sizeof(L"Network\\");
-            subkey = HeapAlloc(GetProcessHeap(), 0, len);
-            if (subkey)
-            {
-                strcpyW(subkey, L"Network\\");
-                memcpy(subkey + (sizeof(L"Network\\") / sizeof(WCHAR)) - 1, lpName, (ULONG_PTR)coma - (ULONG_PTR)lpName);
-                subkey[len / sizeof(WCHAR) - 1] = 0;
+            WCHAR subkey[10] = {'N', 'e', 't', 'w', 'o', 'r', 'k', '\\', lpName[0], 0};
 
-                TRACE("Removing: %S\n", subkey);
-
-                RegDeleteKeyW(user_profile, subkey);
-                HeapFree(GetProcessHeap(), 0, subkey);
-            }
+            RegDeleteKeyW(user_profile, subkey);
 
             RegCloseKey(user_profile);
         }
     }
 
-#endif
     return ret;
 }