验证:补充2K刷新率与单显示器验收
This commit is contained in:
1 parent
a98d9ddeee
commit
b29b59c62f
21 files changed
+1195
-4
No files matched your search
@@ -1,3 +1,4 @@
|
||||
param([ValidateSet(30, 60)][int]$RefreshRate = 60)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Add-Type @'
|
||||
using System;
|
||||
@@ -45,12 +46,12 @@ public static class VdiDisplayMode {
|
||||
if (!EnumDisplaySettings(name, -1, ref m)) return "unavailable";
|
||||
return m.width + "x" + m.height + "@" + m.hz;
|
||||
}
|
||||
public static int Apply(string name) {
|
||||
public static int Apply(string name, int refreshRate) {
|
||||
for (int i = 0; ; i++) {
|
||||
var m = new Mode();
|
||||
m.size = (short)Marshal.SizeOf(typeof(Mode));
|
||||
if (!EnumDisplaySettings(name, i, ref m)) return -99;
|
||||
if (m.width == 2560 && m.height == 1440 && m.hz == 30) {
|
||||
if (m.width == 2560 && m.height == 1440 && m.hz == refreshRate) {
|
||||
m.fields = 0x80000 | 0x100000 | 0x400000;
|
||||
int test = ChangeDisplaySettingsEx(name, ref m, IntPtr.Zero, 2, IntPtr.Zero);
|
||||
if (test != 0) return test;
|
||||
@@ -61,13 +62,18 @@ public static class VdiDisplayMode {
|
||||
}
|
||||
'@
|
||||
$log = 'C:/ProgramData/VDI/set-2k-result.txt'
|
||||
$expectedMode = "2560x1440@$RefreshRate"
|
||||
try {
|
||||
for ($i = 0; $i -lt 12; $i++) {
|
||||
$dev = [VdiDisplayMode]::Find()
|
||||
if ($dev) {
|
||||
$result = [VdiDisplayMode]::Apply($dev)
|
||||
if ([VdiDisplayMode]::Current($dev) -eq $expectedMode) {
|
||||
"$(Get-Date -Format o) device=$dev result=0 mode=$expectedMode (already correct)" | Set-Content $log
|
||||
exit 0
|
||||
}
|
||||
$result = [VdiDisplayMode]::Apply($dev, $RefreshRate)
|
||||
$mode = [VdiDisplayMode]::Current($dev)
|
||||
if ($result -eq 0 -and $mode -eq '2560x1440@30') {
|
||||
if ($result -eq 0 -and $mode -eq $expectedMode) {
|
||||
"$(Get-Date -Format o) device=$dev result=0 mode=$mode" | Set-Content $log
|
||||
exit 0
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user