How to find that an application is executed from command prompt or by double clicking the application ?
-
I have an application and it can be executed both through the command prompt and by double clicking the application file (i.e. App.exe). :sigh: The problem is that when the application is double clicked the GetCurrentDirectory() method gives a different path and when it is executed through command-prompt it gives a different path and so i can not use the path retrieved, so if i can identify somehow the way it is invoked, i might make a fix for it. Please HELP...!!:confused: Thanks in advance. ;)
-
I have an application and it can be executed both through the command prompt and by double clicking the application file (i.e. App.exe). :sigh: The problem is that when the application is double clicked the GetCurrentDirectory() method gives a different path and when it is executed through command-prompt it gives a different path and so i can not use the path retrieved, so if i can identify somehow the way it is invoked, i might make a fix for it. Please HELP...!!:confused: Thanks in advance. ;)
-
I have an application and it can be executed both through the command prompt and by double clicking the application file (i.e. App.exe). :sigh: The problem is that when the application is double clicked the GetCurrentDirectory() method gives a different path and when it is executed through command-prompt it gives a different path and so i can not use the path retrieved, so if i can identify somehow the way it is invoked, i might make a fix for it. Please HELP...!!:confused: Thanks in advance. ;)
Dharmendra Bhargava wrote:
I have an application and it can be executed both through the command prompt and by double clicking the application file (i.e. App.exe)...so if i can identify somehow the way it is invoked, i might make a fix for it.
Add some command-line argument to the one that is double-clicked (in Explorer).
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
I have an application and it can be executed both through the command prompt and by double clicking the application file (i.e. App.exe). :sigh: The problem is that when the application is double clicked the GetCurrentDirectory() method gives a different path and when it is executed through command-prompt it gives a different path and so i can not use the path retrieved, so if i can identify somehow the way it is invoked, i might make a fix for it. Please HELP...!!:confused: Thanks in advance. ;)
Which directory do you want? The one where your executable resides or the one from where you launch it (which could be a different directory)? In case you need the directory where the executable is located you can use
GetModuleFileName()
as already suggested. -
Thanks "zhu_lin" for the quick reply, it works fine now. :-D