Exemplo n.º 1
0
        /// <summary>
        /// 设置是否开机自启动时触发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnBtnAutoStartCheckedChanged(object sender, EventArgs e)
        {
            bool autoStartChecked = this.ChkAutoStart.Checked;

            updateAppConfig("AutoStart", autoStartChecked.ToString());
            AutoStartByRegistry.SetMeStart(autoStartChecked);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 设置并启动监听服务
        /// </summary>
        private void SettingAndStartService()
        {
            //设置软件自动启动
            AutoStartByRegistry.SetMeStart(bool.Parse(ConfigurationManager.AppSettings["AutoStart"]));

            //创建桌面快捷方式
            if (bool.Parse(ConfigurationManager.AppSettings["DesktopLnk"].ToString()))
            {
                AppLnkUtil.CreateDesktopQuick();
            }

            //将监听端口的端口添加到防火墙例外
            string lisenerPort = ConfigurationManager.AppSettings["ListenerPort"].ToString();

            FireWallUtil.NetFwAddPorts("WRL-PORT", int.Parse(lisenerPort), "TCP");

            //启动Http监听服务
            HttpListenerManager httpListenerManager = new HttpListenerManager();

            httpListenerManager.startHttpListener(lisenerPort);
        }