Beispiel #1
0
 private void OpenTVTest(int openWait, bool acceptViewApp)
 {
     if (process == null || process.HasExited || (acceptViewApp == false && processType == "View"))
     {
         if (process != null)
         {
             process.Dispose();
         }
         processType = "TvTest";
         process     = FindTVTestProcess(processType);
         if (process == null && acceptViewApp)
         {
             processType = "View";
             process     = FindTVTestProcess(processType);
         }
         if (process == null)
         {
             // EpgTimerPlugInと仮定
             processType = "TvTest";
             process     = Process.Start(Settings.Instance.TvTestExe, Settings.Instance.TvTestCmd);
             if (acceptViewApp)
             {
                 for (int i = 0; i < 100; i++)
                 {
                     var cmdTvTest = new CtrlCmdUtil();
                     cmdTvTest.SetPipeSetting("Global\\View_Ctrl_BonConnect_" + process.Id, "View_Ctrl_BonPipe_" + process.Id);
                     if (cmdTvTest.PipeExists())
                     {
                         // Viewアプリ(EdcbPlugIn)と判断
                         processType = "View";
                         break;
                     }
                     cmdTvTest.SetPipeSetting("Global\\TvTest_Ctrl_BonConnect_" + process.Id, "TvTest_Ctrl_BonPipe_" + process.Id);
                     if (cmdTvTest.PipeExists())
                     {
                         break;
                     }
                     System.Threading.Thread.Sleep(100);
                     openWait -= 100;
                 }
             }
             if (openWait > 0)
             {
                 System.Threading.Thread.Sleep(openWait);
             }
         }
     }
 }
Beispiel #2
0
 private static Process FindTVTestProcess(string type)
 {
     Process[] processes = Process.GetProcesses();
     foreach (Process p in processes)
     {
         // 原作と異なりプロセス名ではなく接続待機用イベントの有無で判断するので注意
         var cmdTvTest = new CtrlCmdUtil();
         cmdTvTest.SetPipeSetting("Global\\" + type + "_Ctrl_BonConnect_" + p.Id, type + "_Ctrl_BonPipe_" + p.Id);
         if (cmdTvTest.PipeExists())
         {
             if (type == "View")
             {
                 // TVTestではなさそうなViewアプリは除外する(※EpgDataCap_BonもViewアプリ)
                 if (p.ProcessName.Equals(System.IO.Path.GetFileNameWithoutExtension(Settings.Instance.TvTestExe),
                                          StringComparison.OrdinalIgnoreCase) == false)
                 {
                     continue;
                 }
                 // 識別用IDが設定されたViewアプリは除外する
                 cmdTvTest.SetConnectTimeOut(1000);
                 int id = -1;
                 if (cmdTvTest.SendViewGetID(ref id) != ErrCode.CMD_SUCCESS || id >= 0)
                 {
                     continue;
                 }
             }
             foreach (Process pp in processes.Where(pp => pp != p))
             {
                 pp.Dispose();
             }
             return(p);
         }
     }
     foreach (Process p in processes)
     {
         p.Dispose();
     }
     return(null);
 }