本文介绍了获取所有连接的显示器的最大分辨率支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我试图让两者使用WMI我的显示器的最大支持的分辨率(因为这将是一个VBScript的一部分)我已经试过以下WMI命令,但我要么得到一个错误的结果或只得到信息对于一台显示器。

  C:\\> WMIC路径win32_videocontroller得到videomodedescription /格式:列表
VideoModeDescription = 1366×768点¯x4294967296颜色C:\\> WMIC路径win32_displaycontrollerconfiguration获得:视频模式/格式:列表
:视频模式= 1024×768像素,真彩色,60赫兹

据显示设置,我的笔记本电脑显示器是1366×768 ...不知道在哪里WMI是从越来越1024x768的。另外,如果我改变我的笔记本电脑显示器的分辨率显示设置为800x600,我得到这样的:

  C:\\> WMIC路径win32_videocontroller得到videomodedescription
VideoModeDescription = 800×600×4294967296颜色

这样准确地汇报我的当前分辨率的命令不告诉我,我的最大分辨率是什么。 (如果哑终端用户下来把他们解决我不在乎,我只想知道他们分辨率的显示器能够支持)。

如你所见,这些方法至今已经表明我,我也连接到我的笔记本电脑外接显示器的任何信息。如果我使用 Win32_DesktopMonitor ,我得到各种有关外接显示器的信息,但不是它的分辨率。

  C:\\> WMIC路径win32_desktopmonitor获得/格式:列表可用性= 8
带宽=
标题= HP L1710液晶显示器
ConfigManagerError code = 0
ConfigManagerUserConfig = FALSE
CreationClassName = Win32_DesktopMonitor
说明= HP L1710液晶显示器
的DeviceID = DesktopMonitor1
显示类型=
ErrorCleared =
ErrorDescription中=
InstallDate =
IsLocked =
LastError code =
MonitorManufacturer =惠普
MonitorType = HP L1710液晶显示器
名称= HP L1710液晶显示器
PixelsPerXLogicalInch = 96
PixelsPerYLogicalInch = 96
PNPDeviceID = DISPLAY \\ HWP26EB \\ 4&放大器;放大器; 298A3A3E&放大器;放大器; 0&放大器;放大器; UID16843008
PowerManagementCapabilities =
PowerManagementSupported =
ScreenHeight =
屏幕宽度=
状态= OK
StatusInfo =
SystemCreationClassName =的Win32_ComputerSystem

那么,有没有使用VBScript(通过WMI与否)让每一个连接的显示器的最大分辨率支持的方式?


更新:我只是跑这对用户具有直接插入他们的笔记本电脑外接显示器一台远程机器,而我的是插入坞站

  C:\\> winrs -r:WMIC的remotehostname路径win32_videocontroller得到videomodedescriptionVideoModeDescription
1920×1080点¯x4294967296颜色
1440点¯x900×4294967296颜色


更新过的2:使用我发现这个命令,它会显示每一个支持的模式。输出是太长了张贴,但我已经包括一个支持模式的输出。

  WMIC /命名空间:\\\\ ROOT \\ WMI路径WmiMonitorListedSupportedSourceModes得到MonitorSourceModes /格式:列表__PATH =
__NAMESPACE =
__SERVER =
__DERIVATION = {}
__PROPERTY_COUNT = 28
__RELPATH =
__DYNASTY = VideoModeDescriptor
__SUPERCLASS =
__CLASS = VideoModeDescriptor
__GENUS = 2
CompositePolarityType = 2
Horizo​​ntalActivePixels = 1366
Horizo​​ntalBlankingPixels = 160
Horizo​​ntalBorder = 0
Horizo​​ntalImageSize = 310
Horizo​​ntalPolarityType = 1
Horizo​​ntalRefreshRateDenominator = 763
Horizo​​ntalRefreshRateNumerator = 24100000
Horizo​​ntalSyncOffset = 48
Horizo​​ntalSyncPulseWidth = 32
IsInterlaced =假
IsSerrationRequired = 2
IsSyncOnRGB = 2
产地= 2
PixelClockRate = 48200000
StereoModeType = 0
SyncSignalType = 3
TimingType = 4
VerticalActivePixels = 768
VerticalBlankingPixels = 22
VerticalBorder = 0
VerticalImageSize = 174
VerticalPolarityType = 1
VerticalRefreshRateDenominator = 60277
VerticalRefreshRateNumerator = 241
VerticalSyncOffset = 3
VerticalSyncPulseWidth = 5
VideoStandardType = 0

