首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

外部程序启动小弟我的程序,并给小弟我的程序传参数

2012-05-27 
外部程序启动我的程序,并给我的程序传参数我最近做一个客户端程序,看开发文档中,服务器程序会主动来启动我

外部程序启动我的程序,并给我的程序传参数
我最近做一个客户端程序,看开发文档中,服务器程序会主动来启动我的程序,并把服务器的监听端口号传给我的程序,我不太明白,服务器如何能够给我的程序传参数?
原文是we will pass the port number on the argument line of your process。求高人指点

[解决办法]

C# code
    static class Program    {//外部调用方式:Win.exe <root><userid>1001</userid><password></password></root>        /// <summary>        /// 应用程序的主入口点。        /// </summary>        [STAThread]        static void Main(string[] args)        {        string str = (string.Format(("{0}"), args));        //str 就是传递过来的值            Application.EnableVisualStyles();            Application.SetCompatibleTextRenderingDefault(false);            Application.Run(new Form1());            MessageBox.Show(str);        }    }
[解决办法]
都已经说的很清楚了
we will pass the port number on the argument line of your process
就是他会执行类似于xxx.exe port这样的命令行形式来调用你的程序,参数就在main函数的args中。

热点排行