Beispiel #1
0
        public int GetStatus()
        {
            RasDialUC.RASCONN[] lpRasconn = new RasDialUC.RASCONN[1];
            int lpcb           = Marshal.SizeOf(typeof(RasDialUC.RASCONN));
            int lpcConnections = 0;

            lpRasconn[0].dwSize = checked ((uint)lpcb);
            while (true)
            {
                int num1 = RasDialUC.RasEnumConnections(lpRasconn, ref lpcb, ref lpcConnections);
                if (lpcConnections != 0)
                {
                    switch (num1)
                    {
                    case 0:
                        goto label_8;

                    case 603:
                        lpRasconn = new RasDialUC.RASCONN[checked (lpcConnections - 1 + 1)];
                        int num2  = Marshal.SizeOf(typeof(RasDialUC.RASCONN));
                        int num3  = 0;
                        int num4  = checked (lpcConnections - 1);
                        int index = num3;
                        while (index <= num4)
                        {
                            lpRasconn[index].dwSize = checked ((uint)num2);
                            checked { ++index; }
                        }
                        lpcb = checked (num2 * lpcConnections);
                        continue;

                    default:
                        goto label_7;
                    }
                }
                else
                {
                    goto label_14;
                }
            }
label_7:
            lpcConnections = 0;
            goto label_14;
label_8:
            int num5 = 0;
            int num6   = checked (lpcConnections - 1);
            int index1 = num5;

            while (index1 <= num6 && Operators.CompareString(lpRasconn[index1].szEntryName, this.MainOptions.EntryName, false) != 0)
            {
                checked { ++index1; }
            }
            if (index1 == lpcConnections)
            {
                lpcConnections = 0;
            }
            else
            {
                this.MainHeader = lpRasconn[index1].hRasConn;
                RasDialUC.RASCONNSTATUS lpRasConnStatus = new RasDialUC.RASCONNSTATUS();
                lpRasConnStatus.dwSize = Marshal.SizeOf(typeof(RasDialUC.RASCONNSTATUS));
                RasDialUC.RasGetConnectStatus(lpRasconn[index1].hRasConn, out lpRasConnStatus);
                lpcConnections = (int)lpRasConnStatus.rasconnstate;
            }
label_14:
            return(lpcConnections);
        }
Beispiel #2
0
        private void TimerStatus_Tick(object sender, ElapsedEventArgs e)
        {
            RasDialUC.RASCONN[] lpRasconn = new RasDialUC.RASCONN[1];
            int lpcb = Marshal.SizeOf(typeof(RasDialUC.RASCONN));

            lpRasconn[0].dwSize = checked ((uint)lpcb);
            int num1;

            while (true)
            {
                num1 = RasDialUC.RasEnumConnections(lpRasconn, ref lpcb, ref this.ConnectionCount);
                switch (num1)
                {
                case 0:
                    goto label_9;

                case 603:
                    lpRasconn = new RasDialUC.RASCONN[checked (this.ConnectionCount - 1 + 1)];
                    int num2  = Marshal.SizeOf(typeof(RasDialUC.RASCONN));
                    int num3  = 0;
                    int num4  = checked (this.ConnectionCount - 1);
                    int index = num3;
                    while (index <= num4)
                    {
                        lpRasconn[index].dwSize = checked ((uint)num2);
                        checked { ++index; }
                    }
                    lpcb = checked (num2 * this.ConnectionCount);
                    continue;

                default:
                    goto label_6;
                }
            }
label_6:
            int num5 = checked (num1 + 60000);

            if (this.PreviousStatus != 8192 && this.PreviousStatus != -1)
            {
                return;
            }
            this.ChangeDisconnect();
            return;

label_9:
            if (this.ConnectionCount == 0)
            {
                if (this.PreviousStatus != 8192 && this.PreviousStatus != -1)
                {
                    return;
                }
                this.ChangeDisconnect();
            }
            else
            {
                int num2  = 0;
                int num3  = checked (this.ConnectionCount - 1);
                int index = num2;
                while (index <= num3 && Operators.CompareString(lpRasconn[index].szEntryName, this.MainOptions.EntryName, false) != 0)
                {
                    checked { ++index; }
                }
                if (index == this.ConnectionCount)
                {
                    if (this.PreviousStatus != 8192 && this.PreviousStatus != -1)
                    {
                        return;
                    }
                    this.ChangeDisconnect();
                }
                else
                {
                    RasDialUC.RASCONNSTATUS lpRasConnStatus = new RasDialUC.RASCONNSTATUS();
                    lpRasConnStatus.dwSize = Marshal.SizeOf(typeof(RasDialUC.RASCONNSTATUS));
                    RasDialUC.RasGetConnectStatus(lpRasconn[index].hRasConn, out lpRasConnStatus);
                    if (lpRasConnStatus.rasconnstate == (RasDialUC.RASCONNSTATE) this.PreviousStatus)
                    {
                        return;
                    }
                    switch (lpRasConnStatus.rasconnstate)
                    {
                    case RasDialUC.RASCONNSTATE.RASCS_Connected:
                        this.PreviousStatus = (int)lpRasConnStatus.rasconnstate;
                        this.send_Connected();
                        break;

                    case RasDialUC.RASCONNSTATE.RASCS_Disconnected:
                        this.ChangeDisconnect();
                        break;
                    }
                }
            }
        }