Executer une appli C# depuis une appli C# avec des arguments
Bonjour à tous,
Je suis nouveau sur le forum et débutant en C#.
Je vous explique mon problème.
Je développe actuellement deux applications en C qu'on appellera Appli1.exe et Appli2.exe.
Ces 2 appli peuvent être exécuter indépendement. Cependant, Appli1 doit pouvoir lancé Appli2 lors d'un clic sur un bouton dédié et doit passer des paramètres à appli2.
Pour le moment, j'ai codé :
Dans appli1 :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
private void buttonAppli2_Click(object sender, EventArgs e)
{
ProcessStartInfo info = new ProcessStartInfo();
// Analyse du fichier Script
info.FileName = System.Windows.Forms.Application.StartupPath + @"Appli2.exe";
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
info.CreateNoWindow = false;
info.Arguments = "12" + "32";
try
{
Process p = Process.Start(info);
// départ de la programmation
// p.Start();
output = p.StandardOutput.ReadToEnd();
// output = p.StandardOutput.ReadToEnd;
p.WaitForExit(10);
p.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
} |
Dans le Main d'Appli 2 :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
static class Program
{
/// <summary>
/// Point d'entrée principal de l'application.
/// </summary>
[STAThread]
static void Main(String[] Args)
{
if (Args.Length == 0)
{
Appli2.Test = "Mode Manuel";
}
else
{
Appli2.Test = "Mode Auto : FC_" + Args[0] + "_S_" + Args[1];
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Appli2());
}
} |
Comme vous vous en doutez, ça fonctionne pas sinon je serai pas là a vous demander de l'aide.
Ma question est donc simple : Comment on fait pour que ça marche?
J'espère que j'ai été clair.
Merci d'avance à ceux qui m'aideront.
Omegas