Gets location of the file of a process
| 54 | public: |
| 55 | // Gets location of the file of a process |
| 56 | inline static std::pair<std::filesystem::path, HRESULT> GetProcessFileName(HANDLE process) |
| 57 | { |
| 58 | std::wstring exeLocation; |
| 59 | HRESULT hr = S_OK; |
| 60 | exeLocation.resize_and_overwrite(wil::max_extended_path_length, [process, &hr](wchar_t* data, std::size_t count) -> std::size_t |
| 61 | { |
| 62 | DWORD bufSize = static_cast<DWORD>(count) + 1; |
| 63 | if (QueryFullProcessImageName(process, 0, data, &bufSize)) |
| 64 | { |
| 65 | return bufSize; |
| 66 | } |
| 67 | else |
| 68 | { |
| 69 | hr = HRESULT_FROM_WIN32(GetLastError()); |
| 70 | return 0; |
| 71 | } |
| 72 | }); |
| 73 | |
| 74 | return { std::move(exeLocation), hr }; |
| 75 | } |
| 76 | |
| 77 | // Gets location of current process |
| 78 | inline static std::pair<std::filesystem::path, HRESULT> GetExeLocation() |
nothing calls this directly
no outgoing calls
no test coverage detected