Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

RasEnumDevices (rasapi32)
 
.
Summary
TODO - a short description

C# Signature:

[DllImport("rasapi32.dll", SetLastError=true)]
static extern TODO RasEnumDevices(TODO);

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.

<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

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

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

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions