Click here to Skip to main content
15,885,729 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am trying to use GetWindowInfo function to get information about an external window. However I am completely new to using DLLImports. I have tried googling for a simple tutorial but they all assume knowledge I don't have. Can anyone point me to good tutorials on DLLs, or better yet provide me with a simple example of using GetWindowInfo.
Posted

Hi,

here is a good site that has all the information needed by you:
http://www.pinvoke.net/default.aspx/user32.getwindow[^]
 
Share this answer
 
Comments
Neil Cross 29-Oct-10 7:18am    
It seems to be a good site but I'm still finding it very difficult. They don't have any examples of using the code. Do you know any sites that give examples. Thanks.
Ok,

here is the code that you need:

Declare the method:
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll",SetLastError = true)]
static extern bool GetWindowInfo(IntPtr hwnd, ref WINDOWINFO pwi);


And then you can call the method in one of your functions / event handlers...
WINDOWINFO info = new WINDOWINFO();
info.cbSize = (uint)Marshal.SizeOf(info);
GetWindowInfo(Handle, ref info);
 
Share this answer
 
Comments
Neil Cross 29-Oct-10 8:47am    
Thanks that helped I was overcomplicating it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900