DFÜ Netzwerk kontrollieren

Hallo,

wie kann ich das DFÜ Netzwerk aus meinem VB Programm steuern. Sprich eine Verbindung aufbauen und wieder abbauen. Eine Funktion, die mir zeigt, welche DFÜs aktiv sind wäre auch gut.

Danke im Vorraus

RP

geht nur über API-Calls der netapi.dll etc.

F:\>Stefan

[Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]

Hi !
Hier ein Beispiel-Code für Dein Problem:
( Hab ich aus http://www.activevb.de/vb/index.html )

Option Explicit

Const RAS_MaxDeviceType = 16
Const RAS95_MaxDeviceName = 128
Const RAS95_MaxEntryName = 256

Private Type RASENTRYNAME95
dwSize As Long
szEntryName(RAS95_MaxEntryName) As Byte
End Type

Private Type RASCONN95
dwSize As Long
hRasConn As Long
szEntryName(RAS95_MaxEntryName) As Byte
szDeviceType(RAS_MaxDeviceType) As Byte
szDeviceName(RAS95_MaxDeviceName) As Byte
End Type

Private Declare Function RasEnumConnections Lib „RasApi32.DLL“ _
Alias „RasEnumConnectionsA“ (lprasconn As Any, lpcb As _
Long, lpcConnections As Long) As Long

Private Declare Function RasEnumEntries Lib „RasApi32.DLL“ _
Alias „RasEnumEntriesA“ (ByVal reserved$, ByVal _
lpszPhonebook$, lprasentryname As Any, lpcb As Long, _
lpcEntries As Long) As Long

Private Declare Function RasHangUp Lib „RasApi32.DLL“ _
Alias „RasHangUpA“ (ByVal hRasConn As Long) As Long

Dim DFÜname$, RCon As Long

Private Sub HangUp(ByVal Verbindung$)
Dim s As Long, l As Long, ln As Long, aa$
ReDim r(255) As RASCONN95

r(0).dwSize = 412
s = 256 * r(0).dwSize
l = RasEnumConnections(r(0), s, ln)
For l = 0 To ln - 1
aa = StrConv(r(l).szEntryName(), vbUnicode)
aa = Left$(aa, InStr(aa, Chr$(0)) - 1)
If aa = Verbindung Then
RCon = r(l).hRasConn
Dim rec As Long
rec = RasHangUp(RCon)
End If
Next l
End Sub

Private Sub Command1_Click()
If List1.ListIndex = -1 Then Exit Sub
DFÜname = List1.List(List1.ListIndex)
Shell "rundll32.exe rnaui.dll,RnaDial " & DFÜname

SendKeys „{ENTER}“, True
SendKeys „{ENTER}“, True
Me.SetFocus
End Sub

Private Sub Command2_Click()
Call HangUp(DFÜname)
End Sub

Private Sub Form_Load()
Dim s As Long, ln As Long, i%, conname$
Dim r(255) As RASENTRYNAME95

r(0).dwSize = 264
s = 256 * r(0).dwSize
Call RasEnumEntries(vbNullString, vbNullString, r(0), s, ln)

For i = 0 To ln - 1
conname = StrConv(r(i).szEntryName(), vbUnicode)
List1.AddItem Left$(conname, InStr(conname, vbNullChar) - 1)
Next i

If List1.ListCount 0 Then List1.ListIndex = 0
End Sub