::ShellExecute - Problem passing arguments
-
Hi there. I have an Console based Exe (ABC.exe) that takes some parameters. Now, I want to call this Exe from some other application and want to pass the paremeters as required. Problems: 1. I am calling this exe as below
HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW);
ABC.exe application got launched but text "Hello" never got displayed on the console. 2. In place of this hardcoded text i.e., "Hello", incase I want to send some text stored in CString type variable then how can I do that. Help will be really appretiated. Thanks PanB
PankajB wrote:
ABC.exe application got launched but text "Hello" never got displayed on the console.
Why would it be displayed on the console ? Are you retrieving it in the code of your application and prining the argument ? If yes, it's the argument at index 1, and not 0 that you have to use (the first argument is always the path to your application).
PankajB wrote:
In place of this hardcoded text i.e., "Hello", incase I want to send some text stored in CString type variable then how can I do that.
Just pass the CString object.
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
Hi there. I have an Console based Exe (ABC.exe) that takes some parameters. Now, I want to call this Exe from some other application and want to pass the paremeters as required. Problems: 1. I am calling this exe as below
HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW);
ABC.exe application got launched but text "Hello" never got displayed on the console. 2. In place of this hardcoded text i.e., "Hello", incase I want to send some text stored in CString type variable then how can I do that. Help will be really appretiated. Thanks PanB
Does your
ABC.exe
application correctly print it's first argument if launched by command line? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I am basically passing a path to a file. Target application just check whether file exists, if does not then create that file.
PankajB wrote:
Target application just check whether file exists, if does not then create that file.
You can as well create the file from the calling application as well. Why are you needing to have an executable solely for this? Or is there anything else? If the file copying takes too long and that leaves you with a frozen UI, just spawn a thread. Can't you? You haven't answered my question: Is the target application handling the command line passed on to it? Without that being done, how will it display the command line?
It is a crappy thing, but it's life -^ Carlo Pallini
-
Hi there. I have an Console based Exe (ABC.exe) that takes some parameters. Now, I want to call this Exe from some other application and want to pass the paremeters as required. Problems: 1. I am calling this exe as below
HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW);
ABC.exe application got launched but text "Hello" never got displayed on the console. 2. In place of this hardcoded text i.e., "Hello", incase I want to send some text stored in CString type variable then how can I do that. Help will be really appretiated. Thanks PanB
Let me provide few details... 1. Lets say ABC.exe just cout the text provided as an argument. 2. If I launch ABC.exe from console, >ABC.exe Hello, it prints out Hello on the Screen. 3. if I call the same application like HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW); ...it does not Just FYI, ABC.exe is a Console based Application
-
Let me provide few details... 1. Lets say ABC.exe just cout the text provided as an argument. 2. If I launch ABC.exe from console, >ABC.exe Hello, it prints out Hello on the Screen. 3. if I call the same application like HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW); ...it does not Just FYI, ABC.exe is a Console based Application
Is the calling application also a console app? If not, does it open a new console window?
-
Let me provide few details... 1. Lets say ABC.exe just cout the text provided as an argument. 2. If I launch ABC.exe from console, >ABC.exe Hello, it prints out Hello on the Screen. 3. if I call the same application like HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW); ...it does not Just FYI, ABC.exe is a Console based Application
You must show us the target application's code, where you've handled the command line passed on to it.
It is a crappy thing, but it's life -^ Carlo Pallini
-
Let me provide few details... 1. Lets say ABC.exe just cout the text provided as an argument. 2. If I launch ABC.exe from console, >ABC.exe Hello, it prints out Hello on the Screen. 3. if I call the same application like HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW); ...it does not Just FYI, ABC.exe is a Console based Application
HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\carlo.pallini\\ABC.exe", L"Hello", NULL, SW_SHOW);
works fine with my
ABC.exe
app... :rolleyes:If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\carlo.pallini\\ABC.exe", L"Hello", NULL, SW_SHOW);
works fine with my
ABC.exe
app... :rolleyes:If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]CPallini wrote:
works fine with my ABC.exe app...
You must have the final release. I tried it with Beta 3 of abc.exe and the output was "Get lost" instead of "Hello"...
-
CPallini wrote:
works fine with my ABC.exe app...
You must have the final release. I tried it with Beta 3 of abc.exe and the output was "Get lost" instead of "Hello"...
:-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hi there. I have an Console based Exe (ABC.exe) that takes some parameters. Now, I want to call this Exe from some other application and want to pass the paremeters as required. Problems: 1. I am calling this exe as below
HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW);
ABC.exe application got launched but text "Hello" never got displayed on the console. 2. In place of this hardcoded text i.e., "Hello", incase I want to send some text stored in CString type variable then how can I do that. Help will be really appretiated. Thanks PanB
PankajB wrote:
ABC.exe application got launched but text "Hello" never got displayed on the console.
Does the console window open at all?
"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