1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-10 11:25:04 -05:00

Try to fix 32-bit MWS support

This commit is contained in:
Reinhard Pointner 2018-08-13 18:05:35 +07:00
parent 28d126b5a8
commit 7e4888d95f
2 changed files with 9 additions and 13 deletions

View File

@ -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;
}

View File

@ -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();
}