答案1
正如所述https://stackoverflow.com/questions/7967699/get-screen-resolution-using-wmi-powershell-in-windows-7
PS> Add-Type -AssemblyName System.Windows.Forms
PS> [System.Windows.Forms.Screen]::AllScreens
BitsPerPixel : 32
Bounds : {X=0,Y=0,Width=1280,Height=800}
DeviceName : \\.\DISPLAY1
Primary : True
WorkingArea : {X=0,Y=0,Width=1280,Height=770}
BitsPerPixel : 32
Bounds : {X=1280,Y=0,Width=1920,Height=1200}
DeviceName : \\.\DISPLAY2
Primary : False
WorkingArea : {X=1280,Y=0,Width=1920,Height=1170}
答案2
我在 powershell 中找到了一种方法。
"Background {0}x{1}" -f [System.Windows.Forms.SystemInformation]::PrimaryMonitorSize.Width,[System.Windows.Forms.SystemInformation]::PrimaryMonitorSize.Height