detect VGA port (through pinout) and send a command to microcontroller
Which "side" are you on - the monitor side or the driving side? 

Either way round the magic words are "EDID" and "VESA DDC". The protocol is basically I2C. Monitors will return a list of supported resolutions and timings.