You can also use the WNetCancelConnection2 function to terminate a network connection.
const UInt32 USE_NOFORCE = 0;
const UInt32 USE_FORCE = 1;
const UInt32 USE_LOTS_OF_FORCE = 2;
[DllImport("NetApi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern UInt32 NetUseDel(
string UncServerName,
string UseName,
UInt32 ForceCond
);
Declare Function NetUseDel Lib "netapi32.dll" (TODO) As TODO
None.
Do you know one? Please contribute it!
None.
Please add some!
var returnCode = NetUseDel(null, @"\\server\c$", USE_NOFORCE);
if (returnCode != 0)
{
throw new Win32Exception((int)returnCode);
}