Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: OT? EnumDisplaySettings()

  1. #1
    Intern Contributor
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    84

    OT? EnumDisplaySettings()

    Hello!

    Im having some troble getting the current display setting. I've looked everywhere, but this should be the way:

    DEVMODE DMsaved;
    DMsaved.dmSize = sizeof(DEVMODE);
    EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS, &DMsaved);

    BoundsChecker says:
    Static memory overrun
    Copying 156 bytes to rnvid_DMsaved
    Starting offset: 0, destination size: 148 bytes

    My program crashes later on, but I dont know if its related to this error.

    Can anybody find anything wrong with this code?

    Thanks!
    /Fredrik Olsson

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: OT? EnumDisplaySettings()

    A buffer overrun will cause large problems at some time. To be sure that line really is the source of your crash, remove it (and fill the devmode structure yourself with some values) and see what happens. I don't see anything wrong with that piece of code.

  3. #3
    Intern Contributor
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    84

    Re: OT? EnumDisplaySettings()

    When i fill the DMsaved struct with 1's nothing goes wrong.

    memset(&DMsaved, 1, sizeof(DEVMODE))

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: OT? EnumDisplaySettings()

    In MSDN it says this about the lpDevMode parameter of EnumDisplaySettings():

    [out] Pointer to a DEVMODE structure into which the function stores information about the specified graphics mode. Before calling EnumDisplaySettings, set the dmSize member to sizeof(DEVMODE), and set the dmDriverExtra member to indicate the size, in bytes, of the additional space available to receive private driver data.
    Try setting the dmDriverExtra member to 0.

    Just as an extra note, it's usually a good idea to zero out structs used in the Win32 API before setting values in them by using something like ZeroMemory or memset.

    [This message has been edited by Deiussum (edited 09-11-2002).]
    Deiussum
    Software Engineer and OpenGL enthusiast

  5. #5
    Intern Contributor
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    84

    Re: OT? EnumDisplaySettings()

    dmDriverExtra is zero.
    I tried clearing the struct to, but it doesn't help.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Dresden, Sachsen, Germany
    Posts
    205

    Re: OT? EnumDisplaySettings()

    i think you have to fill out the devMode.dmfields
    with the your desired flags like DM_PELSWIDTH etc... to obtain the value that is stored last in the registry for that setting
    CU

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •