Reputation: 4813
I don't know the .NET framework (4.5) well enough, so here's a question I can't find an answer to.
How do I get the screen resolution of the primary screen when not working with windows forms or any other graphical environment like WPF, Silverlight, ASP.NET, etc? I'm trying to get the resolution in a class library (dll) and pass it on from there.
Does .NET have such functionality?
Upvotes: 7
Views: 14201
Reputation: 3085
Here is what you need.
It's too late but i think it will useful for another :) The answer is using P/Invoke with SystemMetric.
You can get size of your primary screen without add reference to System.Windows.Forms.dll.
http://pinvoke.net/default.aspx/Enums.SystemMetric
I don't like import a big dll to using one simple method XD
Upvotes: 1
Reputation: 56459
Although you're not working in a Winforms enviroment, you can still add a reference to it's DLLs. Adding a reference to the System.Windows.Forms.dll
means that you can use:
SystemInformation.VirtualScreen.Width
SystemInformation.VirtualScreen.Height
Upvotes: 11