com.sun.jna.platform.win32.Shell32 Java Examples

The following examples show how to use com.sun.jna.platform.win32.Shell32. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Win32ProcessTools.java    From jpexs-decompiler with GNU General Public License v3.0 7 votes vote down vote up
public static BufferedImage extractExeIcon(String fullExeFile, int index, boolean large) {
    PointerByReference iconsLargeRef = new PointerByReference();
    PointerByReference iconsSmallRef = new PointerByReference();
    int cnt = Shell32.INSTANCE.ExtractIconEx(fullExeFile, index, iconsLargeRef, iconsSmallRef, new WinDef.UINT(1)).intValue();
    if (cnt == 0) {
        return null;
    }
    Pointer iconsLarge = iconsLargeRef.getPointer();
    Pointer iconsSmall = iconsSmallRef.getPointer();

    WinDef.HICON icon;
    if (large) {
        icon = new WinDef.HICON(iconsLarge.getPointer(0));
    } else {
        icon = new WinDef.HICON(iconsSmall.getPointer(0));
    }

    BufferedImage ic = iconToImage(icon);

    User32.INSTANCE.DestroyIcon(icon);
    return ic;
}
 
Example #2
Source File: Settings.java    From gtasa-savegame-editor with MIT License 6 votes vote down vote up
private static File getSettingsFile() {
    if (WINDOWS) {
        char[] path = new char[]{};
        if (Shell32.INSTANCE.SHGetSpecialFolderPath(null, path, ShlObj.CSIDL_LOCAL_APPDATA, false)) {
            configDir = String.valueOf(path) + File.separator + "gta-sa_savegame_editor";
        } else {
            log.warn("Unable to determine appdata folder! Falling back to old config dir!");
            return new File(System.getProperty("user.home"), ".gta_sa_savegame_editor");
        }
    } else {
        String xdgConfigHome = System.getenv("XDG_CONFIG_HOME");
        if (xdgConfigHome == null || xdgConfigHome.isBlank() || xdgConfigHome.isEmpty()) {
            configDir = System.getProperty("user.home") + File.separator + ".config" + File.separator + "gta-sa_savegame_editor";
        } else {
            configDir = xdgConfigHome + File.separator + "gta-sa_savegame_editor";
        }
    }
    return new File(configDir, "config");
}
 
Example #3
Source File: WindowsModule.java    From winthing with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(User32.class).toInstance(User32.INSTANCE);
    expose(User32.class);

    bind(Kernel32.class).toInstance(Kernel32.INSTANCE);
    expose(Kernel32.class);

    bind(Advapi32.class).toInstance(Advapi32.INSTANCE);
    expose(Advapi32.class);

    bind(Shell32.class).toInstance(Shell32.INSTANCE);
    expose(Shell32.class);
}
 
Example #4
Source File: SystemService.java    From winthing with Apache License 2.0 5 votes vote down vote up
@Inject
public SystemService(final Kernel32 kernel32, final Advapi32 advapi32,
        final Shell32 shell32) throws SystemException {
    this.kernel32 = Objects.requireNonNull(kernel32);
    this.advapi32 = Objects.requireNonNull(advapi32);
    this.shell32 = Objects.requireNonNull(shell32);
    escalatePrivileges(REQUIRED_PRIVILEGES);
}
 
Example #5
Source File: Unity3dPackageWatcher.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static List<String> getUnityUserPaths()
{
	List<String> paths = new SmartList<>();
	if(SystemInfo.isWinVistaOrNewer)
	{
		paths.add(Shell32Util.getFolderPath(ShlObj.CSIDL_LOCAL_APPDATA) + "\\Unity");

		PointerByReference pointerByReference = new PointerByReference();
		// LocalLow
		WinNT.HRESULT hresult = Shell32.INSTANCE.SHGetKnownFolderPath(Guid.GUID.fromString("{A520A1A4-1780-4FF6-BD18-167343C5AF16}"), 0, null, pointerByReference);

		if(hresult.longValue() == 0)
		{
			paths.add(pointerByReference.getValue().getWideString(0) + "\\Unity");
		}
	}
	else if(SystemInfo.isMac)
	{
		paths.add(SystemProperties.getUserHome() + "/Library/Unity");
	}
	else if(SystemInfo.isLinux)
	{
		paths.add(SystemProperties.getUserHome() + "/.config/unity3d");
	}

	return paths;
}
 
Example #6
Source File: Win32ProcessTools.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public static BufferedImage getShellIcon(String path) {
    SHFILEINFO fi = new SHFILEINFO();
    BaseTSD.DWORD_PTR r = Shell32.INSTANCE.SHGetFileInfo(path, 0, fi, fi.size(), Shell32.SHGFI_ICON | Shell32.SHGFI_SMALLICON);
    if (r.intValue() == 0) {
        return null;
    }
    return iconToImage(fi.hIcon);
}