By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,671 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,671 IT Pros & Developers. It's quick & easy.

How do i use C# app to reflect data on other app textbox.

P: n/a
Hello all,

I'm using below code for c# app to call another app

{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc Enable.RaisingEvents=false;
proc StartInfo.Filename="anotherapp.exe" ;
proc StartInfor.Arguments="1234";
proc Start();
}
I'm able to call up anotheapp.exe within c# app successfully but the
data (1234) that i wanted in anotherapp.exe 's inputbox is blank.

Is there any way round to achieve this condition ?

Thanks for your help .

mcl


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I'm not exactly sure about what you want to achieve. You are mentioning an
"inputbox". What do you mean? Do you mean a TextBox control, an instance of
TextBox class? If yes, then your other app has a GUI.

In your sample code you put the string "1234" into proc.StartInfo.Arguments.
This way you specify the command line arguments for the other app. Is the
other app a console application (without GUI)?

When you assign the value "1234" to proc.StartInfo.Arguments you specify the
command line arguments. Now when you look at the entry point of the other
app it will typically look something like this for a console application:

[STAThread]
static void Main(string[] args) {
// ... your code goes here
}

If you want to access any command line arguments, then just examine the args
string array, e.g. args[0]. You might want to check, whether any arguments
have passed at all, e.g by using args.Length:

[STAThread]
static void Main(string[] args) {
if( args.Length > 0 ) {
// access arguments with subscript, e.g. args[0].
// Sample:
string firstArgument = args[0];
}
}

For a Windows application, it typically looks like this:

[STAThread]
static void Main() {
Application.Run(new MainForm());
}

In order to receive command line parameters, modify the latter to:

[STAThread]
static void Main(string[] args) {
Application.Run(new MainForm());
}

Furthermore, if the textbox is a control on MainForm, you can write:

[STAThread]
static void Main(string[] args) {
Application.Run(new MainForm(args));
}

Accordingly you would have to change the constructor for the class MainForm
so that it takes a parameter, and in the constructor you can assign your
textbox the value:

public class MainForm : System.Windows.Forms.Form {
public MainForm(string[] args) {
_theTextBox.Text = args[0];
}
//... other code ...
private System.Windows.Forms.TextBox _theTextBox;
}

I hope this sheds some light onto your question.

Best regards,
Manfred.
------
Manfred Lange, http://www.agileutilities.com, http://www.csunit.org

"mcl chan" <mc*****@tm.net.my> schrieb im Newsbeitrag
news:eU*************@tk2msftngp13.phx.gbl...
Hello all,

I'm using below code for c# app to call another app

{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc Enable.RaisingEvents=false;
proc StartInfo.Filename="anotherapp.exe" ;
proc StartInfor.Arguments="1234";
proc Start();
}
I'm able to call up anotheapp.exe within c# app successfully but the
data (1234) that i wanted in anotherapp.exe 's inputbox is blank.

Is there any way round to achieve this condition ?

Thanks for your help .

mcl


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #2

P: n/a
SSW
to get Arguments in anotheapp.exe use below

string[] Arguments = Environment.GetCommandLineArgs();

To call anotheapp.exe on button1 click u need below code
private void button1_Click(object sender, System.EventArgs e)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc Enable.RaisingEvents=false;
proc.StartInfo.FileName="anotheapp.exe" ;
proc.StartInfo.Arguments="1234";
proc.Start();
}

HTH

sswalia
MCSD, OCA, MCAD

"mcl chan" <mc*****@tm.net.my> wrote in message
news:eU*************@tk2msftngp13.phx.gbl...
Hello all,

I'm using below code for c# app to call another app

{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc Enable.RaisingEvents=false;
proc StartInfo.Filename="anotherapp.exe" ;
proc StartInfor.Arguments="1234";
proc Start();
}
I'm able to call up anotheapp.exe within c# app successfully but the
data (1234) that i wanted in anotherapp.exe 's inputbox is blank.

Is there any way round to achieve this condition ?

Thanks for your help .

mcl


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.