如何通过 WMI 调用找到安装的视频 RAM 数量?

发布于 2024-07-09 11:46:20 字数 119 浏览 6 评论 0原文

有谁知道如何从 WMI 调用中获取 PC 的视频 RAM?

我见过对 Win32_VideoController 管理对象的 AdapterRAM 属性的调用,但这仅提供系统内存,根本不代表视频 RAM。

Does anyone know how to get the Video Ram of a PC from a WMI call?

I've seen calls to the Win32_VideoController management object's AdapterRAM property, but that only gives the system memory, and is not representative of the video RAM at all.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

说谎友 2024-07-16 11:46:20

结果是适配器 RAM 返回,并且由于不幸的巧合,使用了错误的转换并在两个不同的系统上提供了系统 RAM。 感谢您推动我们再次查看。

就其价值而言,在 C# WinForms 应用程序中:

int _ram = 0;

ManagementObjectSearcher searcher = new ManagementObjectSearcher("select AdapterRAM from Win32_VideoController");

foreach (ManagementObject mo in searcher.Get())
{
   var ram = mo.Properties["AdapterRAM"].Value as UInt32?;

   if (ram.HasValue)
   {
      _ram = ((int)ram/1048576);
   }
}

Turns out it was the adapter RAM returned, and through an unfortunate coincidence, the wrong conversion was used and gave the system RAM...on two different systems. Thanks for pushing us to look again.

For what it's worth, in a C# WinForms app:

int _ram = 0;

ManagementObjectSearcher searcher = new ManagementObjectSearcher("select AdapterRAM from Win32_VideoController");

foreach (ManagementObject mo in searcher.Get())
{
   var ram = mo.Properties["AdapterRAM"].Value as UInt32?;

   if (ram.HasValue)
   {
      _ram = ((int)ram/1048576);
   }
}
一世旳自豪 2024-07-16 11:46:20

来自“硬件”下的 Microsoft Technet 脚本中心脚本存储库,然后是“视频和显示” '然后'列出视频控制器属性'。

我想你可能需要在 AdapterRAM 和“VideoMemoryType”之间解决一些问题

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_VideoController")

For Each objItem in colItems
    For Each strCapability in objItem.AcceleratorCapabilities
        Wscript.Echo "Accelerator Capability: " & strCapability
    Next
    Wscript.Echo "Adapter Compatibility: " & objItem.AdapterCompatibility
    Wscript.Echo "Adapter DAC Type: " & objItem.AdapterDACType
    Wscript.Echo "Adapter RAM: " & objItem.AdapterRAM
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Color Table Entries: " & objItem.ColorTableEntries
    Wscript.Echo "Current Bits Per Pixel: " & objItem.CurrentBitsPerPixel
    Wscript.Echo "Current Horizontal Resolution: " & _
        objItem.CurrentHorizontalResolution
    Wscript.Echo "Current Number of Colors: " & objItem.CurrentNumberOfColors
    Wscript.Echo "Current Number of Columns: " & objItem.CurrentNumberOfColumns
    Wscript.Echo "Current Number of Rows: " & objItem.CurrentNumberOfRows
    Wscript.Echo "Current Refresh Rate: " & objItem.CurrentRefreshRate
    Wscript.Echo "Current Scan Mode: " & objItem.CurrentScanMode
    Wscript.Echo "Current Vertical Resolution: " & _
        objItem.CurrentVerticalResolution
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Device Specific Pens: " & objItem.DeviceSpecificPens
    Wscript.Echo "Dither Type: " & objItem.DitherType
    Wscript.Echo "Driver Date: " & objItem.DriverDate
    Wscript.Echo "Driver Version: " & objItem.DriverVersion
    Wscript.Echo "ICM Intent: " & objItem.ICMIntent
    Wscript.Echo "ICM Method: " & objItem.ICMMethod
    Wscript.Echo "INF Filename: " & objItem.InfFilename
    Wscript.Echo "INF Section: " & objItem.InfSection
    Wscript.Echo "Installed Display Drivers: " & _
        objItem.InstalledDisplayDrivers
    Wscript.Echo "Maximum Memory Supported: " & objItem.MaxMemorySupported
    Wscript.Echo "Maximum Number Controlled: " & objItem.MaxNumberControlled
    Wscript.Echo "Maximum Refresh Rate: " & objItem.MaxRefreshRate
    Wscript.Echo "Minimum Refresh Rate: " & objItem.MinRefreshRate
    Wscript.Echo "Monochrome: " & objItem.Monochrome
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Number of Color Planes: " & objItem.NumberOfColorPlanes
    Wscript.Echo "Number of Video Pages: " & objItem.NumberOfVideoPages
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Reserved System Palette Entries: " & _
        objItem.ReservedSystemPaletteEntries
    Wscript.Echo "Specification Version: " & objItem.SpecificationVersion
    Wscript.Echo "System Palette Entries: " & objItem.SystemPaletteEntries
    Wscript.Echo "Video Architecture: " & objItem.VideoArchitecture
    Wscript.Echo "Video Memory Type: " & objItem.VideoMemoryType
    Wscript.Echo "Video Mode: " & objItem.VideoMode
    Wscript.Echo "Video Mode Description: " & objItem.VideoModeDescription
    Wscript.Echo "Video Processor: " & objItem.VideoProcessor
