| 729 | } |
| 730 | |
| 731 | QString getExecutableForJarFile(const QString& jarFile) |
| 732 | { |
| 733 | const std::wstring jarFileW = jarFile.toStdWString(); |
| 734 | |
| 735 | WCHAR buffer[MAX_PATH]; |
| 736 | |
| 737 | const auto hinst = ::FindExecutableW(jarFileW.c_str(), nullptr, buffer); |
| 738 | const auto r = static_cast<int>(reinterpret_cast<std::uintptr_t>(hinst)); |
| 739 | |
| 740 | // anything <= 32 signals failure |
| 741 | if (r <= 32) { |
| 742 | log::warn("failed to find executable associated with file '{}', {}", jarFile, |
| 743 | shell::formatError(r)); |
| 744 | |
| 745 | return {}; |
| 746 | } |
| 747 | |
| 748 | DWORD binaryType = 0; |
| 749 | |
| 750 | if (!::GetBinaryTypeW(buffer, &binaryType)) { |
| 751 | const auto e = ::GetLastError(); |
| 752 | |
| 753 | log::warn("failed to determine binary type of '{}', {}", |
| 754 | QString::fromWCharArray(buffer), formatSystemMessage(e)); |
| 755 | |
| 756 | return {}; |
| 757 | } |
| 758 | |
| 759 | if (binaryType != SCS_32BIT_BINARY && binaryType != SCS_64BIT_BINARY) { |
| 760 | log::warn("unexpected binary type {} for file '{}'", binaryType, |
| 761 | QString::fromWCharArray(buffer)); |
| 762 | |
| 763 | return {}; |
| 764 | } |
| 765 | |
| 766 | return QString::fromWCharArray(buffer); |
| 767 | } |
| 768 | |
| 769 | QString getJavaHome() |
| 770 | { |
no outgoing calls
no test coverage detected