获取位置使用.NET所有打开的窗口和大小(C#)大小、窗口、位置、NET

由网友(2B範er的小青年)分享简介:有没有一种方法来检测和保存所有打开的窗口的位置和大小,以及它们的状态(最小化,最大化等)Is there a way to detect and store the location and size of all open windows, as well as their state (Minimized, Ma...

有没有一种方法来检测和保存所有打开的窗口的位置和大小,以及它们的状态(最小化,最大化等)

Is there a way to detect and store the location and size of all open windows, as well as their state (Minimized, Maximized etc)

我从来没有开发任何东西,得到这样从实际操作系统的信息。是否需要调用一个Windows API和包括非托管的code?

I've never developed anything that gets information from the actual operating system in this way. Does it require a call to a Windows API and involve unmanaged code?

如果这一点不明确,请评论,我会尽量详细说明。

If this is not clear please comment and I will try to elaborate.

推荐答案

通话 EnumWindows的通过所有的窗户的循环,然后调用 GetWindowPlacement 脱身的信息。这将需要的PInvoke到Windows API,但它并不难,只要能找到在的PInvoke 网站的所有信息。

Call EnumWindows to loop through all the windows, then call GetWindowPlacement to get out the information. It will require PInvoke to Windows API, but it's not that difficult, just can find all the information at the PInvoke site.

顺便说一句,这里是找到一个特定的窗口,并得到一个 $ C $的CProject 文章/设置它的显示状态,可能是一个很好的出发点(code是在VB.Net,但你很可能只是使用在线VB.Net到C#转换器之一,如果你不知道VB。网)

Btw, here's a codeproject article for finding a specific window and getting/setting the show state of it, might be a good starting point (the code is in VB.Net, but you could probably just use one of the online VB.Net to C# converters if you don't know VB.Net)

阅读全文

相关推荐

最新文章