Next

From The Microsoft Technet Script Center Script Repository under 'Hardware' then 'Video and Display' then 'List Video Controller Properties'.

I would imagine you might have to work out something between AdapterRAM and 'VideoMemoryType'

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_VideoController")

For Each objItem in colItems
    For Each strCapability in objItem.AcceleratorCapabilities
        Wscript.Echo "Accelerator Capability: " & strCapability
    Next
    Wscript.Echo "Adapter Compatibility: " & objItem.AdapterCompatibility
    Wscript.Echo "Adapter DAC Type: " & objItem.AdapterDACType
    Wscript.Echo "Adapter RAM: " & objItem.AdapterRAM
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Color Table Entries: " & objItem.ColorTableEntries
    Wscript.Echo "Current Bits Per Pixel: " & objItem.CurrentBitsPerPixel
    Wscript.Echo "Current Horizontal Resolution: " & _
        objItem.CurrentHorizontalResolution
    Wscript.Echo "Current Number of Colors: " & objItem.CurrentNumberOfColors
    Wscript.Echo "Current Number of Columns: " & objItem.CurrentNumberOfColumns
    Wscript.Echo "Current Number of Rows: " & objItem.CurrentNumberOfRows
    Wscript.Echo "Current Refresh Rate: " & objItem.CurrentRefreshRate
    Wscript.Echo "Current Scan Mode: " & objItem.CurrentScanMode
    Wscript.Echo "Current Vertical Resolution: " & _
        objItem.CurrentVerticalResolution
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Device Specific Pens: " & objItem.DeviceSpecificPens
    Wscript.Echo "Dither Type: " & objItem.DitherType
    Wscript.Echo "Driver Date: " & objItem.DriverDate
    Wscript.Echo "Driver Version: " & objItem.DriverVersion
    Wscript.Echo "ICM Intent: " & objItem.ICMIntent
    Wscript.Echo "ICM Method: " & objItem.ICMMethod
    Wscript.Echo "INF Filename: " & objItem.InfFilename
    Wscript.Echo "INF Section: " & objItem.InfSection
    Wscript.Echo "Installed Display Drivers: " & _
        objItem.InstalledDisplayDrivers
    Wscript.Echo "Maximum Memory Supported: " & objItem.MaxMemorySupported
    Wscript.Echo "Maximum Number Controlled: " & objItem.MaxNumberControlled
    Wscript.Echo "Maximum Refresh Rate: " & objItem.MaxRefreshRate
    Wscript.Echo "Minimum Refresh Rate: " & objItem.MinRefreshRate
    Wscript.Echo "Monochrome: " & objItem.Monochrome
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Number of Color Planes: " & objItem.NumberOfColorPlanes
    Wscript.Echo "Number of Video Pages: " & objItem.NumberOfVideoPages
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Reserved System Palette Entries: " & _
        objItem.ReservedSystemPaletteEntries
    Wscript.Echo "Specification Version: " & objItem.SpecificationVersion
    Wscript.Echo "System Palette Entries: " & objItem.SystemPaletteEntries
    Wscript.Echo "Video Architecture: " & objItem.VideoArchitecture
    Wscript.Echo "Video Memory Type: " & objItem.VideoMemoryType
    Wscript.Echo "Video Mode: " & objItem.VideoMode
    Wscript.Echo "Video Mode Description: " & objItem.VideoModeDescription
    Wscript.Echo "Video Processor: " & objItem.VideoProcessor
Next
眼泪都笑了 2024-07-16 11:46:20

我们已经沿着 AdapterRAM 属性的路径走了下去,但这只是为我们提供了系统内存,与视频 RAM 无关。 还有其他方法获得视频内存吗?

We already went down the path of the AdapterRAM property, but that was only giving us the system memory, which has nothing to do with the Video Ram. Is there another way of getting the video ram?

温馨耳语 2024-07-16 11:46:20
ManagementObjectSearcher searcher = new ManagementObjectSearcher("select AdapterRAM from 

    Win32_VideoController");

                    foreach (ManagementObject mo in searcher.Get())
                    {                            

                        double MemorySize = Convert.ToDouble(mo.Properties["AdapterRAM"].Value) / 1048576;

                        return MemorySize.ToString();
                    }
ManagementObjectSearcher searcher = new ManagementObjectSearcher("select AdapterRAM from 

    Win32_VideoController");

                    foreach (ManagementObject mo in searcher.Get())
                    {                            

                        double MemorySize = Convert.ToDouble(mo.Properties["AdapterRAM"].Value) / 1048576;

                        return MemorySize.ToString();
                    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文