Reputation: 682
I am trying to get the current working directory of the C++ program using Poco::Path::current(). It is working fine and gives the correct path when I run the program as normal or "Run As Administrator". But the problem occurs when run the program using "Run Elevated". The function will return "C:\WINDOWS\system32" instead of the working directory. I tried to find the solutions but so far there is none for Poco library. I found a similar problem at here but it is using GetModuleFileName which is for Windows only. I need to deploy the program in different OS like linux and Poco library takes care of that. Is there another way to get the real working directory using Poco library when running the program as elevated or I need to check if is windows, use GetModuleFileName method and else just use Poco's current() function?
Upvotes: 0
Views: 760
Reputation: 1744
If you are using Poco::Application
as your base class for your main, then you can use the Poco::Application::commandPath()
function.
If not, you can do something similar to what Poco does in Poco::Application::getApplicationPath()
.
Upvotes: 1