Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "connect" in [All]

iphlpapi

.

        IF_TYPE_FRAMERELAY_INTERCONNECT = 58,  // Obsolete, use 32 or 44

.

        IF_TYPE_ESCON = 73,  // IBM Enterprise Systems Connection

.

        IF_TYPE_PROP_CNLS = 89,  // Proprietary Connectionless Proto

.

        IF_TYPE_FRAMERELAY_MPI = 92,  // Multiproto Interconnect over FR

.

    public enum NET_IF_CONNECTION_TYPE : uint

.

        NET_IF_CONNECTION_DEDICATED = 1,

.

        NET_IF_CONNECTION_PASSIVE = 2,

.

        NET_IF_CONNECTION_DEMAND = 3,

.

        NET_IF_CONNECTION_MAXIMUM = 4

.

        public NET_IF_CONNECTION_TYPE ConnectionType;

.

public static List<MIB_TCPROW_OWNER_PID> GetAllTCPConnections()

.

    return GetTCPConnections<MIB_TCPROW_OWNER_PID, MIB_TCPTABLE_OWNER_PID>(AF_INET);

.

public static List<MIB_TCP6ROW_OWNER_PID> GetAllTCPv6Connections()

.

    return GetTCPConnections<MIB_TCP6ROW_OWNER_PID, MIB_TCP6TABLE_OWNER_PID>(AF_INET6);

.

private static List<IPR> GetTCPConnections<IPR, IPT>(int ipVersion)//IPR = Row Type, IPT = Table Type

.

public MIB_TCPROW_OWNER_PID[] GetAllTcpConnections()

.

      TCP_TABLE_BASIC_CONNECTIONS,

.

      TCP_TABLE_OWNER_PID_CONNECTIONS,

.

      TCP_TABLE_OWNER_MODULE_CONNECTIONS,

