Esempio n. 1
0
        /// <summary>
        /// 发送连接串等待连接
        /// </summary>
        private void StartWork()
        {
            this.tik.Start();
            try
            {
                //打开连接
                _rdpSession.Open();

                //创建用于连接的字符串
                IRDPSRAPIInvitation invitation = _rdpSession.Invitations.CreateInvitation("PalmaeTech", "CastGroup", "", 1);

                //广播发送字符串
                _hostCaster.StartCast(invitation.ConnectionString);

                notifyIcon1.Text = "远程协助已启动";
                notifyIcon1.ShowBalloonTip(1000, "远程协助启动成功", "远程协助已启动,请等待对方操控你的电脑", ToolTipIcon.Info);

                this.ShowInTaskbar = false;
                this.Hide();

                _isRunning = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                _isRunning = false;
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            try
            {
                // enable styles, faster text rendering and protect the current process
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                ProcessSecurity.ProtectCurrentProcessFromTerminate();

                // parse the args
                var showSecurityDialog = false;
                var overrideConfig     = (string)null;
                foreach (var arg in args)
                {
                    if (arg.Equals(ParamShowSecurityDialog, StringComparison.OrdinalIgnoreCase))
                    {
                        if (!showSecurityDialog)
                        {
                            showSecurityDialog = true;
                            continue;
                        }
                    }
                    else if (arg.StartsWith(ParamOverrideConfig, StringComparison.OrdinalIgnoreCase))
                    {
                        if (overrideConfig == null)
                        {
                            overrideConfig = arg.Substring(ParamOverrideConfig.Length);
                            continue;
                        }
                    }
                    MessageBox.Show(string.Format("{0} [{1}] [{2}<path>]\n\n\n\n{1}\t\tDisplays the security dialog.\n\n{2}\tUse an alternative app config file.", Environment.GetCommandLineArgs()[0], ParamShowSecurityDialog, ParamOverrideConfig), "Usage", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                // set the config file and show the security dialog if requested
                if (overrideConfig != null)
                {
                    ((AppDomainSetup)typeof(AppDomain).GetProperty("FusionStore", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(AppDomain.CurrentDomain, null)).ConfigurationFile = overrideConfig;
                }
                configFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
                if (showSecurityDialog)
                {
                    Security.ShowEditDialog();
                    return;
                }

                // create the rdp session
                var session = new RDPSessionClass();
                session.OnError += OnSessionError;
                session.Open();
                try
                {
                    // create the web service host and run the app
                    var host = new WebServiceHost(new Service(session));
                    host.Open();
                    try { Application.Run(); }
                    finally { host.Close(); }
                }
                finally { session.Close(); }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, e.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.ExitCode = Marshal.GetHRForException(e);
            }
        }