110,502
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
#endregion
namespace ImageViewer
{
public class W7RefreshRateHelper
{
private const uint SIZE_OF_DISPLAYCONFIG_PATH_INFO = 72;
private const uint SIZE_OF_DISPLAYCONFIG_MODE_INFO = 64;
private const uint QDC_ALL_PATHS = 1;
private const uint DISPLAYCONFIG_MODE_INFO_TYPE_TARGET = 2;
private const uint DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE = 1;
public const uint SDC_TOPOLOGY_INTERNAL = 0x00000001;
public const uint SDC_TOPOLOGY_CLONE = 0x00000002;
public const uint SDC_TOPOLOGY_EXTEND = 0x00000004;
public const uint SDC_TOPOLOGY_EXTERNAL = 0x00000008;
public const uint SDC_TOPOLOGY_SUPPLIED = 0x00000010;
public const uint SDC_USE_DATABASE_CURRENT = (SDC_TOPOLOGY_INTERNAL | SDC_TOPOLOGY_CLONE | SDC_TOPOLOGY_EXTEND | SDC_TOPOLOGY_EXTERNAL);
private const uint SDC_USE_SUPPLIED_DISPLAY_CONFIG = 0x00000020;
private const uint SDC_VALIDATE = 0x00000040;
private const uint SDC_APPLY = 0x00000080;
private const uint SDC_ALLOW_CHANGES = 0x00000400;
private const uint SDC_NO_OPTIMIZATION = 0x00000100;
private const uint SDC_SAVE_TO_DATABASE = 0x00000200;
private const uint SDC_PATH_PERSIST_IF_REQUIRED = 0x00000800;
private const uint SDC_FORCE_MODE_ENUMERATION = 0x00001000;
private const uint SDC_ALLOW_PATH_ORDER_CHANGES = 0x00002000;
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern long GetDisplayConfigBufferSizes([In] uint flags, [Out] out uint numPathArrayElements,
[Out] out uint numModeArrayElements);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern long QueryDisplayConfig([In] uint flags, ref uint numPathArrayElements, IntPtr pathArray,
ref uint numModeArrayElements, IntPtr modeArray,
IntPtr currentTopologyId);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern long SetDisplayConfig(uint numPathArrayElements, IntPtr pathArray, uint numModeArrayElements,
IntPtr modeArray, uint flags);
public static bool SetScreen(uint displayModel)
{
return SetDisplayConfig(0, IntPtr.Zero, 0, IntPtr.Zero, SDC_APPLY | displayModel) == 0;
}
}
}
ImageViewer.W7RefreshRateHelper.SetScreen(4); //多台显示器扩展
有解决吗?我也碰到了此类问题