@@ -77,6 +77,27 @@ public static void GetAllPaths()
7777 var result = NativeMethods . QueryDisplayConfig ( QueryDisplayFlags . AllPaths , ref numPathArrayElements , pathArray , ref numModeInfoArrayElements , modeArray , out Unsafe . NullRef < DisplayConfigTopologyId > ( ) ) ;
7878 }
7979
80+ public static void SetDisplayConfig ( )
81+ {
82+ uint numPathArrayElements ;
83+ uint numModeInfoArrayElements ;
84+
85+ NativeMethods . GetDisplayConfigBufferSizes ( QueryDisplayFlags . AllPaths , out numPathArrayElements , out numModeInfoArrayElements ) ;
86+
87+ var pathArray = new DisplayConfigPathInfo [ numPathArrayElements ] ;
88+ var modeArray = new DisplayConfigModeInfo [ numModeInfoArrayElements ] ;
89+
90+ var result = NativeMethods . QueryDisplayConfig ( QueryDisplayFlags . AllPaths , ref numPathArrayElements , pathArray , ref numModeInfoArrayElements , modeArray , out Unsafe . NullRef < DisplayConfigTopologyId > ( ) ) ;
91+
92+ var sourceIndex = pathArray [ 0 ] . sourceInfo . modeInfoIdx ;
93+ var targetIndex = pathArray [ 0 ] . targetInfo . modeInfoIdx ;
94+
95+ modeArray [ targetIndex ] . targetMode . targetVideoSignalInfo . vSyncFreq = new DisplayConfigRational { denominator = 1000 , numerator = 145000 } ;
96+
97+ result = NativeMethods . SetDisplayConfig ( 1 , pathArray , 2 , modeArray , SdcFlags . Apply | SdcFlags . UseSuppliedDisplayConfig | SdcFlags . AllowChanges ) ;
98+ }
99+
100+
80101 public static LUID GetAdapterId ( string displayName = null )
81102 {
82103 return ExecuteForModeConfig ( ( modeInfo ) =>
@@ -786,8 +807,8 @@ enum DisplayConfigScaling : uint
786807 [ StructLayout ( LayoutKind . Sequential ) ]
787808 struct DisplayConfigRational
788809 {
789- uint numerator ;
790- uint denominator ;
810+ public uint numerator ;
811+ public uint denominator ;
791812 }
792813
793814 [ Flags ]
@@ -886,36 +907,36 @@ enum D3DmdtVideoSignalStandard : uint
886907 [ StructLayout ( LayoutKind . Sequential ) ]
887908 struct DisplayConfigVideoSignalInfo
888909 {
889- long pixelRate ;
890- DisplayConfigRational hSyncFreq ;
891- DisplayConfigRational vSyncFreq ;
892- DisplayConfig2DRegion activeSize ;
893- DisplayConfig2DRegion totalSize ;
910+ public long pixelRate ;
911+ public DisplayConfigRational hSyncFreq ;
912+ public DisplayConfigRational vSyncFreq ;
913+ public DisplayConfig2DRegion activeSize ;
914+ public DisplayConfig2DRegion totalSize ;
894915
895- D3DmdtVideoSignalStandard videoStandard ;
896- DisplayConfigScanLineOrdering ScanLineOrdering ;
916+ public D3DmdtVideoSignalStandard videoStandard ;
917+ public DisplayConfigScanLineOrdering ScanLineOrdering ;
897918 }
898919
899920 [ StructLayout ( LayoutKind . Sequential ) ]
900921 struct DisplayConfigTargetMode
901922 {
902- DisplayConfigVideoSignalInfo targetVideoSignalInfo ;
923+ public DisplayConfigVideoSignalInfo targetVideoSignalInfo ;
903924 }
904925
905926 [ StructLayout ( LayoutKind . Sequential ) ]
906927 struct PointL
907928 {
908- int x ;
909- int y ;
929+ public int x ;
930+ public int y ;
910931 }
911932
912933 [ StructLayout ( LayoutKind . Sequential ) ]
913934 struct DisplayConfigSourceMode
914935 {
915- uint width ;
916- uint height ;
917- DisplayConfigPixelFormat pixelFormat ;
918- PointL position ;
936+ public uint width ;
937+ public uint height ;
938+ public DisplayConfigPixelFormat pixelFormat ;
939+ public PointL position ;
919940 }
920941
921942 [ StructLayout ( LayoutKind . Sequential ) ]
0 commit comments