1

I need to be able to access the working area of the primary monitor using C# in WPF. I am looking for a solution that does not utilize the System.Windows.Forms namespace. I assume that this would require some sort of wrapper around a Win32 call.

Edit: Forgot to mention that I also need to get left/top of the primary monitor.

Ming Slogar
  • 2,327
  • 1
  • 19
  • 41
  • You can use WMI. What's wrong with System.Windows.Forms though? – User 12345678 Aug 16 '13 at 20:28
  • 1
    Specifically the second answer on that question: http://stackoverflow.com/a/744306/781792 – Tim S. Aug 16 '13 at 20:28
  • @ByteBlast: I don't want to use System.Windows.Forms because that would require loading a 400KB+ dll. – Ming Slogar Aug 16 '13 at 20:29
  • @ByteBlast: How would I use WMI? – Ming Slogar Aug 16 '13 at 20:34
  • It is a very common myth that loading a .NET assembly means that you are reading the file. .NET is **much** more sophisticated than that. With ample help from the operating system, Windows is a demand-paged virtual memory operating system. Reading an introductory book about operating system design is important for every programmer. – Hans Passant Aug 16 '13 at 21:17
  • @HansPassant: Does this also apply for a cold start? – Ming Slogar Aug 16 '13 at 21:19
  • Erm, no, that's not a myth. I never once heard anybody claim that the size of the file had anything to do with the cold-start time :) – Hans Passant Aug 16 '13 at 21:28

1 Answers1

1

To get the height and width of the primary screen you can use SystemParameters.PrimaryScreenWidth and SystemParameters.PrimaryScreenHeight which are in the PresentationFramework library.

Ryan Amies
  • 4,902
  • 1
  • 21
  • 36