Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8289705

Handle the case where IExtractIconW::Extract returns S_FALSE

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 17, 18, 19, 20
    • client-libs

      The documentation for IExtractIconW::Extract [1] mentions the method may return S_FALSE in which case the icon extraction should be performed by the application.

      This case is not handled in Java_sun_awt_shell_Win32ShellFolder2_extractIcon [2].


      The suggestion in the article [3] is to use SH­Def­Extract­Icon [4]:

      HICON hico;
      if (SHDefExtractIcon(TEXT("C:\\Windows\\Explorer.exe"),
                           1, 0, &hico, NULL, 48) == S_OK) {
        DrawIconEx(pps->hdc, 0, 0, hico, 0, 0, 0, NULL, DI_NORMAL);
        DestroyIcon(hico);
      }


      References:
      [1] https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-iextracticonw-extract
      [2] https://github.com/openjdk/jdk/blob/94127f43a4a28a89094fa93cd1da49763134f9db/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp#L986
      [3] https://devblogs.microsoft.com/oldnewthing/20140501-00/?p=1103
      [4] https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shdefextracticonw

      The issue was raised in the code review for JDK-8282526:
      [5] https://github.com/openjdk/jdk/pull/7805#discussion_r893306463
      [6] https://github.com/openjdk/jdk/pull/7805#discussion_r893275672

            kizune Alexander Zuev
            aivanov Alexey Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: