Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than mpr, prefix the name with the module name and a period.
WNetCancelConnection2 (mpr)
.
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 Long, ByVal fForce As Long) As Long
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 Long, _
ByVal fForce As Long) As Long
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!
dwFlags Values (C#)
public const int CONNECT_UPDATE_PROFILE = 0x00000001;
public const int CONNECT_UPDATE_RECENT = 0x00000002;
public const int CONNECT_TEMPORARY = 0x00000004;
public const int CONNECT_INTERACTIVE = 0x00000008;
public const int CONNECT_PROMPT = 0x00000010;
public const int CONNECT_REDIRECT = 0x00000080;
public const int CONNECT_CURRENT_MEDIA = 0x00000200;
public const int CONNECT_COMMANDLINE = 0x00000800;
public const int CONNECT_CMD_SAVECRED = 0x00001000;
public const int CONNECT_CRED_RESET = 0x00002000;
Alternative Managed API:
Do you know one? Please contribute it!
The WNetCancelConnection2 function cancels an existing network connection. You can also call the function to remove remembered network connections that are not currently connected.
7/14/2012 3:07:47 AM - -99.178.174.198
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).