title: WinAPI GetWindowInfo and GetWindowRect Returning Values of 0
body: <p>So here is what is happening. I am using User32 to use the FindWindowA function, where my test case is Notepad (i.e. &quot;Untitled - Notepad&quot;). I then use several other functions like GetWindowInfo and GetWindowRect, and the values returned are strangely all 0. So here is what I do in Java:</p>
  <pre><code>Pointer windowHandle = user32.FindWindowA(null, &quot;Untitled - Notepad&quot;);
  System.out.println(windowHandle == null ? &quot;Pointer is NULL&quot; : &quot;Pointer is valid.&quot;);
  
  WinAPI.WINDOWINFO windowInfo = new WinAPI.WINDOWINFO();
  Pointer windowInfoPtr = windowInfo.getPointer();
  System.out.println(&quot;result of GetWindowInfo: &quot; + user32.GetWindowInfo(windowHandle, windowInfoPtr));
  
  System.out.println(windowInfo.cbSize);
  System.out.println(windowInfo.dwWindowStatus);
  System.out.println(windowInfo.dwStyle);
  
  WinAPI.RECT rcWindow = windowInfo.rcWindow;
  System.out.println(rcWindow.bottom.longValue() + &quot;, &quot; + rcWindow.left.longValue() + &quot;, &quot; + rcWindow.right.longValue() + &quot;, &quot; + rcWindow.top.longValue());
  
  WinAPI.RECT r = new WinAPI.RECT();
  Pointer rPtr = r.getPointer();
  
  System.out.println(&quot;result of GetWindowRect: &quot; + user32.GetWindowRect(windowHandle, rPtr));
  
  System.out.println(r.top + &quot;, &quot; + r.left + &quot;, &quot; + r.bottom + &quot;, &quot; + r.right);
  </code></pre>
  <p>The output results in this:</p>
  <pre><code>Pointer is valid.
  result of GetWindowInfo: true
  60
  0
  0
  0, 0, 0, 0
  result of GetWindowRect: true
  0, 0, 0, 0
  </code></pre>
  <p>I used Notepad as a test case because it's just a base, one-window program. Why am I getting &quot;0&quot; for everyone of these values? The window handle is clearly not null, and in theory should work.</p>
  <p>For extra information, here are my structs that I made for JNA so it would map them:</p>
  <pre><code>    public static class WINDOWINFO extends Structure {
          public int cbSize = this.size();
          public RECT rcWindow;
          public RECT rcClient;
          public int dwStyle;
          public int dwExStyle;
          public int dwWindowStatus;
          public int cxWindowBorders;
          public int cyWindowBorders;
          public short atomWindowType;
          public short wCreatorVersion;
  
          public WINDOWINFO() {
              super();
          }
  
          public WINDOWINFO(Pointer p) {
              super(p);
          }
  
          protected List&lt;String&gt; getFieldOrder() {
              return Arrays.asList(new String[] {&quot;cbSize&quot;, &quot;rcWindow&quot;, &quot;rcClient&quot;, &quot;dwStyle&quot;, &quot;dwExStyle&quot;, &quot;dwWindowStatus&quot;, &quot;cxWindowBorders&quot;, &quot;cyWindowBorders&quot;, &quot;atomWindowType&quot;, &quot;wCreatorVersion&quot;});
          }
      }
  
      public static class RECT extends Structure {
          public NativeLong left;
          public NativeLong top;
          public NativeLong right;
          public NativeLong bottom;
  
          public RECT() {
              super();
          }
  
          public RECT(Pointer p) {
              super(p);
          }
  
          protected List&lt;String&gt; getFieldOrder() {
              return Arrays.asList(new String[] {&quot;left&quot;, &quot;top&quot;, &quot;right&quot;, &quot;bottom&quot;});
          }
      }
  </code></pre>
  <p>I am working with the WinAPI using Java and the JNA library. User32 is used to call the above calls.</p>
  <p>Any help would be appreciated. I cannot find a lot of info related to why this is happening (even on the WinAPI documentation). Thanks.</p>