MSDN Device Context Functions
What you basically need to do:
Use the EnumDisplayDevices() API call
to enumerate the display devices on
the system and look for those that
don't have the
DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
flag set (this will include any
mirroring devices so not all will be
physical displays.) Once you've found
the display device you'll need to get
a valid display mode to change it to,
you can find this by calling the
EnumDisplaySettingsEx() API call -
Generally you'd display all the
available modes and allow the user to
choose however in your case it sounds
like this may be possible to hard-code
and save you an additional step. For
the sake of future-proofing your
application though I'd suggest having
this easily changeable without having
to dig through the source every time,
a registry key would be the obvious
choice. Once you've got that sorted
out populate a DevMode display
structure with the information about
the display positioning (set the
PelsWidth/Height, Position,
DisplayFrequency and BitsPerPel
properties) then set these flags in
the fields member. Finally call
ChangeDisplaySettingsEx() with this
settings structure and be sure to send
the reset and update registry flags.
That should be all you need, hope this
helps,
DISPLAY_DEVICE structure import using PInvoke
EnumDisplayDevices function import
EnumDisplaySettingsEx function import
etc. the rest of them functions can be found with a simple search by name.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…