Skip to main content
Topic: Using ShellExecute to call Command Line application (Read 8660 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.

 
SimplePortal 1.0.0 RC1 © 2008-2020