Java 类com.sun.jna.platform.win32.Shell32 实例源码

项目:consulo-unity3d    文件:Unity3dPackageWatcher.java   
@Nullable
private static String getUnityUserPath()
{
    if(SystemInfo.isWinVistaOrNewer)
    {
        PointerByReference pointerByReference = new PointerByReference();
        WinNT.HRESULT hresult = Shell32.INSTANCE.SHGetKnownFolderPath(Guid.GUID.fromString("{A520A1A4-1780-4FF6-BD18-167343C5AF16}"), 0, null, pointerByReference);

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

    return null;
}
项目:jpexs-decompiler    文件:Win32ProcessTools.java   
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;
}
项目:winthing    文件:WindowsModule.java   
@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);
}
项目:winthing    文件:SystemService.java   
@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);
}
项目:jpexs-decompiler    文件:Win32ProcessTools.java   
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);
}
项目:appdirs    文件:ShellFolderResolver.java   
public String resolveFolder(FolderId folderId) {
  int folder = convertFolderId(folderId);

  char[] pszPath = new char[WinDef.MAX_PATH];
  HRESULT result = Shell32.INSTANCE.SHGetFolderPath(null, folder, null, null,
      pszPath);
  if (W32Errors.S_OK.equals(result)) {
    return Native.toString(pszPath);
  }

  logger.error("SHGetFolderPath returns an error: {}", result.intValue());
  throw new AppDirsException(
      "SHGetFolderPath returns an error: " + result.intValue());
}