A program doesn't know how it was launched. Another program could have launched it by calling one of several C functions, such as CreateProcess(), system(), ShellExecute(), etc. Or it could be launched by some other non-C program using functions available to it for that purpose.
I'm not sure if this will work all the time. But I managed to get what I want by checking the return of AttachConsole when my program starts up, it returns true if my program was started from the Command Line, and false otherwise. The goal of this was to use the console my program was started in, and if I didn't have one, create a new one.
This is the code I ended up with if anyone's interested:
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...