Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Using ShellExecute to call Command Line application (Read 9391 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Using ShellExecute to call Command Line application

I'm developing a component that would send messages to Snarl (a notifier program) via the commandline.

I'm able to do
Code: [Select]
system("C:\\snarl_command.exe /M \"Hello\" \"World\"")
but that creates the command prompt window (for a split second)so I'm trying to use ShellExecute() instead.

I'm now trying
Code: [Select]
ShellExecute(NULL, LPCWSTR("open"), LPCWSTR("C:\\snarl_command.exe"), LPCWSTR("/M \"Hello\" \"World\""), NULL, SW_HIDE)
but for some reason this doesn't seem to do anything.

any suggestions as to what might be wrong or how I can go about debugging this?

my guess is that maybe I cannot simply use NULL as the first argument (quote MSDN: A handle to the owner window used for displaying a user interface (UI) or error messages. This value can be NULL if the operation is not associated with a window.).
to clarify this, are components associated with any windows?

thanks in advance.

Using ShellExecute to call Command Line application

Reply #1
Note that LPCWSTR is pointer to a wide string, so I think you can use _T() Macro.

Using ShellExecute to call Command Line application

Reply #2
Thanks, that did it! Somehow that didn't occur to me.