Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to know if monitor is connected?

How to know if monitor is connected?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IGx89
    wrote on last edited by
    #1

    Is it possible to programmatically find out if the monitor is connected to the computer? I would be very grateful if someone could provide that answer!

    A 1 Reply Last reply
    0
    • I IGx89

      Is it possible to programmatically find out if the monitor is connected to the computer? I would be very grateful if someone could provide that answer!

      A Offline
      A Offline
      Andrew Kirillov
      wrote on last edited by
      #2

      Hello I was using EnumDisplayMonitors to find all monitors on the system. Try it. EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, NULL); .. BOOL CALLBACK MonitorEnumProc( HMONITOR hMonitor, // handle to display monitor HDC hdcMonitor, // handle to monitor DC LPRECT lprcMonitor, // monitor intersection rectangle LPARAM dwData // data ) { MONITORINFO mi; mi.cbSize = sizeof(mi); if (GetMonitorInfo(hMonitor, &mi)) { ... } return TRUE; }

      I 1 Reply Last reply
      0
      • A Andrew Kirillov

        Hello I was using EnumDisplayMonitors to find all monitors on the system. Try it. EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, NULL); .. BOOL CALLBACK MonitorEnumProc( HMONITOR hMonitor, // handle to display monitor HDC hdcMonitor, // handle to monitor DC LPRECT lprcMonitor, // monitor intersection rectangle LPARAM dwData // data ) { MONITORINFO mi; mi.cbSize = sizeof(mi); if (GetMonitorInfo(hMonitor, &mi)) { ... } return TRUE; }

        I Offline
        I Offline
        IGx89
        wrote on last edited by
        #3

        Thanks, but unfortunately it still finds the monitor when it's been unplugged :(.

        2 1 Reply Last reply
        0
        • I IGx89

          Thanks, but unfortunately it still finds the monitor when it's been unplugged :(.

          2 Offline
          2 Offline
          224917
          wrote on last edited by
          #4

          GetDevicePowerState()


          suhredayan
          There is no spoon.

          I 1 Reply Last reply
          0
          • 2 224917

            GetDevicePowerState()


            suhredayan
            There is no spoon.

            I Offline
            I Offline
            IGx89
            wrote on last edited by
            #5

            Thanks, that function looks to be what I need, but it fails when I use the monitor handle given by EnumDisplayMonitors :(.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups