示例#1
0
 private void button_start_Click(object sender, RoutedEventArgs e)
 {
     if (CommonManager.Instance.NWMode == false && CommonManager.Instance.IsConnected == true)
     {
         int count = Process.GetProcessesByName("EpgTimerSrv").Count();
         if (count > 0)
         {
             int residentMode = IniFileHandler.GetPrivateProfileInt("SET", "ResidentMode", 0, SettingPath.TimerSrvIniPath);
             if (residentMode > 0)
             {
                 MessageBox.Show("[動作設定]-[その他]-[EpgTimerSrvを常駐させる] をオフにしてください。");
             }
             else if (MessageBox.Show("EpgTimerSrv を一度終了する必要があります。終了させますか?", "確認", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
             {
                 if (CommonManager.Instance.CtrlCmd.SendClose() == ErrCode.CMD_SUCCESS)
                 {
                     count = WaitToExit() ? 0 : 1;
                 }
             }
         }
         if (count == 0)
         {
             if (ServiceCtrlClass.StartService("EpgTimer Service") == false)
             {
                 MessageBox.Show("サービスの開始に失敗しました。");
             }
             ServiceStop = true; // 接続しなおす必要がある。
         }
     }
     UpdateServiceBtn();
 }