Skip to content
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.

Commit

Permalink
EnumDisplaySettings - react to PR review (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
weitzhandler committed Jul 17, 2020
1 parent cf8f33a commit 540c495
Show file tree
Hide file tree
Showing 6 changed files with 1,318 additions and 1,303 deletions.
15 changes: 15 additions & 0 deletions src/User32.Tests/User32Facts+EnumDisplaySettingsFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,19 @@ public void EnumDisplaySettings_Test()
Assert.True(mode.dmPelsWidth > 0);
Assert.True(mode.dmPelsHeight > 0);
}

[Fact]
public void EnumDisplaySettingsEx_Test()
{
// Arrange
var mode = DEVMODE.Create();

// Act
var result = EnumDisplaySettingsEx(null, ENUM_CURRENT_SETTINGS, ref mode, EnumDisplaySettingsExFlags.EDS_RAWMODE);

// Assert
Assert.True(result);
Assert.True(mode.dmPelsWidth > 0);
Assert.True(mode.dmPelsHeight > 0);
}
}
18 changes: 9 additions & 9 deletions src/User32/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ PInvoke.User32.EnumDisplaySettingsExFlags.EDS_RAWMODE = 2 -> PInvoke.User32.Enum
PInvoke.User32.EnumDisplaySettingsExFlags.EDS_ROTATEDMODE = 4 -> PInvoke.User32.EnumDisplaySettingsExFlags
const PInvoke.User32.ENUM_CURRENT_SETTINGS = 4294967295 -> uint
const PInvoke.User32.ENUM_REGISTRY_SETTINGS = 4294967294 -> uint
static PInvoke.User32.EnumDisplayDevices(string lpDevice, uint iDevNum, System.IntPtr lpDisplayDevice, PInvoke.User32.EnumDisplayDevicesFlags dwFlags) -> bool
static PInvoke.User32.EnumDisplayDevices(string lpDevice, uint iDevNum, ref PInvoke.DISPLAY_DEVICE lpDisplayDevice, PInvoke.User32.EnumDisplayDevicesFlags dwFlags) -> bool
static PInvoke.User32.EnumDisplaySettings(string lpszDeviceName, uint iModeNum, System.IntPtr lpDevMode) -> bool
static PInvoke.User32.EnumDisplaySettings(string lpszDeviceName, uint iModeNum, ref PInvoke.DEVMODE lpDevMode) -> bool
static PInvoke.User32.EnumDisplaySettingsEx(string lpszDeviceName, uint iModeNum, System.IntPtr lpDevMode, PInvoke.User32.EnumDisplaySettingsExFlags dwFlags) -> bool
static PInvoke.User32.EnumDisplaySettingsEx(string lpszDeviceName, uint iModeNum, ref PInvoke.DEVMODE lpDevMode, PInvoke.User32.EnumDisplaySettingsExFlags dwFlags) -> bool
static extern PInvoke.User32.EnumDisplayDevices(string lpDevice, uint iDevNum, PInvoke.DISPLAY_DEVICE* lpDisplayDevice, PInvoke.User32.EnumDisplayDevicesFlags dwFlags) -> bool
static extern PInvoke.User32.EnumDisplaySettings(string lpszDeviceName, uint iModeNum, PInvoke.DEVMODE* lpDevMode) -> bool
static extern PInvoke.User32.EnumDisplaySettingsEx(string lpszDeviceName, uint iModeNum, PInvoke.DEVMODE* lpDevMode, PInvoke.User32.EnumDisplaySettingsExFlags dwFlags) -> bool
static PInvoke.User32.EnumDisplayDevices(System.IntPtr lpDevice, uint iDevNum, System.IntPtr lpDisplayDevice, PInvoke.User32.EnumDisplayDevicesFlags dwFlags) -> bool
static PInvoke.User32.EnumDisplayDevices(char[] lpDevice, uint iDevNum, ref PInvoke.DISPLAY_DEVICE lpDisplayDevice, PInvoke.User32.EnumDisplayDevicesFlags dwFlags) -> bool
static PInvoke.User32.EnumDisplaySettings(System.IntPtr lpszDeviceName, uint iModeNum, System.IntPtr lpDevMode) -> bool
static PInvoke.User32.EnumDisplaySettings(char[] lpszDeviceName, uint iModeNum, ref PInvoke.DEVMODE lpDevMode) -> bool
static PInvoke.User32.EnumDisplaySettingsEx(System.IntPtr lpszDeviceName, uint iModeNum, System.IntPtr lpDevMode, PInvoke.User32.EnumDisplaySettingsExFlags dwFlags) -> bool
static PInvoke.User32.EnumDisplaySettingsEx(char[] lpszDeviceName, uint iModeNum, ref PInvoke.DEVMODE lpDevMode, PInvoke.User32.EnumDisplaySettingsExFlags dwFlags) -> bool
static extern PInvoke.User32.EnumDisplayDevices(char* lpDevice, uint iDevNum, PInvoke.DISPLAY_DEVICE* lpDisplayDevice, PInvoke.User32.EnumDisplayDevicesFlags dwFlags) -> bool
static extern PInvoke.User32.EnumDisplaySettings(char* lpszDeviceName, uint iModeNum, PInvoke.DEVMODE* lpDevMode) -> bool
static extern PInvoke.User32.EnumDisplaySettingsEx(char* lpszDeviceName, uint iModeNum, PInvoke.DEVMODE* lpDevMode, PInvoke.User32.EnumDisplaySettingsExFlags dwFlags) -> bool
static extern PInvoke.User32.UnregisterClass(string lpClassName, System.IntPtr hInstance) -> bool
static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED -> System.IntPtr
2 changes: 1 addition & 1 deletion src/User32/User32+EnumDisplaySettingsExFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace PInvoke
public partial class User32
{
/// <summary>
/// Flags for <see cref="EnumDisplaySettingsEx(string, uint, ref DEVMODE, EnumDisplaySettingsExFlags)"/>.
/// Flags for <see cref="EnumDisplaySettingsEx(string, uint, DEVMODE*, EnumDisplaySettingsExFlags)"/>.
/// </summary>
[Flags]
public enum EnumDisplaySettingsExFlags : uint
Expand Down
26 changes: 13 additions & 13 deletions src/User32/User32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@ public static extern unsafe int LookupIconIdFromDirectoryEx(
/// </param>
/// <param name="lpDisplayDevice">
/// A pointer to a <see cref="DISPLAY_DEVICE"/> structure that receives information about the display device specified by <paramref name="iDevNum"/>.
/// Before calling <see cref="EnumDisplayDevices(string, uint, DISPLAY_DEVICE*, EnumDisplayDevicesFlags)"/>, you must initialize the member <see cref="DISPLAY_DEVICE.cb"/> to the size, in bytes, of <see cref="DISPLAY_DEVICE"/>.
/// Before calling <see cref="EnumDisplayDevices(char*, uint, DISPLAY_DEVICE*, EnumDisplayDevicesFlags)"/>, you must initialize the member <see cref="DISPLAY_DEVICE.cb"/> to the size, in bytes, of <see cref="DISPLAY_DEVICE"/>.
/// </param>
/// <param name="dwFlags">
/// Set this flag to <see cref="EnumDisplayDevicesFlags.EDD_GET_DEVICE_INTERFACE_NAME"/> to retrieve the device interface name for <c>GUID_DEVINTERFACE_MONITOR</c>, which is registered by the operating system on a per monitor basis.
Expand All @@ -1695,7 +1695,7 @@ public static extern unsafe int LookupIconIdFromDirectoryEx(
[DllImport(nameof(User32), SetLastError = true, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern unsafe bool EnumDisplayDevices(
[MarshalAs(UnmanagedType.LPWStr)] string lpDevice,
[Friendly(FriendlyFlags.Array | FriendlyFlags.In)] char* lpDevice,
uint iDevNum,
[Friendly(FriendlyFlags.Bidirectional)] DISPLAY_DEVICE* lpDisplayDevice,
EnumDisplayDevicesFlags dwFlags);
Expand All @@ -1705,21 +1705,21 @@ public static extern unsafe bool EnumDisplayDevices(
/// </summary>
/// <param name="lpszDeviceName">
/// A pointer to a null-terminated string that specifies the display device about whose graphics mode the function will obtain information.
/// This parameter is either <c>NULL</c> or a <see cref="DISPLAY_DEVICE.DeviceName"/> returned from <see cref="EnumDisplayDevices(string, uint, DISPLAY_DEVICE*, EnumDisplayDevicesFlags)"/>.
/// This parameter is either <c>NULL</c> or a <see cref="DISPLAY_DEVICE.DeviceName"/> returned from <see cref="EnumDisplayDevices(char*, uint, DISPLAY_DEVICE*, EnumDisplayDevicesFlags)"/>.
/// A <c>NULL</c> value specifies the current display device on the computer on which the calling thread is running.
/// </param>
/// <param name="iModeNum">
/// <para>The type of information to be retrieved. This value can be a graphics mode index or one of the following values.</para>
/// <para><see cref="ENUM_CURRENT_SETTINGS"/>: Retrieve the current settings for the display device.</para>
/// <para><see cref="ENUM_REGISTRY_SETTINGS"/>: Retrieve the settings for the display device that are currently stored in the registry.</para>
/// <para>
/// Graphics mode indexes start at zero. To obtain information for all of a display device's graphics modes, make a series of calls to <see cref="EnumDisplaySettings(string, uint, DEVMODE*)"/>, as follows: Set <paramref name="iModeNum"/> to zero for the first call,
/// Graphics mode indexes start at zero. To obtain information for all of a display device's graphics modes, make a series of calls to <see cref="EnumDisplaySettings(char*, uint, DEVMODE*)"/>, as follows: Set <paramref name="iModeNum"/> to zero for the first call,
/// and increment <paramref name="iModeNum"/> by one for each subsequent call.
/// </para>
/// <para>
/// Continue calling the function until the return value is zero.<br/>
/// When you call <see cref="EnumDisplaySettings(string, uint, DEVMODE*)"/> with <paramref name="iModeNum"/> set to zero, the operating system initializes and caches information about the display device.<br/>
/// When you call <see cref="EnumDisplaySettings(string, uint, DEVMODE*)"/> with <paramref name="iModeNum"/> set to a nonzero value,
/// When you call <see cref="EnumDisplaySettings(char*, uint, DEVMODE*)"/> with <paramref name="iModeNum"/> set to zero, the operating system initializes and caches information about the display device.<br/>
/// When you call <see cref="EnumDisplaySettings(char*, uint, DEVMODE*)"/> with <paramref name="iModeNum"/> set to a nonzero value,
/// the function returns the information that was cached the last time the function was called with iModeNum set to zero.
/// </para>
/// </param>
Expand All @@ -1734,7 +1734,7 @@ public static extern unsafe bool EnumDisplayDevices(
[DllImport(nameof(User32))]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern unsafe bool EnumDisplaySettings(
[MarshalAs(UnmanagedType.LPWStr)] string lpszDeviceName,
[Friendly(FriendlyFlags.Array | FriendlyFlags.In)] char* lpszDeviceName,
uint iModeNum,
[Friendly(FriendlyFlags.Bidirectional)]DEVMODE* lpDevMode);

Expand All @@ -1743,21 +1743,21 @@ public static extern unsafe bool EnumDisplaySettings(
/// </summary>
/// <param name="lpszDeviceName">
/// A pointer to a null-terminated string that specifies the display device about whose graphics mode the function will obtain information.
/// This parameter is either <c>NULL</c> or a <see cref="DISPLAY_DEVICE.DeviceName"/> returned from <see cref="EnumDisplayDevices(string, uint, DISPLAY_DEVICE*, EnumDisplayDevicesFlags)"/>.
/// This parameter is either <c>NULL</c> or a <see cref="DISPLAY_DEVICE.DeviceName"/> returned from <see cref="EnumDisplayDevices(char*, uint, DISPLAY_DEVICE*, EnumDisplayDevicesFlags)"/>.
/// A <c>NULL</c> value specifies the current display device on the computer on which the calling thread is running.
/// </param>
/// <param name="iModeNum">
/// <para>The type of information to be retrieved. This value can be a graphics mode index or one of the following values.</para>
/// <para><see cref="ENUM_CURRENT_SETTINGS"/>: Retrieve the current settings for the display device.</para>
/// <para><see cref="ENUM_REGISTRY_SETTINGS"/>: Retrieve the settings for the display device that are currently stored in the registry.</para>
/// <para>
/// Graphics mode indexes start at zero. To obtain information for all of a display device's graphics modes, make a series of calls to <see cref="EnumDisplaySettingsEx(string, uint, DEVMODE*, EnumDisplaySettingsExFlags)"/>, as follows: Set <paramref name="iModeNum"/> to zero for the first call,
/// Graphics mode indexes start at zero. To obtain information for all of a display device's graphics modes, make a series of calls to <see cref="EnumDisplaySettingsEx(char*, uint, DEVMODE*, EnumDisplaySettingsExFlags)"/>, as follows: Set <paramref name="iModeNum"/> to zero for the first call,
/// and increment <paramref name="iModeNum"/> by one for each subsequent call.
/// </para>
/// <para>
/// Continue calling the function until the return value is zero.<br/>
/// When you call <see cref="EnumDisplaySettingsEx(string, uint, DEVMODE*, EnumDisplaySettingsExFlags)"/> with <paramref name="iModeNum"/> set to zero, the operating system initializes and caches information about the display device.<br/>
/// When you call <see cref="EnumDisplaySettingsEx(string, uint, DEVMODE*, EnumDisplaySettingsExFlags)"/> with <paramref name="iModeNum"/> set to a nonzero value,
/// When you call <see cref="EnumDisplaySettingsEx(char*, uint, DEVMODE*, EnumDisplaySettingsExFlags)"/> with <paramref name="iModeNum"/> set to zero, the operating system initializes and caches information about the display device.<br/>
/// When you call <see cref="EnumDisplaySettingsEx(char*, uint, DEVMODE*, EnumDisplaySettingsExFlags)"/> with <paramref name="iModeNum"/> set to a nonzero value,
/// the function returns the information that was cached the last time the function was called with iModeNum set to zero.
/// </para>
/// </param>
Expand All @@ -1772,10 +1772,10 @@ public static extern unsafe bool EnumDisplaySettings(
/// As noted in the description of the <paramref name="iModeNum"/> parameter, you can use this behavior to enumerate all of a display device's graphics modes.
/// </remarks>
/// <returns>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</returns>
[DllImport(nameof(User32), EntryPoint = "EnumDisplaySettingsExW")]
[DllImport(nameof(User32))]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern unsafe bool EnumDisplaySettingsEx(
[MarshalAs(UnmanagedType.LPWStr)] string lpszDeviceName,
[Friendly(FriendlyFlags.Array | FriendlyFlags.In)] char* lpszDeviceName,
uint iModeNum,
[Friendly(FriendlyFlags.Bidirectional)] DEVMODE* lpDevMode,
EnumDisplaySettingsExFlags dwFlags);
Expand Down
Loading

0 comments on commit 540c495

Please sign in to comment.