.

      public List<MIB_TCPROW_OWNER_PID> GetAllTCPv4Connections() {

.

          return GetTCPConnections<MIB_TCPROW_OWNER_PID, MIB_TCPTABLE_OWNER_PID>(AF_INET);

.

      public List<MIB_TCP6ROW_OWNER_PID> GetAllTCPv6Connections() {

.

          return GetTCPConnections<MIB_TCP6ROW_OWNER_PID, MIB_TCP6TABLE_OWNER_PID>(AF_INET6);

.

      public List<IPR> GetTCPConnections<IPR, IPT>(int ipVersion) { //IPR = Row Type, IPT = Table Type

.

    $y=$x.GetAllTCPv4Connections()

.

    /// MIB_IFROW structure array. Content the active networks connection

coredll

.
NOTIFICATION_EVENT_RS232_DETECTED When an RS232 connection is made. 9
.

NOTIFICATION_EVENT_RS232_DETECTED is also raised when connecting the device to USB.

.
Summary
Enumerate through the active RAS connections (GPRS, dialup, etc) on Windows Mobile device
.

    private static extern uint RasEnumConnections(

.

        [Out] out int connections);

.

public static RASCONN[] GetAllConnections()

.

        RASCONN[] allConnections = tempConn;

.

        int lpcConnections = 0;

.

        uint ret = RasEnumConnections(tempConn, ref lpcb, out lpcConnections);

.

        // first call returned that there are more than one connections

.

        allConnections = new RASCONN[lpcb / Marshal.SizeOf(typeof(RASCONN))];

.

        allConnections[0] = tempConn[0];

.

        ret = RasEnumConnections(allConnections, ref lpcb, out lpcConnections);

.

        if (lpcConnections > allConnections.Length)

.

        throw new Exception("RAS: error retrieving correct connection count");

.

        else if (lpcConnections == 0)

.

        allConnections = new RASCONN[0];

.

        return allConnections;

.
Documentation
RasEnumConnections @msdn on MSDN
.

    internal static extern UInt32 RasEnumConnections([In, Out] _RASCONN[] lprasconn, ref UInt32 lpcb, ref UInt32 lpcConnections);

.

        public IntPtr ConnectionHandle { get { return m_hrasconn; } }

.

    public static _RASCONN[] EnumerateConnections()

.

        if (RasEnumConnections(rasconn, ref size, ref noelements) != 0x00)

.

            if (RasEnumConnections(rasconn, ref size, ref noelements) != 0x00) { rasconn = null; }

.
Summary
This function retrieves information on the current status of the specified remote access connection
.

public static extern int RasGetConnectStatus(IntPtr hrasconn, ref RASCONNSTATUS lprasconnstatus);

.

        RASCS_ConnectDevice,

.

        RASCS_DeviceConnected,

.

        RASCS_AllDevicesConnected,

.

        RASCS_Connected = RASCS_DONE,

.

        RASCS_Disconnected

.

    public static RASCONNSTATUS GetConnectStatus(IntPtr hrasconn)

.

        RasGetConnectStatus(hrasconn, ref status);

.
Documentation
[RasGetConnectStatus] on MSDN
.
Summary
Disconnect a RAS connection
.

Use this function together with RasEnumConnections, to return a list of the active connections, then the sample code below will loop through the RASCONN[] array and close each one.

.

public static void CloseAllConnections()

.

        RASCONN[] connections = GetAllConnections();

.

        for (int i = 0; i < connections.Length; ++i)

.

        RasHangUp(connections[i].hrasconn);

aygshell

.

Microsoft.SmartDevice.Connectivity.Device.ProvisionDevice(string, Device.ConfigActions), although it is a desktop managed method and only works remotely, whereas this P/Invoke can be executed directly on the device.

odbccp32

.

    vAttributes &= "Trusted_Connection=Yes" & Convert.ToChar(0)

.

This function persists a system data source with the provided name and connection string. Remember to add your own error checking mechanisms.

.

    // Connection string for SQLConfigDataSource must be null-

.

This function persists a system data source with the provided name and connection string. Remember to add your own error checking mechanisms.

.

    // Connection string for SQLConfigDataSource must be null-

winfax

.
Summary
Connects a fax client application to the local fax server.
.

static extern bool FaxConnectFaxServer (string MachineName, out IntPtr FaxHandle);

.

Declare Function FaxConnectFaxServer Lib "winfax.dll" (TODO) As TODO

.
Documentation
[FaxConnectFaxServer] on MSDN
.
Summary
Enumerates all queued and active fax jobs on the fax server to which the client has connected.
.
Summary
Enumerates all fax devices currently attached to the fax server to which the client has connected.

wlanapi

.

        byte *connectionData = null;

.

        uint sizeConnectionData = 0;

.

        UInt32 result = EapHostPeerInvokeConfigUI(handle, 0, method, 0, null, &sizeConnectionData, &connectionData, ref er);

.

        MessageBox.Show(sizeConnectionData+"jfdgkj");

.

        output = new byte[sizeConnectionData];

.

        for (int i = 0; i < sizeConnectionData; i++)

.

            output[i] = *connectionData;

.

            //MessageBox.Show(*connectionData+" value"+i);

.

            connectionData++;

.

public static extern uint WlanConnect(IntPtr hClientHandle,ref Guid pInterfaceGuid,ref WLAN_CONNECTION_PARAMETERS pConnectionParameters,IntPtr pReserved);

.

Declare Function WlanConnect Lib "wlanapi.dll" (ByVal hClientHandle As IntPtr, _

.

                         ByRef pConnectionParameters As WLAN_CONNECTION_PARAMETERS, _

.

WLAN_CONNECTION_PARAMETERS

.

WLAN_CONNECTION_PARAMETERS wlanConnectionParameters = new WLAN_CONNECTION_PARAMETERS();

.

wlanConnectionParameters.dot11BssType = DOT11_BSS_TYPE.dot11_BSS_type_any;

.

wlanConnectionParameters.dwFlags = 0;

.

wlanConnectionParameters.strProfile = "dlink";

.

wlanConnectionParameters.wlanConnectionMode = WLAN_CONNECTION_MODE.wlan_connection_mode_profile;

.

WlanConnect(ClientHandle,ref pInterfaceGuid,ref wlanConnectionParameters ,new IntPtr());

.

Dim wlanConnectionParameters As New WLAN_CONNECTION_PARAMETERS

.

wlanConnectionParameters.dot11BssType = DOT11_BSS_TYPE.dot11_BSS_type_any

.

wlanConnectionParameters.dwFlags = 0

.

wlanConnectionParameters.strProfile = "dlink"

.

wlanConnectionParameters.wlanConnectionMode = WLAN_CONNECTION_MODE.wlan_connection_mode_profile

.

WlanConnect(ClientHandle, pInterfaceGuid, wlanConnectionParameters, IntPtr.Zero)

.
Documentation
[WlanConnect] on MSDN
.

public static extern uint  WlanDisconnect(IntPtr hClientHandle,ref Guid pInterfaceGuid,IntPtr pReserved);

.

Declare Function WlanDisconnect Lib "wlanapi.dll" (TODO) As TODO

.
Documentation
[WlanDisconnect] on MSDN
.

WLAN_CONNECTION_ATTRIBUTES

.

        WLAN_CONNECTION_ATTRIBUTES connection;

.

            if (WlanQueryInterface(handle, ref guid, WLAN_INTF_OPCODE.wlan_intf_opcode_current_connection, IntPtr.Zero, out dataSize, ref ptr, IntPtr.Zero) != 0)

.

            connection = (WLAN_CONNECTION_ATTRIBUTES)Marshal.PtrToStructure(ptr, typeof(WLAN_CONNECTION_ATTRIBUTES));

.

            // Do something here with the connection info....    

.

     Dim connection As WLAN_CONNECTION_ATTRIBUTES

.

         If WlanQueryInterface(handle, guid, WLAN_INTF_OPCODE.wlan_intf_opcode_current_connection, IntPtr.Zero, dataSize, ptr, _

.

         connection = DirectCast(Marshal.PtrToStructure(ptr, GetType(WLAN_CONNECTION_ATTRIBUTES)), WLAN_CONNECTION_ATTRIBUTES)

.

         ' Do something here with the connection info....

kernel32

.
Summary
.

static extern bool ConnectNamedPipe(IntPtr hNamedPipe,

.

Good example of named pipes using ConnectNamedPipe() can be found at http://wyday.com/blog/2010/multi-process-c-sharp-application-like-google-chrome-using-named-pipes/

.
Documentation
[ConnectNamedPipe] on MSDN
.

    ///         2. Call Listen().  This will block until a client connects.  Sorry, the alternatives

.

    ///         3. Call DataAvailable() in a loop with Read(), Write, ReadLine(), etc. until IsConnected turns false.

.

    private static extern bool DisconnectNamedPipe(

.

    private static extern bool ConnectNamedPipe(

.

    /// Waits indefinitely when connecting to a pipe.

.

    private const ulong ERROR_PIPE_CONNECTED = 535;

.

    /// Server only: block until client connects

.

        DisconnectNamedPipe(_handle);

.

        if (ConnectNamedPipe(_handle, IntPtr.Zero) != true)

.

        if (lastErr == ERROR_PIPE_CONNECTED)

.

    /// Server only: disconnect the pipe.  For most applications, you should just call Listen()

.

    /// instead, which automatically does a disconnect of any old connection.

.

    public void Disconnect()

.

        throw new Exception("Disconnect() is only for server-side streams");

.

        DisconnectNamedPipe(_handle);

.

    /// Returns true if client is connected.  Should only be called after Listen() succeeds.

.

    public bool IsConnected

.

            throw new Exception("IsConnected() is only for server-side streams");

.

        if (ConnectNamedPipe(_handle, IntPtr.Zero) == false)

.

            if ((uint)Marshal.GetLastWin32Error() == ERROR_PIPE_CONNECTED)

.

            } while (stream.IsConnected);

.
Summary
.

static extern bool DisconnectNamedPipe(IntPtr hNamedPipe);

.
Documentation
[DisconnectNamedPipe] on MSDN

setupapi

.

MsgBox “Device not connected”

rasapi32

.
Summary
The RasDialDlg function establishes a RAS connection using a specified phone-book entry and the credentials of the logged-on user. The function displays a stream of dialog boxes that indicate the state of the connection operation.
.

bool ret = RAW.RasDialDlg(IntPtr.Zero, "Some Connection Name", IntPtr.Zero, ref info);

.
Summary
The RasDialDlg function establishes a RAS connection using a specified phone-book entry and the credentials of the logged-on user. The function displays a stream of dialog boxes that indicate the state of the connection operation.
.

bool ret = RAW.RasDialDlg(IntPtr.Zero, "Some Connection Name", IntPtr.Zero, ref info);

.

public static extern int RasEnumConnections(

.

    [Out] out int connections);

.

RAW.RASCONN[] connections = new RAW.RASCONN[1];

.

connections[0].dwSize = Marshal.SizeOf(typeof(RAW.RASCONN));

.

int connectionsCount = 0;

.

int nRet = RAW.RasEnumConnections(connections, ref cb, out connectionsCount);

.

if (connectionsCount == 0)

.

connections = new RAW.RASCONN[connectionsCount];

.

for (int i = 0; i < connections.Length; i++)

.

    connections[i].dwSize = Marshal.SizeOf(typeof(RAW.RASCONN));

.

nRet = RAW.RasEnumConnections(connections, ref cb, out connectionsCount);

.

int cb = 0, connectionCount;

.

if (RAW.RasEnumConnections(null, ref cb, out connectionCount) == RAW.ERROR_BUFFER_TOO_SMALL)

.

    if (connectionCount == 0) return;

.

    if (RasApi.RasEnumConnections(buffer, ref cb, out conns) == RAW.ERROR_SUCCESS)

.
Documentation
[RasEnumConnections] on MSDN
.
Summary
Retrieves accumulated connection statistics for a connection
.

static extern uint RasGetConnectionStatistics(IntPtr hRasConn, ref RAS_STATS lpStatistics);

.

Public Shared Function RasGetConnectionStatistics( _

.

uint retVal = RasGetConnectionStatistics(rasConnectionHandle, ref statistics);

.
Documentation
[RasGetConnectionStatistics] on MSDN
.

public static extern int RasGetConnectStatus(int hrasconn, ref RASCONNSTATUS lprasconnstatus);

.

Declare Function RasGetConnectStatus Lib "rasapi32.dll" (TODO) As TODO

.
Documentation
[RasGetConnectStatus] on MSDN
.
Summary
The RasGetEntryDialParams function retrieves the connection information saved by the last successful call to the RasDial or RasSetEntryDialParams function for a specified phone-book entry.
.
Summary
The RasHangUp function terminates a remote access connection. The connection is specified with a RAS connection handle. The function releases all RASAPI32.DLL resources associated with the handle
.
Summary
The RasSetEntryProperties function changes the connection information for an entry in the phone book or creates a new phone-book entry.
.

/// Changes the connection information for an entry in the phone book or creates a new phone-book entry.

.

/// <param name="lpRasEntry">Pointer to the RASENTRY structure that specifies the connection data to associate with the phone-book entry.</param>

.

          public int       dwIdleDisconnectSeconds;

.

        ReconnectIfDropped = 0x100,

.

/// Create or modify network connection.

.

/// <param name="connectionName">Name of the network connection to create or modify.</param>

.

/// <param name="rasEntryStructure">RASENTRY structure containing connection settings.</param>

.

public static RasError SetEntryProperties(string connectionName, RASENTRY rasEntryStructure)

.

     return (RasError)RasSetEntryProperties(null, connectionName, ref rasEntryStructure, Marshal.SizeOf(rasEntryStructure), IntPtr.Zero, 0);

user32

.
Summary
.

static extern IntPtr DdeConnect(uint idInst, IntPtr hszService,

.

IntPtr handle = DdeConnect(instanceId, serviceHandle, topicHandle, IntPtr.Zero);

.
Documentation
[DdeConnect] on MSDN
.
Summary
.

static extern IntPtr DdeReconnect(IntPtr hConv);

.
Documentation
[DdeReconnect] on MSDN

winspool

.
Summary
.

    internal static extern bool AddPrinterConnection(String pszBuffer);

.

Declare Function AddPrinterConnection Lib "winspool.dll" (TODO) As TODO

.
Documentation
[AddPrinterConnection] on MSDN
.
Summary
.

    internal static extern bool AddPrinterConnection(String pszBuffer);

.

Declare Function AddPrinterConnection Lib "winspool.dll" (TODO) As TODO

.
Documentation
[AddPrinterConnection] on MSDN
.
Summary
Closes a printer connection given a handle
.
Summary
DeletePrinterConnection - disconnect / remove client connection to a shared printer
.

internal static extern bool DeletePrinterConnection(String pName);

.

Declare Function DeletePrinterConnection Lib "winspool.dll" (TODO) As TODO

.

result = DeletePrinterConnection("\\\\Server_Name\\Printer_Share");

.
Documentation
[DeletePrinterConnection] on MSDN

secur32

.

        public const int ISC_REQ_CONNECTION     =    0x00000800;

.

        public const int STANDARD_CONTEXT_ATTRIBUTES = ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_CONNECTION;

.

    /// <param name="LsaHandle">[in] Handle obtained from a previous call to LsaRegisterLogonProcess or LsaConnectUntrusted.</param>

.
Summary
The LsaConnectUntrusted function establishes an untrusted connection to the LSA server.
.

public static extern WinStatusCodes LsaConnectUntrusted([Out] out IntPtr LsaHandle);

.

Declare Function LsaConnectUntrusted Lib "secur32.dll" (TODO) As TODO

.
Documentation
[LsaConnectUntrusted] on MSDN
.
Summary
The LsaDeregisterLogonProcess function deletes the caller's logon application context and closes the connection to the LSA server.
.

    NewCredentials,     // Allows the caller to clone its current token and specify new credentials for outbound connections.

.

                public static extern WinStatusCodes LsaConnectUntrusted([Out] out IntPtr LsaHandle);

.

                        OSCalls.WinStatusCodes status = OSCalls.LsaConnectUntrusted(out lsaHandle);

mpr

.
Summary
The MultinetGetConnectionPerformance function returns information about the expected performance of a connection used to access a network resource.
.

    static extern int MultinetGetConnectionPerformance(

.

        ref NetConnectInfoStruct lpNetConnectInfoStruct);

.

    public struct NetConnectInfoStruct {

.

        /// In the absence of information about the actual connection,

.

        /// the current connection with the resource, with any routing

.

        /// The connection is not being routed.

.

        /// If this flag is not set, the connection may be going through

.

        /// The connection is over a medium that is typically slow (for

.

        NetConnectInfoStruct ci = new NetConnectInfoStruct();

.
Documentation
[MultinetGetConnectionPerformance] on MSDN
.
Summary
.

        RESOURCE_CONNECTED = 1,

.

        RESOURCEUSAGE_CONNECTABLE = 0x00000001,

.

        RESOURCEUSAGE_ALL = (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED),

.

    public enum ResourceConnection

.

        CONNECT_UPDATE_PROFILE = 1,

.

        CONNECT_UPDATE_RECENT = 2,

.

        CONNECT_TEMPORARY = 4,

.

        CONNECT_INTERACTIVE = 8,

.

        CONNECT_PROMPT= 0X10,

.

        CONNECT_REDIRECT = 0X80,

.

        CONNECT_CURRENT_MEDIA = 0X200,

.

        CONNECT_COMMAND_LINE = 0X800,

.

        CONNECT_CMD_SAVECRED = 0X1000,

.

        CONNECT_CRED_RESET = 0X2000

.

private static extern int WNetAddConnection2( NETRESOURCE lpNetResource,

.

Declare Function VVNetAddConnection2 Lib "mpr.dll" (TODO) As TODO

.

nr.dwUsage = ResourceUsage.RESOURCEUSAGE_CONNECTABLE;

.

int result = WNetAddConnection2(nr, password, user, (int)ResourceConnection.CONNECT_TEMPORARY);

.
Documentation
[VVNetAddConnection2] on MSDN
.

private static extern int WNetAddConnection3(IntPtr hWndOwner,

.

    Private Shared Function WNetAddConnection3(ByVal hWndOwner As IntPtr, _

.

private const int CONNECT_INTERACTIVE = 0x8;

.

private const int CONNECT_PROMPT = 0x10;

.

WNetAddConnection3(hWnd, ref ConnInf, null, null,

.

    CONNECT_INTERACTIVE | CONNECT_PROMPT);

.
Documentation
[WNetAddConnection3] on MSDN
.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetaddconnection2.asp

.
Summary
The WNetAddConnection2 function makes a connection to a network resource. The function can redirect a local device to the network resource.
.

The WNetAddConnection2 function supersedes the WNetAddConnection function. If you can pass a handle to a window that the provider of network resources can use as an owner window for dialog boxes, call the WNetAddConnection3 function instead.

.

public static extern int WNetAddConnection2(ref NETRESOURCE netResource,

.

public static extern int WNetAddConnection2(NETRESOURCE netResource,

.

  //      RESOURCE_CONNECTED = 1,

.

  //      RESOURCEUSAGE_CONNECTABLE = 0x00000001,

.

  //      RESOURCEUSAGE_ALL = (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED),

.

  //    [DllImport("Mpr.dll", EntryPoint="WNetAddConnection2", CallingConvention=CallingConvention.Winapi)]

.

  //      private static extern ErrorCodes WNetAddConnection2(NETRESOURCE lpNetResource,ref string lpPassword,ref

.

public static extern int WNetAddConnection2( [In] NETRESOURCE netResource,

.

Declare Function WNetAddConnection2 Lib "mpr.dll" (ByRef netResource As _

.

Declare Function WNetAddConnection2 Lib "mpr.dll" (netResource As _

.

// int ret = WNetAddConnection2( myNetResource, "username", "password", 0);

.

int ret = WNetAddConnection2( myNetResource, "password", "username", 0); //by honglinlee

.

  public class NetworkConnection : IDisposable

.

    public NetworkConnection(string networkName,

.

    var result = WNetAddConnection2(

.

        throw new IOException("Error connecting to remote share",

.

    ~NetworkConnection()

.

    WNetCancelConnection2(_networkName, 0, true);

.

    private static extern int WNetAddConnection2(NetResource netResource,

.

    private static extern int WNetCancelConnection2(string name, int flags,

.

    Connected = 1,

.

        RESOURCE_CONNECTED = 1,

.

        RESOURCEUSAGE_CONNECTABLE = 0x00000001,

.

        RESOURCEUSAGE_ALL = (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED),

.

    private static extern int WNetAddConnection2(NETRESOURCE lpNetResource, string lpPassword, string lpUsername, int dwFlags);

.

        int result = WNetAddConnection2(myNetResource, password, user, 0);

.

This is a function which connects to a share. Will throw a message box with any errors.

.

Example connect code:

.

ConnectDrive("\\server\share", "s:", "username", "password")

.

Public Function ConnectDrive(ByVal RemoteName As String, ByVal LocalName As String, Optional ByVal username As String = Nothing, Optional ByVal password As String = Nothing)

.

    returnValue = WNetAddConnection2(myResource, password, username, 0)

.

        MsgBox("Could not connect to " & myResource.RemoteName & ". The server said this: " & vbNewLine & vbNewLine & "(Error " & returnValue & ") " & errorM)

.
Documentation
[WNetAddConnection2] on MSDN
.

private static extern int WNetAddConnection3(IntPtr hWndOwner,

.

    Private Shared Function WNetAddConnection3(ByVal hWndOwner As IntPtr, _

.

private const int CONNECT_INTERACTIVE = 0x8;

.

private const int CONNECT_PROMPT = 0x10;

.

WNetAddConnection3(hWnd, ref ConnInf, null, null,

.

    CONNECT_INTERACTIVE | CONNECT_PROMPT);

.
Documentation
[WNetAddConnection3] on MSDN
.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetaddconnection2.asp

.
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.
.

static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool bForce);

.

Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Integer, ByVal fForce As Integer) As Integer

.

    ''' The WNetCancelConnection2 function cancels an existing network connection.

.

    ''' You can also call the function to remove remembered network connections that are not currently connected.

.

    Private Shared Function WNetCancelConnection2(ByVal lpName As String, _

.

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;

.

public static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool fForce);

.

private const int CONNECT_UPDATE_PROFILE = 0x1;

.

int result=WNetCancelConnection2("Y:", CONNECT_UPDATE_PROFILE, true);

.
Documentation
[WNetCancelConnection2] on MSDN
.
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.
.

static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool bForce);

.

Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Long, ByVal fForce As Long) As Long

.

    ''' The WNetCancelConnection2 function cancels an existing network connection.

.

    ''' You can also call the function to remove remembered network connections that are not currently connected.

.

    Private Shared Function WNetCancelConnection2(ByVal lpName As String, _

.

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;

.

public static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool fForce);

.

private const int CONNECT_UPDATE_PROFILE = 0x1;

.

int result=WNetCancelConnection2("Y:", CONNECT_UPDATE_PROFILE, true);

.
Documentation
[WNetCancelConnection2] on MSDN
.

    RESOURCE_CONNECTED = 0x00000001,

.

    RESOURCEUSAGE_CONNECTABLE =0x00000001,

.

    RESOURCEUSAGE_ALL =(RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED),

.

    RESOURCE_CONNECTED = &H1

.

    RESOURCEUSAGE_CONNECTABLE = &H1

.

    RESOURCEUSAGE_ALL = (RESOURCEUSAGE_CONNECTABLE Or RESOURCEUSAGE_CONTAINER Or RESOURCEUSAGE_ATTACHED)

.

    public static extern int WNetGetConnection([MarshalAs(UnmanagedType.LPTStr)] string localName, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder remoteName, ref int length);

.

    Shared Function WNetGetConnection(<MarshalAs(UnmanagedType.LPTStr)> _

.

    Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal localName As String, ByVal remoteName As System.Text.StringBuilder, ByRef length As Integer) As Integer

.

rc = WNetGetConnection("p:", rname, ref bsize);

.

    Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal localName As String, _

.

        WNetGetConnection(Microsoft.VisualBasic.Left(path, 2), UNC, length)

.

Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" _

.

        Dim err As Integer = WNetGetConnection(theDriveName, uncPathBuf, uncPathBuf.Capacity)

.
Summary
Makes a connection to a network resource. The function can redirect a local device to a network resource.
.

private static extern int WNetUseConnection

.

    Connect     dwFlags,

.

Declare Function WNetUseConnection Lib "mpr.dll" (TODO) As TODO

.

    CONNECTED   = 0x00000001,

.

    CONNECTABLE    = 0x00000001,

.

public enum Connect

.

public static void UseConnection(string localName, string remoteName, string username, string password)

.

    ThrowIfError(WNetUseConnection(IntPtr.Zero, nr, password, username, 0, null, null, null));

.

public static void UseConnection(string localName, string remoteName, bool promptUser = false)

.

    ThrowIfError(WNetUseConnection(IntPtr.Zero, nr, null, null, promptUser ? Connect.INTERACTIVE | Connect.PROMPT : 0, null, null, null));

.
Documentation
[WNetUseConnection] on MSDN

wininet

.

hConnect (in) A handle returned from a call to InternetConnect.

.

fExpectResponse (in) A Boolean value that indicates whether the application expects a data connection to be established by the FTP server. This must be set to TRUE if a data connection is expected, or FALSE otherwise.

.

Dim ret As Boolean = FTPCommandA(ConnectionHandle, False, 0, sCommand, IntPtr.Zero, IntPtr.Zero)

.

static extern bool FtpCreateDirectory(IntPtr hConnect, string lpszDirectory);

.

  Private Shared Function FtpCreateDirectory(ByVal hConnect As IntPtr, ByVal lpszDirectory As String) As Boolean

.

static extern bool FtpDeleteFile(IntPtr hConnect, string fileName);

.

   (ByVal hConnect As IntPtr, ByVal fileName As String) _

Cut off search results after 60. Please refine your search.


 
Access PInvoke.net directly from VS: