| 396 | } |
| 397 | |
| 398 | std::wstring GetModulePath(HMODULE hModule) |
| 399 | { |
| 400 | static constexpr auto INITIAL_BUFFER_SIZE = MAX_PATH; |
| 401 | static constexpr auto MAX_ITERATIONS = 7; |
| 402 | std::wstring ret; |
| 403 | auto bufferSize = INITIAL_BUFFER_SIZE; |
| 404 | for (size_t iterations = 0; iterations < MAX_ITERATIONS; ++iterations) |
| 405 | { |
| 406 | ret.resize(bufferSize); |
| 407 | size_t charsReturned = 0; |
| 408 | charsReturned = GetModuleFileNameW(hModule, ret.data(), bufferSize); |
| 409 | if (charsReturned < ret.length()) |
| 410 | { |
| 411 | ret.resize(charsReturned); |
| 412 | return ret; |
| 413 | } |
| 414 | else |
| 415 | { |
| 416 | bufferSize *= 2; |
| 417 | } |
| 418 | } |
| 419 | return std::wstring(); |
| 420 | } |
| 421 | |
| 422 | std::wstring GetExeModulePath() |
| 423 | { |
no test coverage detected