Passing command line arguments

C

Cornel Gligan

Hi!

I implemented an application (named "WinCEApp") using C++ and Windows CE
SDK, that used "ShellExecuteEx" method (see
http://msdn.microsoft.com/library/d...s/wceshellui5/html/wce50lrfShellExecuteEx.asp)
to launch an other application (named "DotNetCFApp") implemented in C# with
..Net Compact Framework. "ShellExecuteEx" mothod passed to "DotNetCFApp"
application a command line argument.

If "DotNetCFApp" application is closed, in this case, when "WinCEApp"
application calls "ShellExecuteEx" method, "DotNetCFApp" is opened with the
correct command line argument passed through "Main(string[] args)" method.

But if "DotNetCFApp" application is already opened (for eg. in minimize
state), in this case, when WinCEApp" application calls "ShellExecuteEx"
method with a new command line argument, "DotNetCFApp" application is
activated but the new command line argument is not passed. After the last
call of "ShellExecuteEx" method I checked the command line argument of
"DotNetCFApp" using P/Invoke for "GetCommandLine" method (see
http://msdn.microsoft.com/library/d...us/wcecoreos5/html/wce50lrfgetcommandline.asp)
and it returned the old command line argument passed form the first call of
"ShellExecuteEx, not the new one.

I tried to replace "ShellExecuteEx" method with "CreateProcess" method (see
http://msdn.microsoft.com/library/d...-us/wcecoreos5/html/wce50lrfcreateprocess.asp)
but the results were the same.

Is there anyone who knows how I can activate and pass the new command line
argument to an application that is already running? You can conssider that
both applications are written with Windows CE SDK because I can handle the
Windows CE SDK APIs in a .Net Compact Framework application, too, using
P/Invoke technique. So, any suggestions are wellcome!

I am using Windows Mobile 5, .Net Compact Framework 1.0, Visual Studio
2005, Windows XP Pro.

Thank you in advance!

Regards,
Cornel Gligan
 
P

Paul G. Tobey [eMVP]

Of course not. You don't expect the system to call Main() again on a
running program, right? CreateProcess() won't help with this. It could
never work that way. You could create your own method of communicating with
an already-running program and send it information that would otherwise be
on the command line in that way (a user-defined message sent to the main
window, for example, or a point-to-point message queue to which you send the
new data).

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top