Показывает все прописанные удаленные соединения
а как отобразить еше имеюсшиеся сетевые подключения ?
Спасибо
- Код: Выделить всё
Module RasDef
Public Const RAS_MaxEntryName As Int32 = 257
Public Const MAX_PATH As Int32 = 260
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> Public Structure RASENTRYNAME
Public Size As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=RAS_MaxEntryName + 1)> Public EntryName As String
Public Flags As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAX_PATH + 1)> Public PhonebookPath As String
End Structure
Public Declare Auto Function RasEnumEntries Lib "rasapi32.dll" ( _
ByVal Reserved As String, _
ByVal Phonebook As String, _
<[In](), Out()> ByVal RasEntryNames() As RASENTRYNAME, _
ByRef CountOfBytes As Int32, _
ByRef CountOfEntries As Int32 _
) As Int32
Public Function GetRasEntries() As RASENTRYNAME()
Return GetRasEntries(Nothing)
End Function
Public Function GetRasEntries(ByVal Phonebook As String) As RASENTRYNAME()
Return GetRasEntries(Phonebook, 1)
End Function
Private Function GetRasEntries(ByVal phonebook As String, ByVal count As Int32) As RASENTRYNAME()
Dim entries() As RASENTRYNAME
Dim size As Int32 = Marshal.SizeOf(GetType(RASENTRYNAME))
Dim rtn As Int32
Dim CountOfBytes As Int32
Dim CountOfEntries As Int32 = count
ReDim entries(CountOfEntries - 1)
entries(0).Size = size
CountOfBytes = size * CountOfEntries
rtn = RasEnumEntries(Nothing, phonebook, entries, CountOfBytes, CountOfEntries)
If CountOfEntries > count Then
Return GetRasEntries(phonebook, CountOfEntries)
Else
Return entries
End If
End Function
End Module
- Код: Выделить всё
Private Function CBox_Ras()
Dim entries() As RASENTRYNAME = GetRasEntries()
For i As Int32 = 0 To entries.Length - 1
ComboBox5.Items.Add(entries(i).EntryName)
Next
End Function