1 /* 2 * Copyright 2014 Martin Steiger 3 * 4 * The contents of this file is dual-licensed under 2 5 * alternative Open Source/Free licenses: LGPL 2.1 or later and 6 * Apache License 2.0. (starting with JNA version 4.0.0). 7 * 8 * You can freely decide which license you want to apply to 9 * the project. 10 * 11 * You may obtain a copy of the LGPL License at: 12 * 13 * http://www.gnu.org/licenses/licenses.html 14 * 15 * A copy is also included in the downloadable source code package 16 * containing JNA, in file "LGPL2.1". 17 * 18 * You may obtain a copy of the Apache License at: 19 * 20 * http://www.apache.org/licenses/ 21 * 22 * A copy is also included in the downloadable source code package 23 * containing JNA, in file "AL2.0". 24 */ 25 26 package com.sun.jna.platform.win32; 27 28 import java.util.Collections; 29 import java.util.HashMap; 30 import java.util.Map; 31 32 import com.sun.jna.DefaultTypeMapper; 33 import com.sun.jna.Library; 34 import com.sun.jna.Native; 35 import com.sun.jna.platform.EnumConverter; 36 import com.sun.jna.platform.win32.WTypes.LPSTR; 37 import com.sun.jna.platform.win32.WinDef.BOOL; 38 import com.sun.jna.platform.win32.WinDef.BYTE; 39 import com.sun.jna.platform.win32.WinDef.DWORD; 40 import com.sun.jna.platform.win32.WinDef.DWORDByReference; 41 import com.sun.jna.platform.win32.WinNT.HANDLE; 42 import com.sun.jna.platform.win32.WinUser.HMONITOR; 43 import com.sun.jna.win32.StdCallLibrary; 44 45 /** 46 * A port of dxva2.dll 47 * @author Martin Steiger 48 */ 49 public interface Dxva2 extends StdCallLibrary, PhysicalMonitorEnumerationAPI, HighLevelMonitorConfigurationAPI, LowLevelMonitorConfigurationAPI { 50 51 Map<String, Object> DXVA_OPTIONS = Collections.unmodifiableMap(new HashMap<String, Object>() { 52 private static final long serialVersionUID = -1987971664975780480L; 53 54 { 55 put(Library.OPTION_TYPE_MAPPER, new DefaultTypeMapper() { 56 { 57 addTypeConverter(MC_POSITION_TYPE.class, new EnumConverter<MC_POSITION_TYPE>(MC_POSITION_TYPE.class)); 58 addTypeConverter(MC_SIZE_TYPE.class, new EnumConverter<MC_SIZE_TYPE>(MC_SIZE_TYPE.class)); 59 addTypeConverter(MC_GAIN_TYPE.class, new EnumConverter<MC_GAIN_TYPE>(MC_GAIN_TYPE.class)); 60 addTypeConverter(MC_DRIVE_TYPE.class, new EnumConverter<MC_DRIVE_TYPE>(MC_DRIVE_TYPE.class)); 61 } 62 }); 63 } 64 }); 65 66 /** 67 * The only instance of the library 68 */ 69 Dxva2 INSTANCE = Native.load("Dxva2", Dxva2.class, DXVA_OPTIONS); 70 71 72 /****************************************************************************** 73 Monitor capability functions 74 ******************************************************************************/ 75 /** 76 * Retrieves the configuration capabilities of a monitor. Call this function to find out which high-level 77 * monitor configuration functions are supported by the monitor. 78 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call 79 * {@link #GetPhysicalMonitorsFromHMONITOR} 80 * @param pdwMonitorCapabilities Receives a bitwise OR of capabilities flags. (MC_CAPS_*) 81 * @param pdwSupportedColorTemperatures Receives a bitwise OR of color temperature flags. 82 * (MC_SUPPORTED_COLOR_TEMPERATURE_*) 83 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is 84 * FALSE. To get extended error information, call GetLastError. 85 * 86 * <p>The function fails if the monitor does not support DDC/CI.</p> 87 */ GetMonitorCapabilities(HANDLE hMonitor, DWORDByReference pdwMonitorCapabilities, DWORDByReference pdwSupportedColorTemperatures)88 BOOL GetMonitorCapabilities(HANDLE hMonitor, DWORDByReference pdwMonitorCapabilities, DWORDByReference pdwSupportedColorTemperatures); 89 90 /****************************************************************************** 91 Monitor setting persistence functions 92 ******************************************************************************/ 93 94 /** 95 * Saves the current monitor settings to the display's nonvolatile storage. 96 * <p> 97 * This function takes about 200 milliseconds to return. 98 * This high-level function is identical to the low-level function SaveCurrentSettings.</p> 99 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 100 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 101 */ SaveCurrentMonitorSettings(HANDLE hMonitor)102 BOOL SaveCurrentMonitorSettings(HANDLE hMonitor); 103 104 /****************************************************************************** 105 Monitor meta-data functions 106 ******************************************************************************/ 107 108 /** 109 * Retrieves the type of technology used by a monitor. 110 * This function does not support every display technology. If a monitor uses a display technology that is 111 * supported by this function, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_TECHNOLOGY_TYPE 112 * flag. If that flag is absent, the GetMonitorTechnologyType function fails. 113 * Some monitor technologies do not support certain monitor configuration functions. For example, 114 * the DegaussMonitor function is supported only for cathode ray tube (CRT) monitors. To find out whether a 115 * specific function is supported, call GetMonitorCapabilities. 116 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 117 * @param pdtyDisplayTechnologyType Receives the technology type as defined in {@link HighLevelMonitorConfigurationAPI.MC_DISPLAY_TECHNOLOGY_TYPE}. 118 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 119 */ GetMonitorTechnologyType(HANDLE hMonitor, MC_DISPLAY_TECHNOLOGY_TYPE.ByReference pdtyDisplayTechnologyType)120 BOOL GetMonitorTechnologyType(HANDLE hMonitor, MC_DISPLAY_TECHNOLOGY_TYPE.ByReference pdtyDisplayTechnologyType); 121 122 /****************************************************************************** 123 Monitor image calibration functions 124 ******************************************************************************/ 125 126 /** 127 * Retrieves a monitor's minimum, maximum, and current brightness settings. 128 * <p> 129 * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_BRIGHTNESS flag. 130 * This function takes about 40 milliseconds to return. The brightness setting is a continuous monitor setting.</p> 131 * @param hMonitor Handle to a physical monitor 132 * @param pdwMinimumBrightness Receives the monitor's minimum brightness. 133 * @param pdwCurrentBrightness Receives the monitor's current brightness. 134 * @param pdwMaximumBrightness Receives the monitor's maximum brightness. 135 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 136 */ GetMonitorBrightness(HANDLE hMonitor, DWORDByReference pdwMinimumBrightness, DWORDByReference pdwCurrentBrightness, DWORDByReference pdwMaximumBrightness)137 BOOL GetMonitorBrightness(HANDLE hMonitor, DWORDByReference pdwMinimumBrightness, 138 DWORDByReference pdwCurrentBrightness, DWORDByReference pdwMaximumBrightness); 139 140 /** 141 * Retrieves a monitor's minimum, maximum, and current contrast settings. 142 * @param hMonitor Handle to a physical monitor. 143 * @param pdwMinimumContrast Receives the monitor's minimum contrast. 144 * @param pdwCurrentContrast Receives the monitor's current contrast. 145 * @param pdwMaximumContrast Receives the monitor's maximum contrast. 146 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 147 */ GetMonitorContrast(HANDLE hMonitor, DWORDByReference pdwMinimumContrast, DWORDByReference pdwCurrentContrast, DWORDByReference pdwMaximumContrast)148 BOOL GetMonitorContrast(HANDLE hMonitor, DWORDByReference pdwMinimumContrast, DWORDByReference pdwCurrentContrast, 149 DWORDByReference pdwMaximumContrast); 150 151 /** 152 * Retrieves a monitor's current color temperature. 153 * <p> 154 * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_COLOR_TEMPERATURE flag. 155 * This function takes between 0 and 80 milliseconds to return.</p> 156 * @param hMonitor Handle to a physical monitor. 157 * @param pctCurrentColorTemperature Receives the monitor's current color temperature. 158 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 159 */ GetMonitorColorTemperature(HANDLE hMonitor, MC_COLOR_TEMPERATURE.ByReference pctCurrentColorTemperature)160 BOOL GetMonitorColorTemperature(HANDLE hMonitor, MC_COLOR_TEMPERATURE.ByReference pctCurrentColorTemperature); 161 162 /** 163 * Retrieves a monitor's red, green, or blue drive value. 164 * <p> 165 * Drive settings are generally used to adjust the monitor's white point. Drive and black level are different 166 * names for the same monitor setting. If this function is supported, the GetMonitorCapabilities function returns 167 * the MC_CAPS_RED_GREEN_BLUE_DRIVE flag.</p> 168 * @param hMonitor Handle to a physical monitor. 169 * @param dtDriveType A member of the MC_DRIVE_TYPE enumeration, specifying whether to retrieve the red, green, or blue drive value. 170 * @param pdwMinimumDrive Receives the minimum red, green, or blue drive value. 171 * @param pdwCurrentDrive Receives the current red, green, or blue drive value. 172 * @param pdwMaximumDrive Receives the maximum red, green, or blue drive value. 173 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 174 */ GetMonitorRedGreenOrBlueDrive(HANDLE hMonitor, MC_DRIVE_TYPE dtDriveType, DWORDByReference pdwMinimumDrive, DWORDByReference pdwCurrentDrive, DWORDByReference pdwMaximumDrive)175 BOOL GetMonitorRedGreenOrBlueDrive(HANDLE hMonitor, MC_DRIVE_TYPE dtDriveType, DWORDByReference pdwMinimumDrive, 176 DWORDByReference pdwCurrentDrive, DWORDByReference pdwMaximumDrive); 177 178 /** 179 * Retrieves a monitor's red, green, or blue gain value. 180 * <p> 181 * Gain settings are generally used to adjust the monitor's white point. If this function is supported, the 182 * GetMonitorCapabilities function returns the MC_CAPS_RED_GREEN_BLUE_GAIN flag. This function takes about 40 milliseconds to return. 183 * The gain settings are continuous monitor settings.</p> 184 * @param hMonitor Handle to a physical monitor. 185 * @param gtGainType A member of the MC_GAIN_TYPE enumeration, specifying whether to retrieve the red, green, or blue gain value. 186 * @param pdwMinimumGain Receives the minimum red, green, or blue gain value. 187 * @param pdwCurrentGain Receives the current red, green, or blue gain value. 188 * @param pdwMaximumGain Receives the maximum red, green, or blue gain value. 189 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 190 */ GetMonitorRedGreenOrBlueGain(HANDLE hMonitor, MC_GAIN_TYPE gtGainType, DWORDByReference pdwMinimumGain, DWORDByReference pdwCurrentGain, DWORDByReference pdwMaximumGain)191 BOOL GetMonitorRedGreenOrBlueGain(HANDLE hMonitor, MC_GAIN_TYPE gtGainType, DWORDByReference pdwMinimumGain, 192 DWORDByReference pdwCurrentGain, DWORDByReference pdwMaximumGain); 193 194 /** 195 * Sets a monitor's brightness value. 196 * <p> 197 * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_BRIGHTNESS flag. 198 * This function takes about 50 milliseconds to return. 199 * The brightness setting is a continuous monitor setting. </p> 200 * @param hMonitor Handle to a physical monitor. 201 * @param dwNewBrightness Brightness value. To get the monitor's minimum and maximum brightness values, call GetMonitorBrightness. 202 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 203 */ SetMonitorBrightness(HANDLE hMonitor, int dwNewBrightness)204 BOOL SetMonitorBrightness(HANDLE hMonitor, int dwNewBrightness); 205 206 /** 207 * Sets a monitor's contrast value. 208 * <p> 209 * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_CONTRAST flag. 210 * This function takes about 50 milliseconds to return. The brightness setting is a continuous monitor setting.</p> 211 * @param hMonitor Handle to a physical monitor. 212 * @param dwNewContrast Contrast value. To get the monitor's minimum and maximum contrast values, call GetMonitorContrast. 213 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 214 */ SetMonitorContrast(HANDLE hMonitor, int dwNewContrast)215 BOOL SetMonitorContrast(HANDLE hMonitor, int dwNewContrast); 216 217 /** 218 * Sets a monitor's color temperature. 219 * <p> 220 * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_COLOR_TEMPERATURE flag. 221 * The GetMonitorCapabilities function also returns the range of color temperatures that the monitor supports. 222 * The ctCurrentColorTemperature parameter must correspond to one of these values. Changing the color temperature 223 * changes the monitor's white point. It can also change the current drive and gain settings. To get the new drive 224 * and gain settings, call GetMonitorRedGreenOrBlueDrive and GetMonitorRedGreenOrBlueGain, respectively. 225 * This function takes from 50 to 90 milliseconds to return.</p> 226 * @param hMonitor Handle to a physical monitor. 227 * @param ctCurrentColorTemperature Color temperature, specified as a member of the MC_COLOR_TEMPERATURE enumeration. 228 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 229 */ SetMonitorColorTemperature(HANDLE hMonitor, MC_COLOR_TEMPERATURE ctCurrentColorTemperature)230 BOOL SetMonitorColorTemperature(HANDLE hMonitor, MC_COLOR_TEMPERATURE ctCurrentColorTemperature); 231 232 /** 233 * Sets a monitor's red, green, or blue drive value. 234 * <p> 235 * Drive settings are generally used to adjust the 236 * monitor's white point. Drive and black level are different names for the same monitor setting. If this function 237 * is supported, the GetMonitorCapabilities function returns the MC_CAPS_RED_GREEN_BLUE_DRIVE flag. This function 238 * takes about 50 milliseconds to return. Changing the drive settings can change the color temperature. To get the 239 * new color temperature, call GetMonitorColorTemperature. The drive settings are continuous monitor settings</p> 240 * @param hMonitor Handle to a physical monitor. 241 * @param dtDriveType A member of the MC_DRIVE_TYPE enumeration, specifying whether to set the red, green, or blue 242 * drive value. 243 * @param dwNewDrive Red, green, or blue drive value. To get the monitor's minimum and maximum drive values, call 244 * GetMonitorRedGreenOrBlueDrive. 245 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 246 */ SetMonitorRedGreenOrBlueDrive(HANDLE hMonitor, MC_DRIVE_TYPE dtDriveType, int dwNewDrive)247 BOOL SetMonitorRedGreenOrBlueDrive(HANDLE hMonitor, MC_DRIVE_TYPE dtDriveType, int dwNewDrive); 248 249 /** 250 * Sets a monitor's red, green, or blue gain value. 251 * <p> 252 * Gain settings are generally used to adjust the 253 * monitor's white point. If this function is supported, the GetMonitorCapabilities function returns the 254 * MC_CAPS_RED_GREEN_BLUE_GAIN flag. This function takes about 50 milliseconds to return. Changing the gain settings 255 * can change the color temperature. To get the new color temperature, call GetMonitorColorTemperature. The gain 256 * settings are continuous monitor settings.</p> 257 * @param hMonitor Handle to a physical monitor. 258 * @param gtGainType A member of the MC_GAIN_TYPE enumeration, specifying whether to set the red, green, or blue 259 * gain. 260 * @param dwNewGain Red, green, or blue gain value. To get the monitor's minimum and maximum gain values, call 261 * GetMonitorRedGreenOrBlueGain. 262 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 263 */ SetMonitorRedGreenOrBlueGain(HANDLE hMonitor, MC_GAIN_TYPE gtGainType, int dwNewGain)264 BOOL SetMonitorRedGreenOrBlueGain(HANDLE hMonitor, MC_GAIN_TYPE gtGainType, int dwNewGain); 265 266 /** 267 * Degausses a monitor. 268 * <p> 269 * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DEGAUSS flag. Degaussing 270 * is supported only by cathode ray tube (CRT) monitors. This function takes about 50 milliseconds to return. This 271 * function should not be called frequently, because calling it frequently will not noticeably improve the monitor's 272 * image quality or color fidelity.</p> 273 * @param hMonitor Handle to a physical monitor. 274 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 275 */ DegaussMonitor(HANDLE hMonitor)276 BOOL DegaussMonitor(HANDLE hMonitor); 277 278 /****************************************************************************** 279 * Monitor image size and position calibration functions 280 ******************************************************************************/ 281 282 /** 283 * Retrieves a monitor's minimum, maximum, and current width or height. 284 * <p> 285 * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_SIZE flag. 286 * This function takes about 40 milliseconds to return. The width and height settings are continuous monitor settings. </p> 287 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 288 * @param stSizeType A member of the MC_SIZE_TYPE enumeration, specifying whether to retrieve the width or the height. 289 * @param pdwMinimumWidthOrHeight Receives the minimum width or height. 290 * @param pdwCurrentWidthOrHeight Receives the current width or height. 291 * @param pdwMaximumWidthOrHeight Receives the maximum width or height. 292 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 293 */ GetMonitorDisplayAreaSize(HANDLE hMonitor, MC_SIZE_TYPE stSizeType, DWORDByReference pdwMinimumWidthOrHeight, DWORDByReference pdwCurrentWidthOrHeight, DWORDByReference pdwMaximumWidthOrHeight)294 BOOL GetMonitorDisplayAreaSize(HANDLE hMonitor, MC_SIZE_TYPE stSizeType, DWORDByReference pdwMinimumWidthOrHeight, 295 DWORDByReference pdwCurrentWidthOrHeight, DWORDByReference pdwMaximumWidthOrHeight); 296 297 /** 298 * Retrieves a monitor's minimum, maximum, and current horizontal or vertical position. 299 * <p> 300 * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_POSITION flag. 301 * This function takes about 40 milliseconds to return. The horizontal and vertical position are continuous monitor settings.</p> 302 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 303 * @param ptPositionType A member of the MC_POSITION_TYPE enumeration, specifying whether to retrieve the horizontal position or the vertical position. 304 * @param pdwMinimumPosition Receives the minimum horizontal or vertical position. 305 * @param pdwCurrentPosition Receives the current horizontal or vertical position. 306 * @param pdwMaximumPosition Receives the maximum horizontal or vertical position. 307 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 308 */ GetMonitorDisplayAreaPosition(HANDLE hMonitor, MC_POSITION_TYPE ptPositionType, DWORDByReference pdwMinimumPosition, DWORDByReference pdwCurrentPosition, DWORDByReference pdwMaximumPosition)309 BOOL GetMonitorDisplayAreaPosition(HANDLE hMonitor, MC_POSITION_TYPE ptPositionType, 310 DWORDByReference pdwMinimumPosition, DWORDByReference pdwCurrentPosition, 311 DWORDByReference pdwMaximumPosition); 312 313 /** 314 * Sets the width or height of a monitor's display area. 315 * <p> 316 * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_SIZE flag. 317 * This function takes about 50 milliseconds to return. The width and height settings are continuous monitor settings.</p> 318 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 319 * @param stSizeType A member of the MC_SIZE_TYPE enumeration, specifying whether to set the width or the height. 320 * @param dwNewDisplayAreaWidthOrHeight Display area width or height. To get the minimum and maximum width and height, 321 * call GetMonitorDisplayAreaSize. 322 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 323 */ SetMonitorDisplayAreaSize(HANDLE hMonitor, MC_SIZE_TYPE stSizeType, int dwNewDisplayAreaWidthOrHeight)324 BOOL SetMonitorDisplayAreaSize(HANDLE hMonitor, MC_SIZE_TYPE stSizeType, int dwNewDisplayAreaWidthOrHeight); 325 326 /** 327 * Sets the horizontal or vertical position of a monitor's display area. 328 * <p> 329 * If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_DISPLAY_AREA_POSITION flag. 330 * This function takes about 50 milliseconds to return. The horizontal and vertical position are continuous monitor settings. </p> 331 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 332 * @param ptPositionType A member of the MC_POSITION_TYPE enumeration, specifying whether to set the horizontal position or the vertical position. 333 * @param dwNewPosition Horizontal or vertical position. To get the minimum and maximum position, call GetMonitorDisplayAreaPosition. 334 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 335 */ SetMonitorDisplayAreaPosition(HANDLE hMonitor, MC_POSITION_TYPE ptPositionType, int dwNewPosition)336 BOOL SetMonitorDisplayAreaPosition(HANDLE hMonitor, MC_POSITION_TYPE ptPositionType, int dwNewPosition); 337 338 /****************************************************************************** 339 * Restore to defaults functions 340 ******************************************************************************/ 341 342 /** 343 * Restores a monitor's color settings to their factory defaults. This function potentially changes the current 344 * value of the monitor's brightness, contrast, color temperature, drive, and gain. The current value of each 345 * setting is changed to its factory default. The default settings depend on the manufacturer. This function can 346 * also change the range of supported values for each of these settings. The function does not enable any monitor 347 * settings that were disabled. If this function is supported, the GetMonitorCapabilities function returns the 348 * MC_CAPS_RESTORE_FACTORY_COLOR_DEFAULTS flag. This function takes about 5 seconds to return. This function might 349 * reset monitor settings that are not accessible through the high-level monitor configuration functions. Whether 350 * this occurs depends on the specific model of monitor. The following settings are not affected by this function: 351 * <ul><li>Display area size</li> 352 * <li>Display area position</li> 353 * <li>Capabilities flags</li></ul> 354 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 355 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 356 */ RestoreMonitorFactoryColorDefaults(HANDLE hMonitor)357 BOOL RestoreMonitorFactoryColorDefaults(HANDLE hMonitor); 358 359 /** 360 * Restores a monitor's settings to their factory defaults. This function restores all of the settings that are 361 * supported by the high-level monitor configuration functions. It might also restore settings that are available 362 * only through the low-level functions and are not supported by the high-level functions. The current value of each 363 * setting is changed to its factory default. The exact settings that change, and the default values of those 364 * settings, depend on the manufacturer. This function can also change the range of supported values for some 365 * settings. If this function is supported, the GetMonitorCapabilities function returns the 366 * MC_CAPS_RESTORE_FACTORY_DEFAULTS flag. This function takes about 5 seconds to return. If GetMonitorCapabilities 367 * returns the MC_RESTORE_FACTORY_DEFAULTS_ENABLES_MONITOR_SETTINGS flag, this function also enables all of the 368 * monitor settings that are supported by the high-level functions. It is sometimes possible for an application to 369 * disable certain settings by calling the low-level functions. It is also possible for the user to disable certain 370 * settings by adjusting settings on the monitor's physical control panel. If that happens, the setting can only be 371 * re-enabled through the control panel or by calling RestoreMonitorFactoryDefaults. It is not possible to disable 372 * any settings by using the high-level functions. 373 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 374 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 375 */ RestoreMonitorFactoryDefaults(HANDLE hMonitor)376 BOOL RestoreMonitorFactoryDefaults(HANDLE hMonitor); 377 378 // LowLevelMonitorConfigurationAPI.h 379 380 /** 381 * Retrieves the current value, maximum value, and code type of a Virtual Control Panel (VCP) code for a monitor. 382 * This function corresponds to the "Get VCP Feature & VCP Feature Reply" command from the Display Data 383 * Channel Command Interface (DDC/CI) standard. Vendor-specific VCP codes can be used with this function. 384 * This function takes about 40 milliseconds to return. 385 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 386 * @param bVCPCode VCP code to query. The VCP codes are Include the VESA Monitor Control Command Set (MCCS) 387 * standard, versions 1.0 and 2.0. This parameter must specify a continuous or non-continuous VCP, or a 388 * vendor-specific code. It should not be a table control code. 389 * @param pvct Receives the VCP code type, as a member of the MC_VCP_CODE_TYPE enumeration. This parameter can be NULL. 390 * @param pdwCurrentValue Receives the current value of the VCP code. This parameter can be NULL. 391 * @param pdwMaximumValue If bVCPCode specifies a continuous VCP code, this parameter receives the maximum value of 392 * the VCP code. If bVCPCode specifies a non-continuous VCP code, the value received in this parameter 393 * is undefined. This parameter can be NULL. 394 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 395 */ GetVCPFeatureAndVCPFeatureReply(HANDLE hMonitor, BYTE bVCPCode, MC_VCP_CODE_TYPE.ByReference pvct, DWORDByReference pdwCurrentValue, DWORDByReference pdwMaximumValue)396 BOOL GetVCPFeatureAndVCPFeatureReply(HANDLE hMonitor, BYTE bVCPCode, MC_VCP_CODE_TYPE.ByReference pvct, 397 DWORDByReference pdwCurrentValue, DWORDByReference pdwMaximumValue); 398 399 /** 400 * Sets the value of a Virtual Control Panel (VCP) code for a monitor. This function corresponds to the 401 * "Set VCP Feature" command from the Display Data Channel Command Interface (DDC/CI) standard. This function takes 402 * about 50 milliseconds to return. 403 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 404 * @param bVCPCode VCP code to set. The VCP codes are defined in the VESA Monitor Control Command Set (MCCS) 405 * standard, version 1.0 and 2.0. This parameter must specify a continuous or non-continuous VCP, or a 406 * vendor-specific code. It should not be a table control code. 407 * @param dwNewValue Value of the VCP code. 408 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 409 */ SetVCPFeature(HANDLE hMonitor, BYTE bVCPCode, DWORD dwNewValue)410 BOOL SetVCPFeature(HANDLE hMonitor, BYTE bVCPCode, DWORD dwNewValue); 411 412 /** 413 * Saves the current monitor settings to the display's nonvolatile storage. This function corresponds to the 414 * "Save Current Settings" function from the Display Data Channel Command Interface (DDC/CI) standard. This function 415 * takes about 200 milliseconds to return. This low-level function is identical to the high-level function 416 * SaveCurrentMonitorSettings. 417 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 418 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 419 */ SaveCurrentSettings(HANDLE hMonitor)420 BOOL SaveCurrentSettings(HANDLE hMonitor); 421 422 /** 423 * Retrieves the length of a monitor's capabilities string. 424 * This function usually returns quickly, but sometimes it can take several seconds to complete. 425 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 426 * @param pdwCapabilitiesStringLengthInCharacters Receives the length of the capabilities string, in characters, including the terminating null character. 427 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 428 */ GetCapabilitiesStringLength(HANDLE hMonitor, DWORDByReference pdwCapabilitiesStringLengthInCharacters)429 BOOL GetCapabilitiesStringLength(HANDLE hMonitor, DWORDByReference pdwCapabilitiesStringLengthInCharacters); 430 431 /** 432 * Retrieves a string describing a monitor's capabilities. This function corresponds to the 433 * "Capabilities Request & Capabilities Reply" command from the Display Data Channel Command Interface (DDC/CI) 434 * standard. For more information about the capabilities string, refer to the DDC/CI standard. This function usually 435 * returns quickly, but sometimes it can take several seconds to complete. You can update a monitor's capabilities 436 * string by adding an AddReg directive to the monitor's INF file. Add a registry key named "CapabilitiesString" to 437 * the monitor's driver key. The value of the registry key is the capabilities string. The registry data type is 438 * REG_SZ. 439 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 440 * @param pszASCIICapabilitiesString Pointer to a buffer that receives the monitor's capabilities string. The caller 441 * must allocate this buffer. To get the size of the string, call GetCapabilitiesStringLength. The capabilities 442 * string is always an ASCII string. The buffer must include space for the terminating null character. 443 * @param dwCapabilitiesStringLengthInCharacters Size of pszASCIICapabilitiesString in characters, including the 444 * terminating null character. 445 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 446 */ CapabilitiesRequestAndCapabilitiesReply(HANDLE hMonitor, LPSTR pszASCIICapabilitiesString, DWORD dwCapabilitiesStringLengthInCharacters)447 BOOL CapabilitiesRequestAndCapabilitiesReply(HANDLE hMonitor, LPSTR pszASCIICapabilitiesString, 448 DWORD dwCapabilitiesStringLengthInCharacters); 449 450 /** 451 * Retrieves a monitor's horizontal and vertical synchronization frequencies. 452 * @param hMonitor Handle to a physical monitor. To get the monitor handle, call GetPhysicalMonitorsFromHMONITOR 453 * @param pmtrMonitorTimingReport Pointer to an MC_TIMING_REPORT structure that receives the timing information. 454 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. 455 */ GetTimingReport(HANDLE hMonitor, MC_TIMING_REPORT pmtrMonitorTimingReport)456 BOOL GetTimingReport(HANDLE hMonitor, MC_TIMING_REPORT pmtrMonitorTimingReport); 457 458 // PhysicalMonitorEnumerationAPI.h 459 460 /****************************************************************************** 461 * Physical Monitor Enumeration Functions 462 ******************************************************************************/ 463 464 /** 465 * Retrieves the number of physical monitors associated with an HMONITOR monitor handle. Call this function before 466 * calling GetPhysicalMonitorsFromHMONITOR. 467 * @param hMonitor A monitor handle. Monitor handles are returned by several Multiple Display Monitor functions, 468 * including EnumDisplayMonitors and MonitorFromWindow, which are part of the graphics device interface (GDI). 469 * @param pdwNumberOfPhysicalMonitors Receives the number of physical monitors associated with the monitor handle. 470 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 471 */ GetNumberOfPhysicalMonitorsFromHMONITOR(HMONITOR hMonitor, DWORDByReference pdwNumberOfPhysicalMonitors)472 BOOL GetNumberOfPhysicalMonitorsFromHMONITOR(HMONITOR hMonitor, DWORDByReference pdwNumberOfPhysicalMonitors); 473 474 // HRESULT GetNumberOfPhysicalMonitorsFromIDirect3DDevice9 475 // ( 476 // IDirect3DDevice9* pDirect3DDevice9, 477 // DWORDByReference pdwNumberOfPhysicalMonitors 478 // ); 479 480 /** 481 * Retrieves the physical monitors associated with an HMONITOR monitor handle. A single HMONITOR handle can be 482 * associated with more than one physical monitor. This function returns a handle and a text description for each 483 * physical monitor. When you are done using the monitor handles, close them by passing the pPhysicalMonitorArray 484 * array to the DestroyPhysicalMonitors function. 485 * @param hMonitor A monitor handle. Monitor handles are returned by several Multiple Display Monitor functions, 486 * including EnumDisplayMonitors and MonitorFromWindow, which are part of the graphics device interface (GDI). 487 * @param dwPhysicalMonitorArraySize Number of elements in pPhysicalMonitorArray. To get the required size of the 488 * array, call GetNumberOfPhysicalMonitorsFromHMONITOR. 489 * @param pPhysicalMonitorArray Pointer to an array of PHYSICAL_MONITOR structures. The caller must allocate the 490 * array. 491 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 492 */ GetPhysicalMonitorsFromHMONITOR(HMONITOR hMonitor, int dwPhysicalMonitorArraySize, PHYSICAL_MONITOR[] pPhysicalMonitorArray)493 BOOL GetPhysicalMonitorsFromHMONITOR(HMONITOR hMonitor, int dwPhysicalMonitorArraySize, 494 PHYSICAL_MONITOR[] pPhysicalMonitorArray); 495 496 // HRESULT GetPhysicalMonitorsFromIDirect3DDevice9 497 // ( 498 // __in IDirect3DDevice9* pDirect3DDevice9, 499 // __in DWORD dwPhysicalMonitorArraySize, 500 // __out_ecount(dwPhysicalMonitorArraySize) LPPHYSICAL_MONITOR pPhysicalMonitorArray 501 // ); 502 503 /** 504 * Closes a handle to a physical monitor. 505 * Call this function to close a monitor handle obtained from the GetPhysicalMonitorsFromHMONITOR 506 * @param hMonitor Handle to a physical monitor. 507 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 508 */ DestroyPhysicalMonitor(HANDLE hMonitor)509 BOOL DestroyPhysicalMonitor(HANDLE hMonitor); 510 511 /** 512 * Closes an array of physical monitor handles. 513 * Call this function to close an array of monitor handles obtained from the GetPhysicalMonitorsFromHMONITOR 514 * @param dwPhysicalMonitorArraySize Number of elements in the pPhysicalMonitorArray array. 515 * @param pPhysicalMonitorArray Pointer to an array of PHYSICAL_MONITOR structures. 516 * @return If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE 517 */ DestroyPhysicalMonitors(int dwPhysicalMonitorArraySize, PHYSICAL_MONITOR[] pPhysicalMonitorArray)518 BOOL DestroyPhysicalMonitors(int dwPhysicalMonitorArraySize, PHYSICAL_MONITOR[] pPhysicalMonitorArray); 519 } 520