Horizo​​ntalActivePixels VerticalActivePixels 给我,我要找的尺寸。还有的 WmiMonitorListedSupportedSourceModes的两个实例类,每一个监视器。现在的问题是怎么看通过 MonitorSourceModes 阵列查找每个实例的最大分辨率。 (


对于任何人找的VBScript相当于@ 的出色PowerShell的回答是:

 将strComputer =。strQuery =SELECT preferredMonitorSourceModeIndex,MonitorSourceModes&放大器; _
           FROM WmiMonitorListedSupportedSourceModes设置objWMIService为= GetObject的(winmgmts:\\\\&放大器;将strComputer&安培;\\ ROOT \\ WMI)
设置colItems的= objWMIService.ExecQuery(strQuery,48)对于每个objItem在colItems的
    intIndex = objItem。preferredMonitorSourceModeIndex
    Wscript.StdOut.WriteLine实例名称:&放大器; _
        objItem.InstanceName
    Wscript.StdOut.WriteLine水平:&放大器; _
        objItem.MonitorSourceModes(intIndex).Horizo​​ntalActivePixels
    Wscript.StdOut.WriteLine垂直:&放大器; _
        objItem.MonitorSourceModes(objIintIndex).VerticalActivePixels
    Wscript.StdOut.WriteLine__________
下一个


解决方案

这是我的意见,你的更新,一个PowerShell版本拉到一起。这是不是你想要的,但是......不,谢谢为VBScript。

#WmiMonitorId给人的品牌/型号细节
$标识= gwmi - 命名根\\ WMI一流的WmiMonitorId#这使可用的分辨率
$显示器= gwmi -N根\\ WMI一流的WmiMonitorListedSupportedSourceModes
$结果=的foreach($监测监控$){
    #获取ID为这款显示器
    $ currentId = $标识|? {$ _。实例名-eq $ Monitor.InstanceName}    #显示结果显示区域可用的模式(宽*高)
    $ sortedModes = $ monitor.MonitorSourceModes |排序-property {$ _。Horizo​​ntalActivePixels * $ _。VerticalActivePixels}
    $ maxModes = $ sortedModes |选择@ {N =MaxRes; E = {$($ _ Horizo​​ntalActivePixels)x $($ _ VerticalActivePixels)。}}    #整洁的输出 - 转换[UINT16 [] name值的文本,并挑选最大水库
    [pscustomobject] @ {
        名称=($ currentId.UserFriendlyName |%{[字符] $ _}) - 加入''
        模式=($ maxModes |选择-last 1).MaxRes
        YearOfManufacture = $ currentId.YearOfManufacture
        WeekOfManufacture = $ currentId.WeekOfManufacture
    }
}$结果

(特别注意:需要以管理员身份运行)。

输出示例:

名称MaxRes
---- ----
HP XYZ 1080x720
HP 1920×1080的ABC

I'm trying to get the maximum supported resolution of both of my monitors using WMI (since it will be part of a VBScript)I've tried the following WMI commands, but I either get a wrong result or only get info for one monitor.

C:\>wmic path win32_videocontroller get videomodedescription /format:list
VideoModeDescription=1366 x 768 x 4294967296 colors

C:\>wmic path win32_displaycontrollerconfiguration get videomode /format:list
VideoMode=1024 by 768 pixels, True Color, 60 Hertz

According to Display Settings, my laptop monitor is 1366x768... No clue where WMI is getting 1024x768 from. Plus, if I change the resolution of my laptop monitor is Display Settings to 800x600, I get this:

C:\>wmic path win32_videocontroller get videomodedescription
VideoModeDescription=800 x 600 x 4294967296 colors

So the command that is accurately reporting my current resolution is not telling me what my maximum resolution is. (I don't care if dumb end users are turning their resolution down, I just want to know what resolution their monitor is capable of supporting.)

As you can see, none of these methods so far has shown me any information about the external monitor I also have attached to my laptop. If I use Win32_DesktopMonitor, I get all kinds of info about the external monitor, but not its resolution.

C:\>wmic path win32_desktopmonitor get /format:list

Availability=8
Bandwidth=
Caption=HP L1710 LCD Monitor
ConfigManagerErrorCode=0
ConfigManagerUserConfig=FALSE
CreationClassName=Win32_DesktopMonitor
Description=HP L1710 LCD Monitor
DeviceID=DesktopMonitor1
DisplayType=
ErrorCleared=
ErrorDescription=
InstallDate=
IsLocked=
LastErrorCode=
MonitorManufacturer=Hewlett-Packard
MonitorType=HP L1710 LCD Monitor
Name=HP L1710 LCD Monitor
PixelsPerXLogicalInch=96
PixelsPerYLogicalInch=96
PNPDeviceID=DISPLAY\HWP26EB\4&298A3A3E&0&UID16843008
PowerManagementCapabilities=
PowerManagementSupported=
ScreenHeight=
ScreenWidth=
Status=OK
StatusInfo=
SystemCreationClassName=Win32_ComputerSystem

So, is there a way using VBScript (either via WMI or not) to get the maximum supported resolution of every attached monitor?


Update: I just ran this against a remote machine where the user has an external monitor plugged directly into their laptop, whereas mine is plugged into a docking station.

C:\>winrs -r:remotehostname wmic path win32_videocontroller get videomodedescription

VideoModeDescription
1920 x 1080 x 4294967296 colors
1440 x 900 x 4294967296 colors


Upated 2: Using WMI Explorer I found this command which displays every supported mode. The output is far too long to post, but I've included the output for one supported mode.

wmic /namespace:\\ROOT\WMI path WmiMonitorListedSupportedSourceModes get MonitorSourceModes /format:list

__PATH=
__NAMESPACE=
__SERVER=
__DERIVATION={}
__PROPERTY_COUNT=28
__RELPATH=
__DYNASTY=VideoModeDescriptor
__SUPERCLASS=
__CLASS=VideoModeDescriptor
__GENUS=2
CompositePolarityType = 2
HorizontalActivePixels = 1366
HorizontalBlankingPixels = 160
HorizontalBorder = 0
HorizontalImageSize = 310
HorizontalPolarityType = 1
HorizontalRefreshRateDenominator = 763
HorizontalRefreshRateNumerator = 24100000
HorizontalSyncOffset = 48
HorizontalSyncPulseWidth = 32
IsInterlaced = False
IsSerrationRequired = 2
IsSyncOnRGB = 2
Origin = 2
PixelClockRate = 48200000
StereoModeType = 0
SyncSignalType = 3
TimingType = 4
VerticalActivePixels = 768
VerticalBlankingPixels = 22
VerticalBorder = 0
VerticalImageSize = 174
VerticalPolarityType = 1
VerticalRefreshRateDenominator = 60277
VerticalRefreshRateNumerator = 2410000
VerticalSyncOffset = 3
VerticalSyncPulseWidth = 5
VideoStandardType = 0

HorizontalActivePixels and VerticalActivePixels give me the dimensions I'm looking for. There are two instances of the WmiMonitorListedSupportedSourceModes class, one for each monitor. Now the question is how to look through the MonitorSourceModes array to find the max resolution for each instance. :(


For anyone looking for the VBScript equivalent to @TessellatingHeckler's excellent PowerShell answer:

strComputer = "."

strQuery = "SELECT PreferredMonitorSourceModeIndex, MonitorSourceModes " & _
           "FROM WmiMonitorListedSupportedSourceModes"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\ROOT\WMI")
Set colItems = objWMIService.ExecQuery(strQuery, , 48)

For Each objItem In colItems
    intIndex = objItem.PreferredMonitorSourceModeIndex
    Wscript.StdOut.WriteLine "InstanceName: " & _
        objItem.InstanceName
    Wscript.StdOut.WriteLine "Horizontal: " & _
        objItem.MonitorSourceModes(intIndex).HorizontalActivePixels
    Wscript.StdOut.WriteLine "Vertical: " & _
        objItem.MonitorSourceModes(objIintIndex).VerticalActivePixels
    Wscript.StdOut.WriteLine "__________"
Next
解决方案

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

这篇关于获取所有连接的显示器的最大分辨率支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 11:53