From 28da1fb7f9e7bf7b2898a459f3a93e3f9d8e081a Mon Sep 17 00:00:00 2001 From: Daniel Widdis Date: Fri, 16 Aug 2019 15:30:22 -0700 Subject: [PATCH] Fixed the bug, tests now pass! --- CHANGES.md | 1 + .../src/com/sun/jna/platform/win32/COM/IShellFolder.java | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index a154b39431..362a7fd1ff 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Features Bug Fixes --------- * [#1115](https://github.com/java-native-access/jna/issues/1115): Fix signature for `c.s.j.p.win32.Kernel32#CreateRemoteThread` and bind `VirtualAllocEx`, `VirtualFreeEx`, `GetExitCodeThread` in `c.s.j.p.win32.Kernel32` - [@apangin](https://github.com/apangin), [@matthiasblaesing](https://github.com/matthiasblaesing). +* [#1127](https://github.com/java-native-access/jna/issues/1127): Windows needs a wide string in `c.s.j.p.win32.COM.IShellFolder#ParseDisplayName` - [@dbwiddis](https://github.com/dbwiddis). Release 5.4.0 ============= diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IShellFolder.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IShellFolder.java index fe7f03f59f..61d5b19115 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/IShellFolder.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IShellFolder.java @@ -27,6 +27,7 @@ */ import com.sun.jna.Function; +import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.Guid.IID; import com.sun.jna.platform.win32.Guid.REFIID; @@ -480,7 +481,11 @@ public int Release() { @Override public WinNT.HRESULT ParseDisplayName(WinDef.HWND hwnd, Pointer pbc, String pszDisplayName, IntByReference pchEaten, PointerByReference ppidl, IntByReference pdwAttributes) { Function f = Function.getFunction(vTable[3], Function.ALT_CONVENTION); - return new WinNT.HRESULT(f.invokeInt(new Object[]{interfacePointer, hwnd, pbc, pszDisplayName, pchEaten, ppidl, pdwAttributes})); + // pszDisplayName is mapped as String but Windows needs + // Wide String. Convert and pass here. + char[] pszDisplayNameNative = Native.toCharArray(pszDisplayName); + return new WinNT.HRESULT(f.invokeInt(new Object[] { interfacePointer, hwnd, pbc, + pszDisplayNameNative, pchEaten, ppidl, pdwAttributes })); } @Override