|
-
Jan 30th, 2002, 07:10 AM
#1
Thread Starter
Junior Member
VB RAS? - Getting DUN Names!
Hello,
Does anyone know if it is possible to get the dial up network NAMES, not numbers of the phone book entries from within VB?
I've looked on MSDN, and some html help file that lists the VB Ras API calls..
I'd prefer to do it via API, but a control is ok too.
Thanks!
-
Jan 31st, 2002, 08:02 PM
#2
Addicted Member
I would be interested in this also...
My software never has bugs. It just develops random features.

-
Jan 31st, 2002, 08:28 PM
#3
Addicted Member
Put this in module......
Public Type VBRasEntryName
entryname As String
Win2000_SystemPhonebook As Boolean
PhonebookPath As String
End Type
Public Declare Function RasEnumEntries _
Lib "rasapi32.dll" Alias "RasEnumEntriesA" _
(ByVal lpStrNull As String, ByVal lpszPhonebook As String, _
lpRasEntryName As Any, lpCb As Long, lpCEntries As Long) As Long
Public Declare Function RasGetErrorString _
Lib "rasapi32.dll" Alias "RasGetErrorStringA" _
(ByVal uErrorValue As Long, ByVal lpszErrorString As String, _
cBufSize As Long) As Long
Public Declare Function FormatMessage _
Lib "kernel32" Alias "FormatMessageA" _
(ByVal dwFlags As Long, lpSource As Any, _
ByVal dwMessageId As Long, ByVal dwLanguageId As Long, _
ByVal lpBuffer As String, ByVal nSize As Long, _
Arguments As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)
Function VBRasGetAllEntries(clsRasEntryName() As VBRasEntryName, _
Optional strPhoneBook As String) As Long
Dim rtn As Long, i As Long
Dim lpCb As Long 'count of bytes
Dim lpCEntries As Long 'count of entries
Dim b() As Byte
Dim strTemp As String
Dim dwSize As Long 'size of each entry
Dim lngLen As Long
Dim lngBLen As Variant
ReDim b(3)
'determine appropiate size for b()
lngBLen = Array(532&, 264&, 28&)
For i = 0 To 2
CopyMemory b(0), CLng(lngBLen(i)), 4
rtn = RasEnumEntries(vbNullString, strPhoneBook, _
b(0), lpCb, lpCEntries)
If rtn <> 632 Then Exit For
Next i
VBRasGetAllEntries = lpCEntries
If lpCEntries = 0 Then Exit Function
dwSize = lpCb \ lpCEntries
ReDim b(lpCb - 1)
CopyMemory b(0), dwSize, 4
rtn = RasEnumEntries(vbNullString, strPhoneBook, _
b(0), lpCb, lpCEntries)
If rtn <> 0 Then MsgBox VBRASErrorHandler(rtn)
strTemp = String(dwSize - 4, 0)
ReDim clsRasEntryName(lpCEntries - 1)
If dwSize = 28 Then lngLen = 21 Else lngLen = 257
For i = 0 To lpCEntries - 1
CopyMemory ByVal strTemp, b((i * dwSize) + 4), lngLen
clsRasEntryName(i).entryname = _
Left(strTemp, InStr(strTemp, Chr$(0)) - 1)
Next i
If dwSize > 264 Then
For i = 0 To lpCEntries - 1
CopyMemory clsRasEntryName(i).Win2000_SystemPhonebook, _
b((i * dwSize) + 264), 2&
CopyMemory ByVal strTemp, b((i * dwSize) + 268), 260&
clsRasEntryName(i).PhonebookPath = _
Left(strTemp, InStr(strTemp, Chr$(0)) - 1)
Next i
Else
For i = 0 To lpCEntries - 1
clsRasEntryName(i).PhonebookPath = strPhoneBook
Next i
End If
End Function
Function VBRASErrorHandler(rtn As Long) As String
Dim strError As String, i As Long
strError = String(512, 0)
If rtn > 600 Then
RasGetErrorString rtn, strError, 512&
Else
FormatMessage &H1000, ByVal 0&, rtn, 0&, strError, 512, ByVal 0&
End If
i = InStr(strError, Chr$(0))
If i > 1 Then VBRASErrorHandler = Left$(strError, i - 1)
End Function
Put this in a form.....
Dim myRasEntry() As VBRasEntryName
Dim ret As Long
Dim l As Long
ret = VBRasGetAllEntries(myRasEntry)
For l = LBound(myRasEntry) To UBound(myRasEntry)
'Debug.Print myRasEntry(l).entryname
Combo1.AddItem myRasEntry(l).entryname
Next
You can use a listbox ,combo box just change
Combo1.addItem Line to what ever....
My software never has bugs. It just develops random features.

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|