RasConnection.GetActiveConnectionByHandle Method

DotRas SDK

Collapse image Expand Image Copy image CopyHover image
Retrieves an active connection by the handle.

Namespace: DotRas
Assembly: DotRas (in DotRas.dll) Version: 1.3.5166.33435 (1.3.0.0)

Syntax

C#
[ObsoleteAttribute("This method will be removed in a future version, please use the GetActiveConnections method to find the connection.", 
	false)]
public static RasConnection GetActiveConnectionByHandle(
	RasHandle handle
)
Visual Basic
<ObsoleteAttribute("This method will be removed in a future version, please use the GetActiveConnections method to find the connection.", 
	false)> 
Public Shared Function GetActiveConnectionByHandle ( 
	handle As RasHandle
) As RasConnection
Visual C++
public:
[ObsoleteAttribute(L"This method will be removed in a future version, please use the GetActiveConnections method to find the connection.", 
	false)]
static RasConnection^ GetActiveConnectionByHandle(
	RasHandle^ handle
)
F#
[<ObsoleteAttribute("This method will be removed in a future version, please use the GetActiveConnections method to find the connection.", 
	false)>]
static member GetActiveConnectionByHandle : 
        handle : RasHandle -> RasConnection 

Parameters

handle
Type: DotRas..::..RasHandle
The connection handle.

Return Value

Type: RasConnection
A RasConnection if the connection was found; otherwise, a null reference (Nothing in Visual Basic).

Examples

The following example shows how to retrieve an active connection from the handle.
C# Copy imageCopy
RasHandle handle = null;
using (RasDialer dialer = new RasDialer())
{
    dialer.EntryName = "VPN Connection";
    dialer.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers);
    handle = dialer.Dial();
}
RasConnection connection = RasConnection.GetActiveConnectionByHandle(handle);
Visual Basic Copy imageCopy
Dim handle As RasHandle
Dim dialer As RasDialer
Try
    dialer = New RasDialer
    dialer.EntryName = "VPN Connection"
    dialer.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers)
    handle = dialer.Dial()
Finally
    If dialer IsNot Nothing Then
        dialer.Dispose()
    End If
End Try
RasConnection connection = RasConnection.GetActiveConnectionByHandle(handle)

Exceptions

Exception Condition
System..::..ArgumentNullException handle is a null reference (Nothing in Visual Basic).

See Also