Esempio n. 1
0
        public static byte[] getSystemSpecifications(Command command)
        {
            CPUInfo[]            cpuInfo            = WMI.buildWMIObjects <CPUInfo>("Win32_Processor");
            GPUInfo[]            gpuInfo            = WMI.buildWMIObjects <GPUInfo>("Win32_VideoController");
            RAMInfo[]            ramInfo            = WMI.buildWMIObjects <RAMInfo>("Win32_PhysicalMemory");
            BIOSInfo[]           biosInfo           = WMI.buildWMIObjects <BIOSInfo>("Win32_BIOS");
            NetworkAdapterInfo[] networkAdapterInfo = WMI.buildWMIObjects <NetworkAdapterInfo>("Win32_NetworkAdapter");
            PhoenixLib.Datastore.CommunicationClasses.DriveInfo[] driveInfo = WMI.buildWMIObjects <PhoenixLib.Datastore.CommunicationClasses.DriveInfo>("Win32_DiskDrive");
            ScreenInfo[] screenInfo = Screen.AllScreens.Select((x) =>
            {
                return(new ScreenInfo
                {
                    deviceName = x.DeviceName,
                    height = x.Bounds.Height,
                    width = x.Bounds.Width
                });
            }).ToArray();
            SoundInfo[]           soundInfo           = WMI.buildWMIObjects <SoundInfo>("Win32_SoundDevice");
            UserAccountInfo[]     userAccountInfo     = WMI.buildWMIObjects <UserAccountInfo>("Win32_UserAccount");
            OperatingSystemInfo[] operationSystemInfo = WMI.buildWMIObjects <OperatingSystemInfo>("Win32_OperatingSystem");

            ManagementObjectCollection batteryCollection = WMI.getWMIInfo("Win32_Battery");
            bool batteryInstalled = false;

            foreach (ManagementObject obj in batteryCollection)
            {
                try
                {
                    uint value = (uint)obj["Availability"];
                    if (!((value == 0xB) || (value == 0x6) || (value == 0x1)))
                    {
                        batteryInstalled = false;
                        break;
                    }
                    else
                    {
                        batteryInstalled = true;
                        break;
                    }
                }
                catch
                {
                    batteryInstalled = true;
                    break;
                }
            }
            String internalIP = "0.0.0.0";

            using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0))
            {
                try
                {
                    socket.Connect("10.0.2.4", 65530);
                    IPEndPoint endPoint = socket.LocalEndPoint as IPEndPoint;
                    internalIP = endPoint.Address.ToString();
                }
                catch
                {
                    internalIP = "No internet connection!";
                }
            }
            SoftwareInfo softwareInfo = new SoftwareInfo
            {
                users = userAccountInfo,
                operationSystemInfo = operationSystemInfo[0]
            };
            SummaryInfo hardwareInfo = new SummaryInfo
            {
                cpuInfo            = cpuInfo,
                gpuInfo            = gpuInfo,
                ramInfo            = ramInfo,
                biosInfo           = biosInfo,
                networkAdapterInfo = networkAdapterInfo,
                driveInfo          = driveInfo,
                monitorInfo        = screenInfo,
                internalIP         = internalIP,
                soundInfo          = soundInfo,
                softwareInfo       = softwareInfo,
                batteryAvailible   = batteryInstalled
            };

            byte[] data = Util.Serialization.serialize(hardwareInfo);
            return(data);
        }