@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: The WNetCancelConnection2 function cancels an existing network connection. You can also call the function to remove remembered network connections that are not currently connected. !!!!C# Signature: [DllImport("mpr.dll")] static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool bForce); !!!!VB Signature: Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Integer, ByVal fForce As Integer) As Integer !!!!Notes: !!!!VB SIG ''' <summary> ''' The WNetCancelConnection2 function cancels an existing network connection. ''' You can also call the function to remove remembered network connections that are not currently connected. ''' </summary> ''' <param name="lpName"></param> ''' <param name="dwFlags"></param> ''' <param name="fForce"></param> ''' <returns></returns> ''' <remarks></remarks> <DllImport("mpr.dll")> _ Private Shared Function WNetCancelConnection2(ByVal lpName As String, _ ByVal dwFlags As Integer, _ ByVal fForce As Integer) As Integer End Function !!!!Tips & Tricks: The system updates the user profile with the information that the connection is no longer a persistent one if you pass this constant as <dwFlags> private const int CONNECT_UPDATE_PROFILE = 0x1; !!!!Sample Code: [DllImport("mpr.dll")] public static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool fForce); private const int CONNECT_UPDATE_PROFILE = 0x1; private const int NO_ERROR = 0; int result=WNetCancelConnection2("Y:", CONNECT_UPDATE_PROFILE, true); if (result != NO_ERROR) { //handle error } !!!!Alternative Managed API: Do you know one? Please contribute it! > Do not use Long as the param data types as shown previously on this page, use Integers. Documentation: WNetCancelConnection2@msdn on MSDN
Edit mpr.WNetCancelCon...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.