SORU
13 Mart 2012, Salı


C bir exe çalıştırmak# kodu

Benim C exe dosyası bir başvuru var# proje. Nasıl benim kod bu exe çağırmak?

CEVAP
13 Mart 2012, Salı


using System.Diagnostics;
class Program
{
    static void Main()
    {
    //
    // Use Process.Start here.
    //
    Process.Start("C:\\");
    }
}

Eğer uygulamanız cmd bağımsız değişken gerekiyorsa, bu gibi bir şey kullanabilirsiniz:

using System.Diagnostics;

class Program
{
    static void Main()
    {
    LaunchCommandLineApp();
    }

    /// <summary>
    /// Launch the legacy application with some options set.
    /// </summary>
    static void LaunchCommandLineApp()
    {
    // For the example
    const string ex1 = "C:\\";
    const string ex2 = "C:\\Dir";

    // Use ProcessStartInfo class
    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.CreateNoWindow = false;
    startInfo.UseShellExecute = false;
    startInfo.FileName = "dcm2jpg.exe";
    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
    startInfo.Arguments = "-f j -o \""   ex1   "\" -z 1.0 -s y "   ex2;

    try
    {
        // Start the process with the info we specified.
        // Call WaitForExit and then the using statement will close.
        using (Process exeProcess = Process.Start(startInfo))
        {
        exeProcess.WaitForExit();
        }
    }
    catch
    {
        // Log error.
    }
    }
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Brendan van Son

    Brendan van

    5 Aralık 2006
  • ChrisCrossMedia

    ChrisCrossMe

    17 EYLÜL 2009
  • wwjoshdew

    wwjoshdew

    1 AĞUSTOS 2007