Delete saved connection on disconnection if asked (even though the resource wasn't connected).
This allows net use to properly remove connections it may have created.

CORE-11757

svn path=/trunk/; revision=73092
This commit is contained in:
Pierre Schweitzer 2016-10-31 21:20:32 +00:00
parent c397981db2
commit fdc18e536d
2 changed files with 71 additions and 2 deletions

View file

@ -113,7 +113,45 @@ Index: wnet.c
return ret;
}
@@ -2188,6 +2221,7 @@
@@ -2061,6 +2094,37 @@
}
}
}
+#ifdef __REACTOS__
+
+ if (dwFlags & CONNECT_UPDATE_PROFILE)
+ {
+ HKEY user_profile;
+ WCHAR *coma = strchrW(lpName, ':');
+
+ if (coma && 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;
+
+ TRACE("Removing: %S\n", subkey);
+
+ RegDeleteKeyW(user_profile, subkey);
+ HeapFree(GetProcessHeap(), 0, subkey);
+ }
+
+ RegCloseKey(user_profile);
+ }
+ }
+
+#endif
return ret;
}
@@ -2188,6 +2252,7 @@
/* find the network connection for a given drive; helper for WNetGetConnection */
static DWORD get_drive_connection( WCHAR letter, LPWSTR remote, LPDWORD size )
{
@ -121,7 +159,7 @@ Index: wnet.c
char buffer[1024];
struct mountmgr_unix_drive *data = (struct mountmgr_unix_drive *)buffer;
HANDLE mgr;
@@ -2230,6 +2264,32 @@
@@ -2230,6 +2295,32 @@
}
CloseHandle( mgr );
return ret;

View file

@ -2094,6 +2094,37 @@ DWORD WINAPI WNetCancelConnection2W( LPCWSTR lpName, DWORD dwFlags, BOOL fForce
}
}
}
#ifdef __REACTOS__
if (dwFlags & CONNECT_UPDATE_PROFILE)
{
HKEY user_profile;
WCHAR *coma = strchrW(lpName, ':');
if (coma && 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;
TRACE("Removing: %S\n", subkey);
RegDeleteKeyW(user_profile, subkey);
HeapFree(GetProcessHeap(), 0, subkey);
}
RegCloseKey(user_profile);
}
}
#endif
return ret;
}