我在Get Screen resolution using WMI/powershell in Windows 7中键入命令,但结果为空(我在Surface Pro 2017上,单屏显示)?
答案 0 :(得分:3)
我没有Surface,但这行得通吗?
Add-Type -AssemblyName System.Windows.Forms
$screen = [System.Windows.Forms.Screen]::PrimaryScreen
[pscustomobject]@{
DeviceName = $screen.DeviceName.Split('\\')[-1]
Width = $screen.Bounds.Width
Height = $screen.Bounds.Height
BitsPerPixel = $screen.BitsPerPixel
}
编辑
使用CIM_VideoController
$screen = Get-CimInstance -ClassName CIM_VideoController
[pscustomobject]@{
DeviceName = $screen.Caption
Width = $screen.CurrentHorizontalResolution
Height = $screen.CurrentVerticalResolution
BitsPerPixel = $screen.CurrentBitsPerPixel
}