Passing commands between apps

J

John

Hi

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

Thanks

Regards
 
G

Gillard

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

or you can make your app read the clipboard
 
J

John

The app is already running when command needs to be sent to it so command
line arguments are perhaps not workable here...
 
J

John

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...
 
P

Peter Morris

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
 
J

John

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
 
P

Peter Morris

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
 
S

SurturZ

Just out of interest, why didn't you tick the box in Project Properties "Make
single instance application"?
 
P

Paul

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 --------
 
J

Jeff Johnson

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."
 

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