| 7 | HMODULE hUAL = NULL; |
| 8 | |
| 9 | std::filesystem::path GetModulePath(HMODULE hModule) |
| 10 | { |
| 11 | static constexpr auto INITIAL_BUFFER_SIZE = MAX_PATH; |
| 12 | static constexpr auto MAX_ITERATIONS = 7; |
| 13 | |
| 14 | std::u16string ret; |
| 15 | std::filesystem::path pathret; |
| 16 | auto bufferSize = INITIAL_BUFFER_SIZE; |
| 17 | for (size_t iterations = 0; iterations < MAX_ITERATIONS; ++iterations) |
| 18 | { |
| 19 | ret.resize(bufferSize); |
| 20 | size_t charsReturned = 0; |
| 21 | charsReturned = GetModuleFileNameW(hModule, (LPWSTR)&ret[0], bufferSize); |
| 22 | if (charsReturned < ret.length()) |
| 23 | { |
| 24 | ret.resize(charsReturned); |
| 25 | pathret = ret; |
| 26 | return pathret; |
| 27 | } |
| 28 | else |
| 29 | { |
| 30 | bufferSize *= 2; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | return {}; |
| 35 | } |
| 36 | |
| 37 | void Init() |
| 38 | { |
no test coverage detected