Exemplo n.º 1
0
Arquivo: Form1.cs Projeto: zsea/QnPg
        private static int GetChromeListeningPortWithInterOp(int pid)
        {
            int port = 0;

            if (pid > 0)
            {
                port = TcpConnectionInfo.GetChromeListeningPortWithInterOp(pid);
            }
            return(port);
        }
Exemplo n.º 2
0
Arquivo: Form1.cs Projeto: zsea/QnPg
        public static int GetChromeListeningPortWithInterOp(int pid)
        {
            int port = 0;

            try
            {
                TcpConnectionInfo.MIB_TCPROW_OWNER_PID[] tcpConnections = TcpConnectionInfo.GetAllTcpConnections();
                for (int i = 0; i < tcpConnections.Length; i++)
                {
                    TcpConnectionInfo.MIB_TCPROW_OWNER_PID mIB_TCPROW_OWNER_PID = tcpConnections[i];
                    if (mIB_TCPROW_OWNER_PID.localAddr == 16777343u && mIB_TCPROW_OWNER_PID.owningPid == pid)
                    {
                        port = (int)mIB_TCPROW_OWNER_PID.LocalPort;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.Assert(false, ex.Message);
            }
            return(port);
        }