コード例 #1
0
        private void OnMachineInfoRequest(INetworkConnection con, Packet packet)
        {
            bool cpu, gpu, drives, mainboard, os, ram;

            cpu = gpu = drives = mainboard = os = ram = false;

            PacketGenericMessage m = packet as PacketGenericMessage;

            m.ReplyPacket = CreateStandardReply(packet, ReplyType.OK, "");

            if (m.Parms.GetBoolProperty("cpu").GetValueOrDefault(false))
            {
                cpu = true;
                CPUInfo ci = MachineInfo.ReadCPUInfo();
                m.ReplyPacket.Parms.SetProperty("cpu", ci.ToString());
            }
            if (m.Parms.GetBoolProperty("gpu").GetValueOrDefault(false))
            {
                gpu = true;
                VideoCardInfo gi = MachineInfo.ReadGPUInfo();
                m.ReplyPacket.Parms.SetProperty("gpu", gi.ToString());
            }
            if (m.Parms.GetBoolProperty("drives").GetValueOrDefault(false))
            {
                drives = true;
                PatcherLib.DriveInfo di = MachineInfo.ReadLogicalDiskInfo();
                m.ReplyPacket.Parms.SetProperty("drives", di.ToString());
            }
            if (m.Parms.GetBoolProperty("mainboard").GetValueOrDefault(false))
            {
                mainboard = true;
                MotherboardInfo mi = MachineInfo.ReadMotherboardInfo();
                m.ReplyPacket.Parms.SetProperty("mainboard", mi.ToString());
            }
            if (m.Parms.GetBoolProperty("os").GetValueOrDefault(false))
            {
                os = true;
                OperatingSystemInfo osr = MachineInfo.ReadOperatingSystemInfo();
                m.ReplyPacket.Parms.SetProperty("os", osr.ToString());
            }
            if (m.Parms.GetBoolProperty("ram").GetValueOrDefault(false))
            {
                ram = true;
                RamInfo ri = MachineInfo.ReadRAMInfo();
                m.ReplyPacket.Parms.SetProperty("ram", ri.ToString());
            }

            if (MachineInfoRequestArrived != null)
            {
                MachineInfoRequestArrived(cpu, gpu, mainboard, drives, os, ram);
            }
        }
コード例 #2
0
        public static void ShowSystemInfo()
        {
            AddProcessorInfo();
            VideoCardInfo card1 = new VideoCardInfo();
            VideoCardInfo card2 = new VideoCardInfo();

            List <string> res = GetHardwareInfo("Win32_VideoController", "Name");

            AddFieldToVideoCard(res, card1, card2, "VideoName");
            res = GetHardwareInfo("Win32_VideoController", "VideoProcessor");
            AddFieldToVideoCard(res, card1, card2, "VideoType");
            res = GetHardwareInfo("Win32_VideoController", "DriverVersion");
            AddFieldToVideoCard(res, card1, card2, "VideoVersion");
            res = GetHardwareInfo("Win32_VideoController", "AdapterRAM");
            AddFieldToVideoCard(res, card1, card2, "VideoSize");
            MainWindow.SystemInfo.VideoCard.Add(card1);
            MainWindow.SystemInfo.VideoCard.Add(card2);
        }
コード例 #3
0
        private static void AddFieldToVideoCard(List <string> res, VideoCardInfo card1, VideoCardInfo card2, string field)
        {
            switch (field)
            {
            case "VideoName":
                card1.VideoName = res[0];
                if (res.Count == 2)
                {
                    card2.VideoName = res[1];
                }
                break;

            case "VideoType":
                card1.VideoType = res[0];
                if (res.Count == 2)
                {
                    card2.VideoType = res[1];
                }
                break;

            case "VideoVersion":
                card1.VideoVersion = res[0];
                if (res.Count == 2)
                {
                    card2.VideoVersion = res[1];
                }
                break;

            case "VideoSize":
                card1.VideoSize = Convert.ToDouble(res[0]) / 1024 / 1024;
                if (res.Count == 2)
                {
                    card2.VideoSize = Convert.ToDouble(res[1]) / 1024 / 1024;
                }
                break;
            }
        }