title: How do I map a pointer to an array of structures in JNA
body: <p>I'm trying to map the Win32 function <a href="http://msdn.microsoft.com/en-us/library/dd162625%28v=vs.85%29.aspx" rel="nofollow">EnumJobs</a> in JNA.  The method has the following signature:</p>
  
  <pre><code>BOOL EnumJobs(
    __in   HANDLE hPrinter,
    __in   DWORD FirstJob,
    __in   DWORD NoJobs,
    __in   DWORD Level,
    __out  LPBYTE pJob,
    __in   DWORD cbBuf,
    __out  LPDWORD pcbNeeded,
    __out  LPDWORD pcReturned
  );
  </code></pre>
  
  <p>I figured out most of it except LPBYTE pJob which according to the documentation is a pointer to a buffer that receives an array of JOB_INFO structures.  I can't seem to figure out how to do this mapping correctly.  So far I have:</p>
  
  <pre><code>   boolean EnumJobs(HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs, DWORD Level, JOB_INFO_2[] pJob, DWORD cbBuf, IntByReference pcbNeeded, IntByReference pcReturned );
  </code></pre>
  
  <p>but I'm getting an IllegalArgumentException: Can't determine size of nested structure: can't instantiate class com.sun.jna.structure (java.lang.InstantiationException)  Any insight into how this should be mapped and handle would be greatly appreciated.</p>