Get maximum supported resolution of all attached monitors

萝らか妹 提交于 2019-12-04 11:33:35

Pulled together from my comment and your update, a PowerShell version. Which isn't what you want, but ... no thank you to VBScript.

# WmiMonitorId gives the make/model details
$IDs = gwmi -NameSpace "root\wmi" -Class WmiMonitorId

# This gives the available resolutions
$monitors = gwmi -N "root\wmi" -Class WmiMonitorListedSupportedSourceModes 


$results = foreach($monitor in $monitors) {
    # Get the id for this monitor
    $currentId =  $IDs |? {$_.InstanceName -eq $Monitor.InstanceName}

    # Sort the available modes by display area (width*height)
    $sortedModes = $monitor.MonitorSourceModes | sort -property {$_.HorizontalActivePixels * $_.VerticalActivePixels}
    $maxModes = $sortedModes | select @{N="MaxRes";E={"$($_.HorizontalActivePixels)x$($_.VerticalActivePixels)"}}

    # Tidy output - convert [uint16[]] name value to text, and pick the max res
    [pscustomobject]@{
        Name=($currentId.UserFriendlyName | % {[char]$_}) -join ''
        Modes=($maxModes | select -last 1).MaxRes
        YearOfManufacture=$currentId.YearOfManufacture
        WeekOfManufacture=$currentId.WeekOfManufacture
    }
}

$results

(NB. requires running as administrator).

Example output:

Name        MaxRes
----        ----
HP xyz      1080x720
HP abc      1920x1080
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!