| 6 | #include <tuple> |
| 7 | |
| 8 | std::wstring GetModuleFileNameW(HMODULE hModule) |
| 9 | { |
| 10 | static constexpr auto INITIAL_BUFFER_SIZE = MAX_PATH; |
| 11 | static constexpr auto MAX_ITERATIONS = 7; |
| 12 | std::wstring ret; |
| 13 | auto bufferSize = INITIAL_BUFFER_SIZE; |
| 14 | for (size_t iterations = 0; iterations < MAX_ITERATIONS; ++iterations) |
| 15 | { |
| 16 | ret.resize(bufferSize); |
| 17 | auto charsReturned = GetModuleFileNameW(hModule, &ret[0], bufferSize); |
| 18 | if (charsReturned < ret.length()) |
| 19 | { |
| 20 | ret.resize(charsReturned); |
| 21 | return ret; |
| 22 | } |
| 23 | else |
| 24 | { |
| 25 | bufferSize *= 2; |
| 26 | } |
| 27 | } |
| 28 | return L""; |
| 29 | } |
| 30 | |
| 31 | auto starts_with = [](const std::wstring &big_str, const std::wstring &small_str) -> auto |
| 32 | { |
no outgoing calls