当前位置: 首页>>代码示例>>C#>>正文


C# CommandLineArguments.Add方法代码示例

本文整理汇总了C#中CommandLineArguments.Add方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineArguments.Add方法的具体用法?C# CommandLineArguments.Add怎么用?C# CommandLineArguments.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandLineArguments的用法示例。


在下文中一共展示了CommandLineArguments.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Connect

            public override bool Connect()
            {
                try
                {
                    _isPuttyNg = IsFilePuttyNg(PuttyPath);

                    PuttyProcess = new Process();
                    var _with1 = PuttyProcess.StartInfo;
                    _with1.UseShellExecute = false;
                    _with1.FileName = _PuttyPath;

                    CommandLineArguments arguments = new CommandLineArguments();
                    arguments.EscapeForShell = false;

                    arguments.Add("-load", InterfaceControl.Info.PuttySession);
                    arguments.Add("-" + _PuttyProtocol.ToString());

                    if (_PuttyProtocol == Putty_Protocol.ssh)
                    {
                        string username = "";
                        string password = "";

                        if (!string.IsNullOrEmpty(InterfaceControl.Info.Username))
                        {
                            username = InterfaceControl.Info.Username;
                        }
                        else
                        {
                            if (Settings.Default.EmptyCredentials == "windows")
                            {
                                username = Environment.UserName;
                            }
                            else if (Settings.Default.EmptyCredentials == "custom")
                            {
                                username = Settings.Default.DefaultUsername;
                            }
                        }

                        if (!string.IsNullOrEmpty(InterfaceControl.Info.Password))
                        {
                            password = InterfaceControl.Info.Password;
                        }
                        else
                        {
                            if (Settings.Default.EmptyCredentials == "custom")
                            {
                                password = Security.Crypt.Decrypt(Settings.Default.DefaultPassword, AppInfo.General.EncryptionKey);
                            }
                        }

                        arguments.Add("-" + (int)_PuttySSHVersion);
                        arguments.Add("-l", username);
                        arguments.Add("-pw", password);
                    }

                    arguments.Add("-P", InterfaceControl.Info.Port.ToString());
                    arguments.Add(InterfaceControl.Info.Hostname);

                    if (_isPuttyNg)
                    {
                        arguments.Add("-hwndparent", InterfaceControl.Handle.ToString());
                    }

                    _with1.Arguments = arguments.ToString();

                    //REMOVE IN RELEASE!
                #if DEBUG
                    Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg,
                                                        "PuTTY Arguments: " + PuttyProcess.StartInfo.Arguments, true);
                    Debug.WriteLine("PuTTY Arguments: " + PuttyProcess.StartInfo.Arguments);
                #endif

                    PuttyProcess.EnableRaisingEvents = true;
                    PuttyProcess.Exited += ProcessExited;

                    PuttyProcess.Start();
                    PuttyProcess.WaitForInputIdle(Settings.Default.MaxPuttyWaitTime * 1000);

                    int startTicks = Environment.TickCount;
                    while (PuttyHandle.ToInt32() == 0 & Environment.TickCount < startTicks + (Settings.Default.MaxPuttyWaitTime * 1000))
                    {
                        if (_isPuttyNg)
                        {
                            PuttyHandle = Native.FindWindowEx(InterfaceControl.Handle, IntPtr.Zero, Constants.vbNullString, Constants.vbNullString);
                        }
                        else
                        {
                            PuttyProcess.Refresh();
                            PuttyHandle = PuttyProcess.MainWindowHandle;
                        }
                        if (PuttyHandle.ToInt32() == 0)
                            Thread.Sleep(50);
                    }

                    if (!_isPuttyNg)
                    {
                        Native.SetParent(PuttyHandle, InterfaceControl.Handle);
                    }

                    Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strPuttyStuff, true);
//.........这里部分代码省略.........
开发者ID:824462811,项目名称:mRemoteNC,代码行数:101,代码来源:Connection.Protocol.PuttyBase.cs


注:本文中的CommandLineArguments.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。