「最後の接続」を取得することはできませんが、Active Connectionを取得できます。また、Networking名前空間のイベントを使用して「Network Disconnected/Connected」を検出することもできます。
これは以前使用したVB.Netコードの一部ですが、その意図がわかります。
Dim networkAvailable As Boolean = Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()
AddHandler System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged, AddressOf NetworkAddressChanged
AddHandler System.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged, AddressOf NetworkAvailabilityChanged
Private Sub OutputNetworkAddresses(message As String, linePrefix As String)
Dim adapters() As Net.NetworkInformation.NetworkInterface
adapters = Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces
For Each adapter As Net.NetworkInformation.NetworkInterface In adapters
Dim properties As IPInterfaceProperties = adapter.GetIPProperties()
For Each ipi As IPAddressInformation In properties.UnicastAddresses
Dim ip As Net.IPAddress = ipi.Address
If ip.IsIPv6LinkLocal Or ip.Equals(IPAddress.Any) Or ip.Equals(IPAddress.IPv6Any) Or IPAddress.IsLoopback(ip) Then
'Debug.Print("IPv6=" & ip.ToString)
Else
Console.WriteLine(String.Format("{0} - {1}", linePrefix, ip.ToString()))
End If
Next
Next
End Sub