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.Tex t = 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******** *****@tk2msftng p13.phx.gbl...
Hello all,
I'm using below code for c# app to call another app
{
System.Diagnost ics.Process proc = new System.Diagnost ics.Process();
proc Enable.RaisingE vents=false;
proc StartInfo.Filen ame="anotherapp .exe" ;
proc StartInfor.Argu ments="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!