Function: returns the size of the border rectangle of the specified window. This dimension is given relative to the screen coordinate in the upper left corner of the screen coordinate.
Function prototype: bool getwindowrect (hwnd, lprectlprect );
Parameters:
Hwnd: Window handle.
Lprect: a pointer to a rect structure that receives screen coordinates in the upper left and lower right corner of the window.
Return Value: If the function succeeds, the return value is non-zero. If the function fails, the return value is zero. To obtain more error information, call the getlasterror function.
Use this function in C # To first import the namespace:
UsingSystem. runtime. interopservices;
Then writeCodeIn the class.
[Dllimport ("User32.dll")]Private Static Extern IntGetwindowrect (intptr hwnd,OutRect lprect );
This function has two parameters. The first parameter specifies the window handle. The second parameter receives the screen coordinates in the upper left corner and lower right corner of the window, which is a rect structure. The rect structure is defined as follows:
Public Struct Rect { Public Int Left; Public Int Top; Public Int Right; Public Int Bottom;} DEMO code: intptr hwnd = Findwindow ( "" , " Calculator " ); Rect = New Rect (); getwindowrect (hwnd, Out Lprect );
Reprinted from: http://blog.csdn.net/dangdaa/article/details/7001810