From 61e2f5488448f23b206006e30457cc8a90b116cf Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 14 Aug 2018 01:49:09 +0700 Subject: [PATCH] Try to fix 32-bit MWS support --- source/net/filebot/platform/windows/Kernel32.java | 5 +++-- .../net/filebot/platform/windows/WinAppUtilities.java | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/source/net/filebot/platform/windows/Kernel32.java b/source/net/filebot/platform/windows/Kernel32.java index 3df748f6..5fee71d9 100644 --- a/source/net/filebot/platform/windows/Kernel32.java +++ b/source/net/filebot/platform/windows/Kernel32.java @@ -1,6 +1,7 @@ package net.filebot.platform.windows; import com.sun.jna.Native; +import com.sun.jna.NativeLong; import com.sun.jna.platform.win32.WTypes.LPWSTR; import com.sun.jna.platform.win32.WinDef.UINTByReference; import com.sun.jna.win32.StdCallLibrary; @@ -13,8 +14,8 @@ public interface Kernel32 extends StdCallLibrary { long APPMODEL_ERROR_NO_PACKAGE = 15700; long ERROR_INSUFFICIENT_BUFFER = 122; - long GetCurrentPackageFullName(UINTByReference packageFullNameLength, LPWSTR packageFullName); + NativeLong GetCurrentPackageFullName(UINTByReference packageFullNameLength, LPWSTR packageFullName); - long GetCurrentApplicationUserModelId(UINTByReference applicationUserModelIdLength, LPWSTR applicationUserModelId); + NativeLong GetCurrentApplicationUserModelId(UINTByReference applicationUserModelIdLength, LPWSTR applicationUserModelId); } diff --git a/source/net/filebot/platform/windows/WinAppUtilities.java b/source/net/filebot/platform/windows/WinAppUtilities.java index 436e93e7..1fecbac1 100644 --- a/source/net/filebot/platform/windows/WinAppUtilities.java +++ b/source/net/filebot/platform/windows/WinAppUtilities.java @@ -10,6 +10,7 @@ import javax.swing.UIManager; import com.sun.jna.Memory; import com.sun.jna.Native; +import com.sun.jna.NativeLong; import com.sun.jna.WString; import com.sun.jna.platform.win32.Shell32; import com.sun.jna.platform.win32.W32Errors; @@ -45,10 +46,10 @@ public class WinAppUtilities { UINTByReference packageFullNameLength = new UINTByReference(new UINT(64)); LPWSTR packageFullName = new LPWSTR(new Memory(packageFullNameLength.getValue().intValue() * Native.WCHAR_SIZE)); - long r = Kernel32.INSTANCE.GetCurrentPackageFullName(packageFullNameLength, packageFullName); + NativeLong r = Kernel32.INSTANCE.GetCurrentPackageFullName(packageFullNameLength, packageFullName); - if (r != W32Errors.ERROR_SUCCESS) { - throw new IllegalStateException(String.format("Kernel32.GetCurrentPackageFullName (%d)", r)); + if (r.intValue() != W32Errors.ERROR_SUCCESS) { + throw new IllegalStateException(String.format("Kernel32.GetCurrentPackageFullName (%s)", r)); } return packageFullName.getValue(); @@ -58,9 +59,9 @@ public class WinAppUtilities { UINTByReference applicationUserModelIdLength = new UINTByReference(new UINT(64)); LPWSTR applicationUserModelId = new LPWSTR(new Memory(applicationUserModelIdLength.getValue().intValue() * Native.WCHAR_SIZE)); - long r = Kernel32.INSTANCE.GetCurrentApplicationUserModelId(applicationUserModelIdLength, applicationUserModelId); + NativeLong r = Kernel32.INSTANCE.GetCurrentApplicationUserModelId(applicationUserModelIdLength, applicationUserModelId); - if (r != W32Errors.ERROR_SUCCESS) { + if (r.intValue() != W32Errors.ERROR_SUCCESS) { throw new IllegalStateException(String.format("Kernel32.GetCurrentApplicationUserModelId (%d)", r)); }