예제 #1
0
        public static VideoCardInfo ReadGPUInfo()
        {
            VideoCardInfo cards = new VideoCardInfo();

            try
            {
                ManagementObjectSearcher    searcher = new ManagementObjectSearcher("SELECT Name, DriverVersion, AdapterRAM FROM Win32_VideoController");
                Dictionary <string, string> data     = new Dictionary <string, string>();

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    GPUInfo gi = new GPUInfo();

                    if (queryObj["Name"] != null)
                    {
                        gi.Name = queryObj["Name"].ToString();
                    }

                    if (queryObj["DriverVersion"] != null)
                    {
                        gi.DriverVersion = queryObj["DriverVersion"].ToString();
                    }

                    if (queryObj["AdapterRAM"] != null)
                    {
                        gi.AdapterRam = Util.ConvertBytesToMegabytes(UInt64.Parse(queryObj["AdapterRAM"].ToString()));
                    }

                    cards.VideoCards.Add(gi);
                }
            }
            catch (Exception e)
            {
            }
            finally
            { }

            return(cards);
        }
예제 #2
0
        public static VideoCardInfo ReadGPUInfo()
        {
            VideoCardInfo cards = new VideoCardInfo();
            try
            {
                ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Name, DriverVersion, AdapterRAM FROM Win32_VideoController");
                Dictionary<string, string> data = new Dictionary<string, string>();

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    GPUInfo gi = new GPUInfo();

                    if (queryObj["Name"] != null)
                    {
                        gi.Name = queryObj["Name"].ToString();
                    }

                    if (queryObj["DriverVersion"] != null)
                    {
                        gi.DriverVersion = queryObj["DriverVersion"].ToString();
                    }

                    if (queryObj["AdapterRAM"] != null)
                    {
                        gi.AdapterRam = Util.ConvertBytesToMegabytes(UInt64.Parse(queryObj["AdapterRAM"].ToString()));
                    }

                    cards.VideoCards.Add(gi);
                }
            }
            catch (Exception e)
            {
            }
            finally
            { }

            return cards;
        }