From 522e422ac374de154cd88508ca05ad8514765ef3 Mon Sep 17 00:00:00 2001 From: IvanRF Date: Mon, 21 Dec 2015 19:57:50 -0300 Subject: [PATCH] Added Win32Exception --- CHANGES.md | 2 +- .../platform/src/com/sun/jna/platform/win32/WinspoolUtil.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 289155724..8fdd5b1fb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,7 +7,7 @@ Next release Features -------- -* [#569](https://github.com/java-native-access/jna/pull/569): Added PRINTER_INFO_2 support and GetPrinter function [@IvanRF](https://github.com/IvanRF) +* [#569](https://github.com/java-native-access/jna/pull/569): Added `com.sun.jna.platform.win32.Winspool.PRINTER_INFO_2` support and GetPrinter function in `com.sun.jna.platform.win32.Winspool` [@IvanRF](https://github.com/IvanRF) * [#526](https://github.com/java-native-access/jna/pull/526): Added initialization and conversion between Windows SYSTEMTIME and Java Calendar [@lgoldstein](https://github.com/lgoldstein) * [#532](https://github.com/java-native-access/jna/pull/529): Added `com.sun.jna.platform.win32.Mpr`, `com.sun.jna.platform.win32.LmShare`, and `com.sun.jna.platform.win32.Winnetwk` - [@amarcionek](https://github.com/amarcionek). * [#532](https://github.com/java-native-access/jna/pull/529): Added `ACCESS_*` definitions to `com.sun.jna.platform.win32.LmAccess` - [@amarcionek](https://github.com/amarcionek). diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinspoolUtil.java b/contrib/platform/src/com/sun/jna/platform/win32/WinspoolUtil.java index 82132e796..93c47d1a5 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinspoolUtil.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinspoolUtil.java @@ -97,7 +97,9 @@ public static PRINTER_INFO_2 getPrinterInfo2(String printerName) { PRINTER_INFO_2 pinfo2 = new PRINTER_INFO_2(pcbNeeded.getValue()); - Winspool.INSTANCE.GetPrinter(pHandle.getValue(), 2, pinfo2.getPointer(), pcbNeeded.getValue(), pcReturned); + if (!Winspool.INSTANCE.GetPrinter(pHandle.getValue(), 2, pinfo2.getPointer(), pcbNeeded.getValue(), pcReturned)) { + throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); + } pinfo2.read(); return pinfo2;