• 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

    • Hi guys. Having some trouble with an MSI MAG Tomahawk B760 WiFi DDR5 motherboard. I want Thunderbolt and my motherboard has a TB Header on the base of the board. The USBC on the back is just a USB C port but I really want a Thunderbolt port because of a piece of hardware I've just bought. I'm looking for either a header I can connect direct to the board or a PCI Card I can connect. Does anyone know what I need or where I can get help? Thanks
    • I do not want every single browser to be based on Chromium. The main reason I use Firefox is because it's not based on Chromium.
    • Insert "but Lundluke is xyz" like he is lying. Yes, people on Neowin don't like him. I don't actively follow him either but in that particular one he is correct, he is not lying.
    • That guy is an idiot. Why can't you plainly answer my question?
    • Last chance: Solutions Architect's Handbook, Third Edition (worth $42.99) download by Steven Parker Claim your complimentary eBook worth $42.99 for free, before the offer ends today, June 10. Build a strong foundation in solution architecture and excel in your career with the Solutions Architect’s Handbook. Authored by seasoned AWS technology leaders Saurabh Shrivastav and Neelanjali Srivastav, this book goes beyond traditional certification guides, offering in-depth insights and advanced techniques to meet the specific needs and challenges of solutions architects today. This edition introduces exciting new features that keep you at the forefront of this evolving field. From large language models and generative AI to deep learning innovations, these cutting-edge advancements are shaping the future of technology. Key topics such as cloud-native architecture, data engineering architecture, cloud optimization, mainframe modernization, and building cost-efficient, secure architectures remain essential today. This book covers both emerging and foundational technologies, guiding you through solution architecture design with key principles and providing the knowledge you need to succeed as a Solutions Architect. It also sharpens your soft skills, providing career-accelerating techniques to stay ahead. By the end of this book, you will be able to harness cutting-edge technologies, apply practical insights from real-world scenarios, and enhance your solution architecture skills with the Solutions Architect's Handbook. This free offer expires today, June 10. How to get it Please ensure you read the terms and conditions to claim this offer. Complete and verifiable information is required in order to receive this free offer. If you have previously made use of these free offers, you will not need to re-register. While supplies last! Download Solutions Architect's Handbook, Third Edition (worth $42.99) for free Offered by Packt, view other free resources The below offers are also available for free in exchange for your (work) email: Solutions Architect's Handbook, Third Edition ($42.99 Value) FREE – Expires 6/10 AI and Innovation ($21 Value) FREE – Expires 6/11 Unruly: Fighting Back when Politics, AI, and Law Upend [...] ($18 Value) FREE - Expires 6/17 SQL Essentials For Dummies ($10 Value) FREE – Expires 6/17 Continuous Testing, Quality, Security, and Feedback ($27.99 Value) FREE – Expires 6/18 VideoProc Converter AI v7.5 for FREE (worth $78.90) – Expires 6/18 Macxvideo AI ($39.95 Value) Free for a Limited Time – Expires 6/22 The Ultimate Linux Newbie Guide – Featured Free content Python Notes for Professionals – Featured Free content Learn Linux in 5 Days – Featured Free content Quick Reference Guide for Cybersecurity – Featured Free content We post these because we earn commission on each lead so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin The above deal not doing it for you, but still want to help? Check out the links below. Check out our partner software in the Neowin Store Buy a T-shirt at Neowin's Threadsquad Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: An account at Neowin Deals is required to participate in any deals powered by our affiliate, StackCommerce. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through the branded deals site.
  • Recent Achievements

    • Week One Done
      IAMFLUXX earned a badge
      Week One Done
    • One Month Later
      Æhund earned a badge
      One Month Later
    • One Month Later
      CoolRaoul earned a badge
      One Month Later
    • First Post
      Kurotama earned a badge
      First Post
    • Collaborator
      Carltonbar earned a badge
      Collaborator
  • Popular Contributors

    1. 1
      +primortal
      499
    2. 2
      ATLien_0
      267
    3. 3
      +FloatingFatMan
      227
    4. 4
      +Edouard
      199
    5. 5
      snowy owl
      151
  • Tell a friend

    Love Neowin? Tell a friend!