RasEnumDevices (rasapi32)
Last changed: -195.137.200.48

.
Summary
TODO - a short description

C# Signature:

:(

VB Signature:

This Signature is needed.

Private Declare Auto Function RasEnumDevices Lib "rasapi32.dll" (ByVal lpRasDevInfo As IntPtr, ByRef lpcb As Integer, ByRef lpcDevices As Integer) As Integer

User-Defined Types:

This Structure Is Needed.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

This structure needs to be defined.

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)>

    Public Class CRasDevInfo
        Public Const RAS_MAXDEVICETYPE As Integer = 16
        Public Const RAS_MAXDEVICENAME As Integer = 128
        Public dwSize As Integer
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=RAS_MAXDEVICETYPE + 1)> _
        Public szDeviceType As String
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=RAS_MAXDEVICENAME + 1)> _
        Public szDeviceName As String
    End Class

Sample Code:

Public Shared Function GetDevices() As CRasDevInfo()

        Dim intRet As Integer
        Dim lpcb As Integer
        Dim lpcDevices As Integer
        Dim devinfo As IntPtr
        Dim rdiRet As CRasDevInfo()
        Dim i As Integer
        RasEnumDevices(IntPtr.Zero, lpcb, lpcDevices)
        devinfo = Marshal.AllocHGlobal(lpcb)
        ReDim rdiRet(0)
        rdiRet(0) = New CRasDevInfo()
        Marshal.WriteInt32(devinfo, Marshal.SizeOf(rdiRet(0)))
        intRet = RasEnumDevices(devinfo, lpcb, lpcDevices)
        If intRet = 0 Then
        ReDim rdiRet(lpcDevices - 1)
        For i = 0 To lpcDevices - 1
            rdiRet(i) = New CRasDevInfo()
            Marshal.PtrToStructure(devinfo, rdiRet(i))
            devinfo = IntPtr.op_Explicit(devinfo.ToInt32() + Marshal.SizeOf(rdiRet(i)))
        Next
        Marshal.FreeHGlobal(devinfo)
        Return rdiRet
        Else
        Return Nothing
        End If
    End Function

Documentation