C# da iki exe arasında veri gönderme

C# da çağrılan exe ye parametre olarak veri gönderme işlemi. Diagnostics kütüphanesi ProcessStart sınıfı ile yapılacak. C# exe uygulamasını açacak programın kodları aşağıda. “startInfo.Arguments” kısmında her boşluk dizi elemanlarını ayırır. Burada çağırılan exe ye parametre gönderilir.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace UygulamaCalis
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
LaunchCommandLineApp();
}
static void LaunchCommandLineApp()
{

// ProcessStartInfo class
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = “deneme.exe”;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = “Veri1 Veri2”;
Process exeProcess = Process.Start(startInfo);

}
}
}

Gelen parametredeki ilk bilgiyi textbox1 atama yaptım. Bu uygulamayı ilk exenin yanına deneme.exe olarak koyun. İlk uygulamayı çalıştırıp deneme.exe yi çağırdığınızda textbox1 de gönderdiğiniz veriyi göreceksiniz.

static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 frm1 = new Form1();
if (args.Length > 0)
{
//MessageBox.Show(“Message ” + args[0]);
frm1.textBox1.Text = args[0];
}
Application.Run(frm1);
}

İyi kullanımlar.

Yorum bırakın