Passing commands between apps

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

How can I send simple commands like GotoClient 10, GotoSupplier 53 etc to a
WinForm app?

Thanks

Regards
 
command line arguments ???
For Each argument As String In My.Application.CommandLineArgs
' do something
Next

or you can make your app read the clipboard
 
The app is already running when command needs to be sent to it so command
line arguments are perhaps not workable here...
 
Ideally app is not aware of incoming commands and is nudged when command is
available to avoid valuable app resources being used to monitor incoming
commands...
 
You want to know how to automate your app :-) The answer is to use
remoting. I recently did this for an app I wrote, all I wanted was for it
to be a single-instance app, but when a 2nd instance started up with command
line arguments for it to pass those arguments to the existing instance.

http://mrpmorris.blogspot.com/2008/07/single-instance-application.html

You could easily add more interfaces in order to provide more functionality.
The channel type I used ensures that the app can only be automated from the
current machine, no remote connections.


Pete
 
Hi Peter

Many thanks. Is there a vb.net around? Trying to convert code to vb.net
using automatic converter hasn't worked.

Many thanks agian.

Regards
 
Many thanks. Is there a vb.net around? Trying to convert code to vb.net
using automatic converter hasn't worked.

You could compile it in C# and then use Reflector to view the generated code
as VB.NET


Pete
 
Just out of interest, why didn't you tick the box in Project Properties "Make
single instance application"?
 
Using remoting for this might be complete overkill. Sometimes I think a lot of .net programmers never did regular windows programming. If you just want to receive simple messages you can use WndProc. Register a custom windows message and send it to any window you want. Use win32 PostMessage to send it.

protected override void WndProc(ref Message m)
{
//calling the base first is important, otherwise the values you set later will be lost
base.WndProc(ref m);

//if the window message id equals the myCustomMessage message id
if((UInt32)m.Msg == myCustomMessage)
{
m.Result = (IntPtr)1;

// do something with the data
string text = m.WParam.ToInt32().ToString();
}
}
http://www.codeproject.com/KB/vb/Send_string_by_message.aspx

-------- Original Message --------
 
How can I send simple commands like GotoClient 10, GotoSupplier 53 etc to
a WinForm app?

To help you broaden your search, what you're looking for is technically
known as "interprocess communication."
 
Back
Top