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

RasEnumConnections (coredll)
 

coredll is for smart devices, not desktop Windows. Therefore, this information only applies to code using the .NET Compact Framework. To see if information for RasEnumConnections in other DLLs exists, click on Find References to the right.

.

C# Signature:

    [DllImport("coredll.dll", CharSet = CharSet.Unicode)]
    internal static extern UInt32 RasEnumConnections([In, Out] _RASCONN[] lprasconn, ref UInt32 lpcb, ref UInt32 lpcConnections);

User-Defined Types:

    const int RAS_MaxEntryName = 20;
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    internal struct _RASCONN
    {
        private UInt32 m_size;
        private IntPtr m_hrasconn;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = RAS_MaxEntryName + 1)]
        private char[] m_entryName;

        public IntPtr ConnectionHandle { get { return m_hrasconn; } }
        public string EntryName { get { return new string(m_entryName).TrimEnd(new char[] { '\0' }); } }

        public static _RASCONN CreateStruct()
        {
        _RASCONN obj = new _RASCONN();
        obj.m_size = System.Convert.ToUInt32(Marshal.SizeOf(typeof(_RASCONN)));
        obj.m_hrasconn = IntPtr.Zero;
        obj.m_entryName = new char[RAS_MaxEntryName + 1];
        return obj;
        }    
    }

Sample Code:

    public static _RASCONN[] EnumerateConnections()
    {
        _RASCONN[] rasconn;
        UInt32 size = 0, noelements = 0;
        size = System.Convert.ToUInt32(Marshal.SizeOf((rasconn = new _RASCONN[1])[0] = _RASCONN.CreateStruct()));
        if (RasEnumConnections(rasconn, ref size, ref noelements) != 0x00)
        {
            size = System.Convert.ToUInt32(Marshal.SizeOf((rasconn = new _RASCONN[size / Marshal.SizeOf(typeof(_RASCONN))])[0] =                         _RASCONN.CreateStruct()) * rasconn.Length);
            if (RasEnumConnections(rasconn, ref size, ref noelements) != 0x00) { rasconn = null; }
        }
        return rasconn;
    }

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
Edit This Page
Find References
Show Printable Version
Revisions