@@ -68,18 +68,15 @@ private static PRINTER_INFO_2[] getPrinterInfo2(int flags) {
68
68
IntByReference pcbNeeded = new IntByReference ();
69
69
IntByReference pcReturned = new IntByReference ();
70
70
Winspool .INSTANCE .EnumPrinters (flags , null , 2 , null , 0 , pcbNeeded , pcReturned );
71
- if (pcbNeeded .getValue () <= 0 ) {
71
+ if (pcbNeeded .getValue () <= 0 )
72
72
return new PRINTER_INFO_2 [0 ];
73
- }
74
73
75
74
PRINTER_INFO_2 pPrinterEnum = new PRINTER_INFO_2 (pcbNeeded .getValue ());
76
- if (!Winspool .INSTANCE .EnumPrinters (flags , null , 2 , pPrinterEnum .getPointer (), pcbNeeded .getValue (),
77
- pcbNeeded , pcReturned )) {
75
+ if (!Winspool .INSTANCE .EnumPrinters (flags , null , 2 , pPrinterEnum .getPointer (), pcbNeeded .getValue (), pcbNeeded ,
76
+ pcReturned ))
78
77
throw new Win32Exception (Kernel32 .INSTANCE .GetLastError ());
79
- }
80
78
81
79
pPrinterEnum .read ();
82
-
83
80
return (PRINTER_INFO_2 []) pPrinterEnum .toArray (pcReturned .getValue ());
84
81
}
85
82
@@ -88,18 +85,16 @@ public static PRINTER_INFO_2 getPrinterInfo2(String printerName) {
88
85
IntByReference pcReturned = new IntByReference ();
89
86
HANDLEByReference pHandle = new HANDLEByReference ();
90
87
91
- Winspool .INSTANCE .OpenPrinter (printerName , pHandle , null );
88
+ if (!Winspool .INSTANCE .OpenPrinter (printerName , pHandle , null ))
89
+ throw new Win32Exception (Kernel32 .INSTANCE .GetLastError ());
92
90
93
91
Winspool .INSTANCE .GetPrinter (pHandle .getValue (), 2 , null , 0 , pcbNeeded );
94
- if (pcbNeeded .getValue () <= 0 ) {
92
+ if (pcbNeeded .getValue () <= 0 )
95
93
return new PRINTER_INFO_2 ();
96
- }
97
94
98
95
PRINTER_INFO_2 pinfo2 = new PRINTER_INFO_2 (pcbNeeded .getValue ());
99
-
100
- if (!Winspool .INSTANCE .GetPrinter (pHandle .getValue (), 2 , pinfo2 .getPointer (), pcbNeeded .getValue (), pcReturned )) {
96
+ if (!Winspool .INSTANCE .GetPrinter (pHandle .getValue (), 2 , pinfo2 .getPointer (), pcbNeeded .getValue (), pcReturned ))
101
97
throw new Win32Exception (Kernel32 .INSTANCE .GetLastError ());
102
- }
103
98
104
99
pinfo2 .read ();
105
100
return pinfo2 ;
0 commit comments