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.
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).]
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