Results 1 to 5 of 5

Thread: which API can list out all my dialup connection

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    14

    which API can list out all my dialup connection

    hi all,

    i looking for many days on this topic already. as i know maybe is using RASAPI32 to do this. but i have vb6 code only. when i convert to vb.net. there have problem like "As Any" not supported by .net, declaration "TYPE" also not supported and etc. who can teach me how to modified?

    code:
    Private Type RAS_ENTRIES
    dwSize As Long
    szEntryname(256) As Byte
    End Type
    Private Declare Function RasEnumEntriesA Lib "rasapi32.dll" (ByVal reserved As String, ByVal lpszPhonebook As String, lprasentryname As Any, lpcb As Long, lpcEntries As Long) As Long

    sub
    Dim plSize As Long
    Dim plEntries As Long
    Dim psConName As String
    Dim plIndex As Long
    Dim RAS(255) As RAS_ENTRIES

    Erase sDunList()
    RAS(0).dwSize = 264
    plSize = 256 * RAS(0).dwSize
    Call RasEnumEntriesA(vbNullString, vbNullString, RAS(0), plSize, plEntries)
    plEntries = plEntries - 1
    If plEntries >= 0 Then
    ReDim sDunList(plEntries)
    For plIndex = 0 To plEntries
    psConName = StrConv(RAS(plIndex).szEntryname(), vbUnicode)
    sDunList(plIndex) = Left$(psConName, InStr(psConName, vbNullChar) - 1)
    Next plIndex
    End If
    end sub

    thanks~

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: which API can list out all my dialup connection

    "As Any" can be specified as which ever type you are dealing with but generically you can use Object but you wil need to create an instance of it first.

    Code:
    Option Explicit On
    Option Strict On
    
    Imports System.Runtime.InteropServices
    
    Public Class Form1
    
        <StructLayout(LayoutKind.Sequential)> _
        Private Structure RAS_ENTRIES
            Private dwSize As Integer
            Private szEntryname() As Byte
        End Structure
    
        <DllImport("rasapi32.dll", CharSet:=CharSet.Auto, EntryPoint:="rasapi32.dll")> _
        Private Shared Function RasEnumEntries( _
            ByVal reserved As String, _
            ByVal lpszPhonebook As String, _
            ByRef lprasEntryName As RAS_ENTRIES, _
            ByRef lpcb As Integer, _
            ByRef lpcEntries As Integer) As Integer
        End Function
    
    End Class
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    14

    Re: which API can list out all my dialup connection

    thanks, after i try ur method, it shown error at below part

    sub ListDun(ByRef sDunList() As String)
    Dim plSize As Long
    Dim plEntries As Long
    Dim psConName As String
    Dim plIndex As Long
    Dim RAS(255) As RAS_ENTRIES

    Erase sDunList() 'error : number of indices is less than the number of dimension of the indexed arrayRAS(0).dwSize = 264
    plSize = 256 * RAS(0).dwSize
    Call RasEnumEntriesA(vbNullString, vbNullString, RAS(0), plSize, plEntries)
    plEntries = plEntries - 1
    If plEntries >= 0 Then
    ReDim sDunList(plEntries)
    For plIndex = 0 To plEntries
    psConName = StrConv(RAS(plIndex).szEntryname(), vbUnicode) ' error: Convert method not support
    sDunList(plIndex) = Left$(psConName, InStr(psConName, vbNullChar) - 1)
    Next plIndex
    End If
    end sub

    beside that, other no blue underline shown, how to modified it?? thanks

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: which API can list out all my dialup connection

    Please use [code] tags next time so its easier to read.

    RAS(0).dwSize = 264 'Exceeds the 255 dimensioned.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    14

    Re: which API can list out all my dialup connection

    ok, i will next time.
    but the error is at " Erase sDUNList() " and " ConvStr ", bold text.
    how do i solve that?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width