We have a console app which we launch from command prompt for debugging, but we also launch this as an NT service for production.
Right now, the code has this logic:<
If your application is running as a console application (when not running as a service), a simple solution is to check whether a console has been allocated:
if(GetConsoleWindow()) { //Running as console Application } else { //Running as Service }