如果是winform程序
1、找到项目根目录下Program.cs
2、更改如下代码
static void Main()
变为
static void Main(string[] args)
3、args 是命令行输入的参数,后面创建窗体的代码稍做改动
Application.Run(new Form1());
变为
Form1 form = new Form1();
form.公用变量 = args... 这里请自己脑补
Application.Run(form);

解决方案 »

  1.   

    选择的文件会进到,static void Main(string[] args)中的string[] args吗?
      

  2.   

    关键是如何获取选择的文件,得看看Windows有没有相关的api了,
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            string[] args = null;
            public Form1(string[] args)
            {
                InitializeComponent();
                this.args = args;
            }
            public Form1() {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                if (args != null)
                {
                    string s2 = "您选择了以下文件:\n";
                    foreach (string s1 in args)
                    {
                        s2 += s1 + "\n";
                    }
                    MessageBox.Show(s2);
                }
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows.Forms;namespace WindowsFormsApplication1
    {
        static class Program
        {
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main(string[] args)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                if (args.Length == 0) Application.Run(new Form1());
                else Application.Run(new Form1(args));
            }
        }
    }
      

  4.   

    楼上,关键是:
    static void Main(string[] args)
    string[] args能从右键执行时得到吗?
      

  5.   

    但是老大们,我这边选择了N个文件,程序会被执行N次,如何让他只汇总执行一次呢,是下面我的注册表设置的不对么?
    Windows Registry Editor Version 5.00
    [HKEY_CLASSES_ROOT\*\shell\AA\command]
    @="C:\\AA.exe %1"