From 7e4888d95f63a8fd39f39fc89e2d34158353fb8e Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 13 Aug 2018 18:05:35 +0700 Subject: [PATCH] Try to fix 32-bit MWS support --- .../net/filebot/platform/windows/Kernel32.java | 4 ++-- .../platform/windows/WinAppUtilities.java | 18 +++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/source/net/filebot/platform/windows/Kernel32.java b/source/net/filebot/platform/windows/Kernel32.java index 9e9e2945..be6f491f 100644 --- a/source/net/filebot/platform/windows/Kernel32.java +++ b/source/net/filebot/platform/windows/Kernel32.java @@ -8,10 +8,10 @@ import com.sun.jna.win32.W32APIOptions; public interface Kernel32 extends StdCallLibrary { - public static final long APPMODEL_ERROR_NO_PACKAGE = 15700; - Kernel32 INSTANCE = Native.loadLibrary("kernel32", Kernel32.class, W32APIOptions.DEFAULT_OPTIONS); long GetCurrentPackageFullName(UINTByReference packageFullNameLength, LPWSTR packageFullName); + long APPMODEL_ERROR_NO_PACKAGE = 15700; + } diff --git a/source/net/filebot/platform/windows/WinAppUtilities.java b/source/net/filebot/platform/windows/WinAppUtilities.java index 72b2f8df..cb4619a2 100644 --- a/source/net/filebot/platform/windows/WinAppUtilities.java +++ b/source/net/filebot/platform/windows/WinAppUtilities.java @@ -12,6 +12,7 @@ import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.WString; import com.sun.jna.platform.win32.Shell32; +import com.sun.jna.platform.win32.W32Errors; import com.sun.jna.platform.win32.WinDef.UINT; import com.sun.jna.platform.win32.WinDef.UINTByReference; import com.sun.jna.platform.win32.WinError; @@ -41,20 +42,15 @@ public class WinAppUtilities { } public static String getPackageName() { - System.out.println("WinAppUtilities.getPackageName()"); - UINTByReference length = new UINTByReference(new UINT(0)); - Kernel32.INSTANCE.GetCurrentPackageFullName(length, null); - - System.out.println(length); - System.out.println(length.getValue()); - System.out.println(length.getValue().longValue()); + if (Kernel32.INSTANCE.GetCurrentPackageFullName(length, null) != W32Errors.ERROR_SUCCESS) { + throw new IllegalStateException("Kernel32.GetCurrentPackageFullName"); + } LPWSTR lpwstr = new LPWSTR(new Memory(length.getValue().intValue() * Native.WCHAR_SIZE)); - Kernel32.INSTANCE.GetCurrentPackageFullName(length, lpwstr); - System.out.println(length); - System.out.println(length.getValue()); - System.out.println(lpwstr); + if (Kernel32.INSTANCE.GetCurrentPackageFullName(length, null) != W32Errors.ERROR_SUCCESS) { + throw new IllegalStateException("Kernel32.GetCurrentPackageFullName"); + } return lpwstr.toString(); }