EnumRASEntries – Enumerate all available RAS phone-book entries

Const ERROR_SUCCESS = 0&Const ERROR_BUFFER_TOO_SMALL = 603&Const RAS_MaxEntryName = 256Private Type RASENTRYNAME    dwSize As Long    szEntryName(RAS_MaxEntryName) As ByteEnd TypePrivate Declare Function RasEnumEntries Lib "RasApi32.DLL" Alias _    "RasEnumEntriesA" (ByVal reserved As String, ByVal lpszPhonebook As String, _    lpRasEntryName As Any, lpcb As Long, lpcEntries As Long) As Long' Enumerate available RAS phone-book entries' returns their name in a collection.'' the optional argument is the phonebook name' Windows 9x: this argument is always ignored' Windows NT, if omitted it uses the default phonebook' Windows 2000, if omitted entries are enumerated from all'    the remote access phone-book files in the AllUsers profile'    and the user's profile.Function EnumRASEntries(Optional ByVal PhoneBook As String) As Collection    Dim lpRasEntryName() As RASENTRYNAME    Dim retCode As Long    Dim cbBuf As Long    Dim cEntries As Long    Dim i As Integer    ' prepare the result    Set EnumRASEntries = New Collection        ' NULL is different from an empty string    If Len(PhoneBook) = 0 Then PhoneBook = vbNullString        ' only one entry, just to check how many entries are there    ReDim lpRasEntryName(0) As RASENTRYNAME    lpRasEntryName(0).dwSize = LenB(lpRasEntryName(0))    cbBuf = lpRasEntryName(0).dwSize    retCode = RasEnumEntries(vbNullString, PhoneBook, lpRasEntryName(0), cbBuf, _        cEntries)    ' read all entries, if more than just one    If retCode = ERROR_BUFFER_TOO_SMALL Then        ReDim lpRasEntryName(cEntries - 1) As RASENTRYNAME        lpRasEntryName(0).dwSize = LenB(lpRasEntryName(0))        cbBuf = cEntries * lpRasEntryName(0).dwSize        retCode = RasEnumEntries(vbNullString, PhoneBook, lpRasEntryName(0), _            cbBuf, cEntries)    End If    ' an error occurred    If retCode <> ERROR_SUCCESS Then Err.Raise vbObjectError + 512, , _        "RasEnumEntries returnet " & retCode    ' fill the result collection with entry names    For i = 0 To cEntries - 1        EnumRASEntries.Add StrConv(lpRasEntryName(i).szEntryName(), vbUnicode)    Next iEnd Function

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may

man on floor with data

DevX Quick Guide to Data Ingestion

One of the biggest trends of the 21st century is the massive surge in internet usage. With major innovations such as smart technology, social media, and online shopping sites, the internet has become an essential part of everyday life for a large portion of the population. Due to this internet

payment via phone

7 Ways Technology Has Changed Traditional Payments

In today’s digital world, technology has changed how we make payments. From contactless cards to mobile wallets, it’s now easier to pay for goods and services without carrying cash or using a checkbook. This article will look at seven of the most significant ways technology has transformed traditional payment methods.