Connor McLaughlin 2020-09-20 20:10:03 +10:00
parent ffc840d909
commit 3950d80771
1 changed files with 9 additions and 12 deletions

View File

@ -1114,16 +1114,13 @@ bool FileSystem::DeleteDirectory(const char* Path, bool Recursive)
std::string GetProgramPath() std::string GetProgramPath()
{ {
const HANDLE hProcess = GetCurrentProcess();
std::wstring buffer; std::wstring buffer;
buffer.resize(MAX_PATH); buffer.resize(MAX_PATH);
for (;;) for (;;)
{ {
DWORD nChars = static_cast<DWORD>(buffer.size()); DWORD nChars = GetModuleFileNameW(nullptr, buffer.data(), static_cast<DWORD>(buffer.size()));
if (!QueryFullProcessImageNameW(GetCurrentProcess(), 0, buffer.data(), &nChars) && if (nChars == static_cast<DWORD>(buffer.size()) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{ {
buffer.resize(buffer.size() * 2); buffer.resize(buffer.size() * 2);
continue; continue;