using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Management;

namespace ShopBot.GetInformations
{
    class Informations
    {
        public static string getHWID()
        {
            ManagementObjectCollection mbsList = null;
            ManagementObjectSearcher mbs = new ManagementObjectSearcher("Select * From Win32_processor");
            mbsList = mbs.Get();
            string id = "";
            foreach (ManagementObject mo in mbsList)
            {
                id = mo["ProcessorID"].ToString();
            }

            ManagementObject dsk = new ManagementObject(@"win32_logicaldisk.deviceid=""c:""");
            dsk.Get();
            string ids = dsk["VolumeSerialNumber"].ToString();

            return id + ids;
        }

        public static string DetectAntivir()
        {
            string WmiPath;

            if (DetectOS().ToLower().Contains("xp"))
                WmiPath = @"\\" + Environment.MachineName + @"\root\SecurityCenter";
            else
                WmiPath = @"\\" + Environment.MachineName + @"\root\SecurityCenter2";

            try
            {
                ManagementObjectSearcher searcher = new ManagementObjectSearcher(WmiPath, "SELECT * FROM AntivirusProduct");
                ManagementObjectCollection instances = searcher.Get();

                foreach (ManagementObject queryObj in instances)
                {
                    return queryObj["displayName"].ToString();
                }
            }

            catch
            {
                return "No Antivir";
            }
            return "No Antivir";
        }

        public static string DetectOS()
        {
            OperatingSystem os = Environment.OSVersion;
            string osText = "";
            if (os.Version.Major == 5)
            {
                switch (os.Version.Minor)
                {
                    case 0: osText = "Windows 2000";
                        break;
                    case 1: osText = "Windows XP";
                        break;
                    case 2: osText = "Windows Server 2003";
                        break;
                    default: osText = os.ToString();
                        break;
                }
            }
            else
            {
                if (os.Version.Major == 6)
                {
                    switch (os.Version.Minor)
                    {
                        case 0: osText = "Windows Vista";
                            break;
                        case 1: osText = "Windows 7";
                            break;
                        case 2: osText = "Windows 8";
                            break;
                    }
                }
                else
                    osText = os.ToString();
            }

            return osText;
        }
    }
}
