コード例 #1
0
ファイル: MachineInfo.cs プロジェクト: Amitkapadi/WISP
        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
ファイル: MachineInfo.cs プロジェクト: kamilion/WISP
        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;
        }