# JNA Implimentierungs Problem



## JavaFox (28. Apr 2014)

Hallo Leute,
Ich muss zum erreichen der Druckerjob informationen auf die Windows API zugreifen mit JNA das problem liegt darin dass ich 2 DatenTypen habe dich ich nicht weiss zu implementieren könnte mir da jemand vieleicht helfen bitte?

Was ich bis jetzt habe ist folgendes:
LPDEVMODE und  PSECURITY_DESCRIPTOR welche ich nicht weiss zu implementieren



```
package org.management.interfaces;

import java.util.Arrays;
import java.util.List;

import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinBase.SYSTEMTIME;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;


/*
 * typedef struct _JOB_INFO_2 {
  DWORD                JobId;
  LPTSTR               pPrinterName;
  LPTSTR               pMachineName;
  LPTSTR               pUserName;
  LPTSTR               pDocument;
  LPTSTR               pNotifyName;
  LPTSTR               pDatatype;
  LPTSTR               pPrintProcessor;
  LPTSTR               pParameters;
  LPTSTR               pDriverName;
  LPDEVMODE            pDevMode;
  LPTSTR               pStatus;
  PSECURITY_DESCRIPTOR pSecurityDescriptor;
  DWORD                Status;
  DWORD                Priority;
  DWORD                Position;
  DWORD                StartTime;
  DWORD                UntilTime;
  DWORD                TotalPages;
  DWORD                Size;
  SYSTEMTIME           Submitted;
  DWORD                Time;
  DWORD                PagesPrinted;
} JOB_INFO_2, *PJOB_INFO_2;
 */

public interface WinPrintJobs extends StdCallLibrary{
	
	WinPrintJobs INSTANCE = (WinPrintJobs) Native.loadLibrary("Winspool.drv", WinPrintJobs.class, W32APIOptions.UNICODE_OPTIONS);
	
	public static class _JOB_INFO_2 extends Structure {

		  public int  	 JobId;
		  public String  pPrinterName;
		  public String  pMachineName;
		  public String  pUserName;
		  public String  pDocument;
		  public String  pNotifyName;
		  public String  pDatatype;
		  public String  pPrintProcessor;
		  public String  pParameters;
		  public String  pDriverName;
		  //LPDEVMODE            pDevMode;
		  public String  pStatus;
		  //PSECURITY_DESCRIPTOR pSecurityDescriptor;
		  public int     Status;
		  public int     Priority;
		  public int     Position;
		  public int     StartTime;
		  public int     UntilTime;
		  public int     TotalPages;
		  public int     Size;
		  SYSTEMTIME     Submitted;
		  public int     Time;
		  public int     PagesPrinted;

		@Override
		protected List<? > getFieldOrder() {
			return	Arrays.asList(new String[] {"JobId", "pPrinterName", "pMachineName", "pUserName","pDocument","pNotifyName",
												"pDatatype", "pPrintProcessor", "pParameters", "pDriverName", "pDevMode",
												"pStatus", "pSecurityDescriptor", "Status", "Priority", "Position","StartTime",
												"UntilTime", "TotalPages", "Size", "Time", "PagesPrinted"
												});	
		}
		
		public _JOB_INFO_2() {
			
		}
		
		public _JOB_INFO_2(int size) {
			super(new Memory(size));
		}	
		
		//Fetch Printer Jobs

	}
	
	boolean  EnumJobs(HANDLE spooler, DWORD FirstJob, DWORD NoJobs, int level, IntByReference pRef3, int cBuf, IntByReference pcbNeeded, IntByReference pcReturned );

}
```


----------

