i guess you can change it to:

    for(result; result!=executablePath.size(); result=::GetModuleFileNameA(....)){
       executablePath.resize(executablePath.size() * 2);
    }

but it's probably more confusing than the while loop, i think what we try to avoid with while loops is that something enters an inifinite loop if the condition is never met or because there's an uninitialized variable but i think in this case the logic is the same with a for or a while loop