Reputation: 69923
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
Reputation: 29540
normally the program name is passed to the main() function as argv[0].
Upvotes: 0
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