GetWindowRectを使用してウインドウサイズを取得します
Windows APIのGetWindowRect()関数を使用してウインドウの位置を取得して、その取得した位置からウインドウサイズを取得します
[DllImport("user32.dll")]
private static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
private void button1_Click(object sender, RoutedEventArgs e)
{
IntPtr handle = (IntPtr)0x33162; //取得したいWindowのハンドル
RECT rect;
bool flag = GetWindowRect(handle, out rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
Console.WriteLine("height:{0} width:{1}", height, width);
}
