private static void openViaShellApi(String dir, @Nullable String toSelect) {
    if (LOG.isDebugEnabled()) LOG.debug("shell open: dir=" + dir + " toSelect=" + toSelect);

    ProcessIOExecutorService.INSTANCE.execute(() -> {
      Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_APARTMENTTHREADED);

      if (toSelect == null) {
        var res = Shell32.INSTANCE.ShellExecute(null, "explore", dir, null, null, WinUser.SW_NORMAL);
        if (res.intValue() <= 32) {
          LOG.warn("ShellExecute(" + dir + "): " + res.intValue() + " GetLastError=" + Kernel32.INSTANCE.GetLastError());
          openViaExplorerCall(dir, null);
        }
      }
      else {
        var pIdl = Shell32Ex.INSTANCE.ILCreateFromPath(dir);
        var apIdl = new Pointer[]{Shell32Ex.INSTANCE.ILCreateFromPath(toSelect)};
        var cIdl = new WinDef.UINT(apIdl.length);
        try {
          var res = Shell32Ex.INSTANCE.SHOpenFolderAndSelectItems(pIdl, cIdl, apIdl, new WinDef.DWORD(0));
          if (!WinError.S_OK.equals(res)) {
            LOG.warn("SHOpenFolderAndSelectItems(" + dir + ',' + toSelect + "): 0x" + Integer.toHexString(res.intValue()));
            openViaExplorerCall(dir, toSelect);
          }
        }
        finally {
          Shell32Ex.INSTANCE.ILFree(pIdl);
          Shell32Ex.INSTANCE.ILFree(apIdl[0]);
        }
      }
    });
  }
private static void openViaShellApi(String dir, @Nullable String toSelect)