internal static extern int RasEnumConnections
     (
     ref RASCONN lprasconn, // buffer to receive connections data
     ref int lpcb, // size in bytes of buffer
     ref int lpcConnections // number of connections written to buffer
     );
 internal static extern int RasEnumConnections
 (
     ref RASCONN lprasconn, // buffer to receive connections data
     ref int lpcb,          // size in bytes of buffer
     ref int lpcConnections // number of connections written to buffer
 );
        //RasStats status = new RasStats();
        public RASDisplay()
        {
            m_connected = true;

            RAS lpras = new RAS();
            RASCONN lprasConn = new RASCONN();

            lprasConn.dwSize = Marshal.SizeOf(typeof(RASCONN));
            lprasConn.hrasconn = IntPtr.Zero;

            int lpcb = 0;
            int lpcConnections = 0;
            int nRet = 0;
            lpcb = Marshal.SizeOf(typeof(RASCONN));

            nRet = RAS.RasEnumConnections(ref lprasConn, ref lpcb, ref
                lpcConnections);

            if (nRet != 0)
            {
                m_connected = false;
                return;

            }

            if (lpcConnections > 0)
            {
                //for (int i = 0; i < lpcConnections; i++)

                //{
                RasStats stats = new RasStats();

                m_ConnectedRasHandle = lprasConn.hrasconn;
                //RAS.RasGetConnectionStatistics(lprasConn.hrasconn, stats);


                m_ConnectionName = lprasConn.szEntryName;

                //int Hours = 0;
                //int Minutes = 0;
                //int Seconds = 0;

                //Hours = ((stats.dwConnectionDuration / 1000) / 3600);
                //Minutes = ((stats.dwConnectionDuration / 1000) / 60) - (Hours * 60);
                //Seconds = ((stats.dwConnectionDuration / 1000)) - (Minutes * 60) - (Hours * 3600);


                //m_duration = Hours + " hours " + Minutes + " minutes " + Seconds + " secs";
                //m_TX = stats.dwBytesXmited;
                //m_RX = stats.dwBytesRcved;
                //}
            }
            else
            {
                m_connected = false;
            }


            int lpNames = 1;
            int entryNameSize = 0;
            int lpSize = 0;
            RasEntryName[] names = null;

            entryNameSize = Marshal.SizeOf(typeof(RasEntryName));
            lpSize = lpNames * entryNameSize;

            names = new RasEntryName[lpNames];
            names[0].dwSize = entryNameSize;

            uint retval = RAS.RasEnumEntries(null, null, names, ref lpSize, out lpNames);

            //if we have more than one connection, we need to do it again
            if (lpNames > 1)
            {
                names = new RasEntryName[lpNames];
                for (int i = 0; i < names.Length; i++)
                {
                    names[i].dwSize = entryNameSize;
                }

                retval = RAS.RasEnumEntries(null, null, names, ref lpSize, out lpNames);

            }
            m_ConnectionNames = new string[names.Length];


            if (lpNames > 0)
            {
                for (int i = 0; i < names.Length; i++)
                {
                    m_ConnectionNames[i] = names[i].szEntryName;
                }
            }
        }
        //RasStats status = new RasStats();
        public RASDisplay()
        {
            m_connected = true;

            RAS     lpras     = new RAS();
            RASCONN lprasConn = new RASCONN();

            lprasConn.dwSize   = Marshal.SizeOf(typeof(RASCONN));
            lprasConn.hrasconn = IntPtr.Zero;

            int lpcb           = 0;
            int lpcConnections = 0;
            int nRet           = 0;

            lpcb = Marshal.SizeOf(typeof(RASCONN));

            nRet = RAS.RasEnumConnections(ref lprasConn, ref lpcb, ref
                                          lpcConnections);

            if (nRet != 0)
            {
                m_connected = false;
                return;
            }

            if (lpcConnections > 0)
            {
                //for (int i = 0; i < lpcConnections; i++)

                //{
                RasStats stats = new RasStats();

                m_ConnectedRasHandle = lprasConn.hrasconn;
                //RAS.RasGetConnectionStatistics(lprasConn.hrasconn, stats);


                m_ConnectionName = lprasConn.szEntryName;

                //int Hours = 0;
                //int Minutes = 0;
                //int Seconds = 0;

                //Hours = ((stats.dwConnectionDuration / 1000) / 3600);
                //Minutes = ((stats.dwConnectionDuration / 1000) / 60) - (Hours * 60);
                //Seconds = ((stats.dwConnectionDuration / 1000)) - (Minutes * 60) - (Hours * 3600);


                //m_duration = Hours + " hours " + Minutes + " minutes " + Seconds + " secs";
                //m_TX = stats.dwBytesXmited;
                //m_RX = stats.dwBytesRcved;
                //}
            }
            else
            {
                m_connected = false;
            }


            int lpNames       = 1;
            int entryNameSize = 0;
            int lpSize        = 0;

            RasEntryName[] names = null;

            entryNameSize = Marshal.SizeOf(typeof(RasEntryName));
            lpSize        = lpNames * entryNameSize;

            names           = new RasEntryName[lpNames];
            names[0].dwSize = entryNameSize;

            uint retval = RAS.RasEnumEntries(null, null, names, ref lpSize, out lpNames);

            //if we have more than one connection, we need to do it again
            if (lpNames > 1)
            {
                names = new RasEntryName[lpNames];
                for (int i = 0; i < names.Length; i++)
                {
                    names[i].dwSize = entryNameSize;
                }

                retval = RAS.RasEnumEntries(null, null, names, ref lpSize, out lpNames);
            }
            m_ConnectionNames = new string[names.Length];


            if (lpNames > 0)
            {
                for (int i = 0; i < names.Length; i++)
                {
                    m_ConnectionNames[i] = names[i].szEntryName;
                }
            }
        }