The EnumDisplaySettings function retrieves information about one of the graphics modes for a display device. To retrieve information for all the graphics modes of a display device, make a series of calls to this function.
[in] Pointer to a null-terminated string that specifies the display device about whose graphics mode the function will obtain information.
[in] Specifies the type of information to retrieve.
[out] Pointer to a DEVMODE structure into which the function stores information about the specified graphics mode.
If the function succeeds, the return value is nonzero.
MSDN: The function fails if iModeNum is greater than the index of the display device"s last graphics mode. As noted in the description of the iModeNum parameter, you can use this behavior to enumerate all of a display device"s graphics modes.