Help - Search - Members - Calendar
Full Version: Using ShellExecute to call Command Line application
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
hsadan
I'm developing a component that would send messages to Snarl (a notifier program) via the commandline.

I'm able to do
CODE
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
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.
T.P Wang
Note that LPCWSTR is pointer to a wide string, so I think you can use _T() Macro.
hsadan
Thanks, that did it! Somehow that didn't occur to me.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.