Robert Gould
Robert Gould

Reputation: 69923

how can I programatically get the name of an application?

I'm developing an orthogonal. Reporting/Logging system for several applications and was wondering how I can get an applications name on Windows using C/C++? the obvious requirement is I can't get it as a commandline argument or have the application tell me directly so I need to query the OS.

Thanks for any ideas!

Upvotes: 0

Views: 308

Answers (2)

codymanix
codymanix

Reputation: 29540

normally the program name is passed to the main() function as argv[0].

Upvotes: 0

JaredPar
JaredPar

Reputation: 755587

You could try the following. Call GetModuleHandle passing in NULL. This will give you back the handle for the .exe of the current running process. You can then use GetModuleFileName method to get the name of the actual file. That should serve as a good "program name"

Upvotes: 3

Related Questions