如何使用 C# windows 应用程序将三个参数传递给其他 "demo.exe"?

How to pass three parameters to other "demo.exe" using C# windows application?

我想将三个参数传递给项目启动位置的其他 EXE,我在 C 中成功完成但我无法在 C# 中完成 windows 应用程序,请帮助我如何做?以下 C 代码适用于它

#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
char query[100];
int MYNO= 0x1133aa;
sprintf(query, "demo.exe %x test.bin",MYNO);
system(query);
return 0;
}
enter code here

如何用 C# 编写此代码,请帮助我:(

在 visual studio 中,您也可以这样做以简单地传递或避免命令行参数:

static void Main(string[] args)
{
    if (args == null)
    {
        Console.WriteLine("args is null"); // Check for null array
    }
    else
    {
        args=new string[2];
        args[0] = "welcome in";
        args[1] = "www.overflow.com";
        Console.Write("args length is ");
        Console.WriteLine(args.Length); // Write array length
        for (int i = 0; i < args.Length; i++) // Loop through array
        {
            string argument = args[i];
            Console.Write("args index ");
            Console.Write(i); // Write index
            Console.Write(" is [");
            Console.Write(argument); // Write string
            Console.WriteLine("]");
        }
    }

参见此处获取文档:https://msdn.microsoft.com/de-de/library/h6ak8zt5%28v=vs.110%29.aspx

using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    class MyProcess
    {
        // Opens the Internet Explorer application.
        void OpenApplication(string myFavoritesPath)
        {
            // Start Internet Explorer. Defaults to the home page.
            Process.Start("IExplore.exe");

            // Display the contents of the favorites folder in the browser.
            Process.Start(myFavoritesPath);
        }

        // Opens urls and .html documents using Internet Explorer.
        void OpenWithArguments()
        {
            // url's are not considered documents. They can only be opened
            // by passing them as arguments.
            Process.Start("IExplore.exe", "www.northwindtraders.com");

            // Start a Web page using a browser associated with .html and .asp files.
            Process.Start("IExplore.exe", "C:\myPath\myFile.htm");
            Process.Start("IExplore.exe", "C:\myPath\myFile.asp");
        }

        // Uses the ProcessStartInfo class to start new processes,
        // both in a minimized mode.
        void OpenWithStartInfo()
        {
            ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
            startInfo.WindowStyle = ProcessWindowStyle.Minimized;

            Process.Start(startInfo);

            startInfo.Arguments = "www.northwindtraders.com";

            Process.Start(startInfo);
        }

        static void Main()
        {
            // Get the path that stores favorite links.
            string myFavoritesPath =
                Environment.GetFolderPath(Environment.SpecialFolder.Favorites);

            MyProcess myProcess = new MyProcess();

            myProcess.OpenApplication(myFavoritesPath);
            myProcess.OpenWithArguments();
            myProcess.OpenWithStartInfo();
        }
    }
}

试试这个:

System.Diagnostics.Process.Start("demo.exe","arguments");