Question

I'm looking at the MSDN documentation for ChangeDisplaySettings. For the dwFlags option, you can pass in 0 or one of the other listed flags. However, I can't figure out how to reference those flags directly, nor figure out what their actual long value is to use in their stead.

I'm making these calls from a C# application using this:

[DllImport("User32.dll")]
public static extern long ChangeDisplaySettings(ref DeviceMode lpDevMode, int dwflags);

Is there a way I can reference the flags directly, or, barring that, find out what their actual values are?

Was it helpful?

Solution

http://www.pinvoke.net to the rescue

[Flags()]
public enum ChangeDisplaySettingsFlags : uint
{
    CDS_NONE = 0,
    CDS_UPDATEREGISTRY = 0x00000001,
    CDS_TEST = 0x00000002,
    CDS_FULLSCREEN = 0x00000004,
    CDS_GLOBAL = 0x00000008,
    CDS_SET_PRIMARY = 0x00000010,
    CDS_VIDEOPARAMETERS = 0x00000020,
    CDS_ENABLE_UNSAFE_MODES = 0x00000100,
    CDS_DISABLE_UNSAFE_MODES = 0x00000200,
    CDS_RESET = 0x40000000,
    CDS_RESET_EX = 0x20000000,
    CDS_NORESET = 0x10000000
}

[DllImport("user32.dll")]
public static extern DISP_CHANGE ChangeDisplaySettings(ref DEVMODE devMode, ChangeDisplaySettingsFlags flags); 

source: http://www.pinvoke.net/default.aspx/user32.changedisplaysettings

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top