示例#1
0
 private void tmrUpdate_Tick(object sender, EventArgs e)
 {
     if (dsrProcess == null)
     {
         DSRProcess result = DSRProcess.GetProcess();
         if (result != null)
         {
             lblProcessValue.Text      = result.ID.ToString();
             lblVersionValue.Text      = result.Version;
             lblVersionValue.ForeColor = result.Valid ? Color.DarkGreen : Color.DarkRed;
             dsrProcess = result;
         }
     }
     else
     {
         if (dsrProcess.Alive())
         {
             if (dsrProcess.Loaded())
             {
                 if (!loaded)
                 {
                     dsrProcess.LoadPointers();
                     resetFilter();
                     loaded = true;
                 }
                 else
                 {
                     lblWorldValue.Text    = dsrProcess.GetWorld().ToString();
                     lblFilterIDValue.Text = dsrProcess.GetFilter().ToString();
                     if (activeProfile != null)
                     {
                         updateFilters();
                     }
                 }
             }
             else if (loaded && !dsrProcess.Loaded())
             {
                 lblWorldValue.Text    = "None";
                 lblFilterIDValue.Text = "None";
                 loaded = false;
             }
         }
         else
         {
             dsrProcess.Close();
             dsrProcess                = null;
             lblProcessValue.Text      = "None";
             lblVersionValue.Text      = "None";
             lblVersionValue.ForeColor = Color.Black;
             lblWorldValue.Text        = "None";
             lblFilterIDValue.Text     = "None";
             loaded = false;
         }
     }
 }
        public static DSRProcess GetProcess()
        {
            DSRProcess result = null;

            Process[] candidates = Process.GetProcessesByName("DarkSoulsRemastered");
            if (candidates.Length > 0)
            {
                Process candidate = candidates[0];
                if (!candidate.HasExited)
                {
                    result = new DSRProcess(candidate);
                }
            }
            return(result);
        }