• 0

[VB.NET] Display Monitor Identity


Question

Hey gang,

I am looking for the api that is used (if there is one) when the user has multiple monitors and presses the "Identify" button on the Display dialog, Settings tab. (see attached image) I'm writing a an app that can take advantage of multiple monitors and I want to be able to show the user which one is which.

Thanks,

James

post-45653-1264195925305_thumb.jpg

  • Like 1
Link to comment
https://www.neowin.net/forum/topic/867666-vbnet-display-monitor-identity/
Share on other sites

7 answers to this question

Recommended Posts

  • 0

.NET has a class called Screen (in the System.Windows.Forms namespace), which represents the screens available. However, it does not have an ID associated with it, instead it just provides a device name. In order to get this in .NET, you'll have to make use of the Windows API.

I believe the DISPLAY_DEVICE structure provides what you're looking for: http://msdn.microsoft.com/en-us/library/dd183569%28VS.85%29.aspx

You can iterate through the display devices, using the EnumDisplayDevices function: http://msdn.microsoft.com/en-us/library/dd162609%28VS.85%29.aspx

(There are relevant links on both of those pages, which should give enough information to provide you with what you need to make the necessary native calls)

In addition, here is a page that gives some C# code for using EnumDisplayDevices: http://www.pinvoke.net/default.aspx/user32/EnumDisplayDevices.html

Edited by naaward
  • 0

Thanks guys,

I already knew about the Screens and AllScreens objects, and the enumDisplays basically does the same thing. What I was hoping for was a way to call that same function that the highlighted button calls. It actually shows a "1", "2", etc on each screen. I can get the height,width,left of each screen and display a number using a transparent form... I was just hoping to use the existing function that Windows uses. (if it's public)

Thanks,

James

  • 0
  On 16/02/2016 at 11:03, Nelson Rodrigues said:

hope ;)

 

Just have tried Win API, windows register, ... Nothing work consistently

Expand  

Get the array of screens from System.Windows.Forms.Screen.AllScreens and enumerate it. The one that returns true for "Primary" is #1.

 

The DeviceName property will give you a device path that should identify the ID Windows assigned it. (e.g.: "\\\\.\\DISPLAY1")

 

This is buggy on Windows XP and returns garbage in the name so you will have to parse it somehow if you're trying to support that OS.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • "The timeframe of Micron's investment in the US has yet to be determined." So, it isn't happening. Announce to please the mad king, stall for 3 years, then quietly back down.
    • Xbox Play Anywhere goes PC and Xbox if you own them. If you have GamePass Ultimate you get both versions as well even non-Play Anywhere.
    • OneDrive for Mac now lets you sync files to removable drives by Taras Buria If you use OneDrive on Mac and often work with external drives (a common sight among Mac users where internal storage is not upgradeable), Microsoft has some good news for you: the OneDrive client for macOS now supports removable drives, allowing you to sync files to external disks, both non-removable and removable. Microsoft introduced external drive support in OneDrive for Mac at the beginning of 2025. However, the initial rollout was limited to drives that macOS detects as non-removable. The company received plenty of feedback from users regarding this change, and it is now addressing the inability to sync files to removable drives. External drive support in OneDrive works the same way as syncing files to internal storage. If you unplug your drive, say, a portable SSD, OneDrive will stop syncing and notify you with an error message (there is a short delay for drives that sporadically disconnect). To resume sync, reconnect your drive and restart OneDrive. If you want to sync OneDrive to an external drive, your drive should be formatted for APFS (Apple File System) and protected by FileVault (read-only, network, and quarantined drives are not supported). Also, you need macOS version 15.0 or newer and OneDrive version 25.097 or newer. For now, external drive support is only available for insiders, but a wider rollout is coming soon. Finally, Microsoft adds that external drive support does not allow moving drives between devices. Therefore, you must set up OneDrive sync again every time you connect your drive to a new Mac. You can read more about external drive support in OneDrive for Mac in a post on the official Tech Community website. In other OneDrive news, check out our recently published guide, which details how to change OneDrive folder colors for extra personalization.
    • I'm here for it! Bill Pullman & Rick Moranis Returning For New ‘Spaceballs’; Keke Palmer Also Set https://deadline.com/2025/06/spaceballs-2-casts-rick-moranis-bill-pullman-keke-palmer-1236431204/ It's gonna be epic! 
    • Lipstick on a data-hungry pig...
  • Recent Achievements

    • One Month Later
      POR2GAL4EVER earned a badge
      One Month Later
    • One Year In
      Orpheus13 earned a badge
      One Year In
    • One Month Later
      Orpheus13 earned a badge
      One Month Later
    • Week One Done
      Orpheus13 earned a badge
      Week One Done
    • Week One Done
      serfegyed earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      535
    2. 2
      ATLien_0
      260
    3. 3
      +FloatingFatMan
      202
    4. 4
      +Edouard
      167
    5. 5
      Xenon
      124
  • Tell a friend

    Love Neowin? Tell a friend!