如何编写带有程序运行参数的Windows Forms程序???

解决方案 »

  1.   

    我程序中的一段代码,
    static void Main(string [] args) 
    {
    //# if debug
    // AppDomain.CurrentDomain.UnhandledException +=new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
    // Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
    //#endif

    bool oneInstance = true;
    if(args.Length > 0)
    {
    foreach(string arg in args)
    {
    switch(arg)
    {
    case "-M":
    case "-m":
    oneInstance = false;
    break;
    case "-C":
    case "-c":
    break;
    case "-G":
    case "-g":
    break;
    case "-S":
    case "-s":
    oneInstance = true;
    break;
    default:
    oneInstance = true;
    break;
    }
    }
    }
    RunInstance(oneInstance);
    }