user63898
user63898

Reputation: 30915

How to get Application file name with POCO as in GetModuleFileName (Win32 API )

i try to find out way to get exe file name of the application using cross platform POCO c++ lib .

tryed with :

char* FileName ;
FileName =  const_cast<char*>(Application::name());

but all i get in the FileName char * is "Application" what do i do wrong here ?

Upvotes: 0

Views: 1092

Answers (1)

Marcus M&#252;ller
Marcus M&#252;ller

Reputation: 36402

The documentation says:

application.name: the file name of the application executable

And there's a name() method:

https://github.com/pocoproject/poco/blob/develop/Util/src/Application.cpp#L179 :

const char* Application::name() const
{
    return "Application";
}

Which I find a bit confusing. However, the docs are right:

The right way to deal with this is getting the config (Application::config()) and retrieving the data from therein.

Still, πάντα ῥεῖ's comment on your original question is right: No need to use a "portable" library for something that comes with the language. The main function's argv[0] is defined to contain the executable name.

Upvotes: 3

Related Questions