mercredi 29 juin 2016

How to return "if" in a if loop?

Hi guys actually first I wanted to do this loop.

Process p = Process.GetProcessesByName("etcProgram.bin")[0];
                foreach (System.Diagnostics.ProcessModule moz in p.Modules)
                    if (csh.Text == "csh" || bin.Text == "bin")
                    {
                        if (moz.FileName.IndexOf("csh") != -1)
                        {
                            csh.Text = moz.BaseAddress.ToString();
                        }
                        if (moz.FileName.IndexOf("bin") != -1)
                        {
                            bin.Text = moz.BaseAddress.ToString();
                        }
                    }
                else
                    {
                      !!!!!! return to "if" until "if code" happens !!!!!!
                    }

But my poor code knowledge can't come through this problem. So I wrote nearly same thinh with timer. Then I wrote this code.

 private void tmrActive_Tick(object sender, EventArgs e)
        {
            try
            {
                Process p = Process.GetProcessesByName("Wolfteam.bin")[0];
                foreach (System.Diagnostics.ProcessModule moz in p.Modules)
                    if (csh.Text == "csh" || bin.Text == "bin")
                    {
                        if (moz.FileName.IndexOf("csh") != -1)
                        {
                            csh.Text = moz.BaseAddress.ToString();
                        }
                        if (moz.FileName.IndexOf("bin") != -1)
                        {
                            bin.Text = moz.BaseAddress.ToString();
                        }
                    }
                else
                    {
                        tmrActive.Stop();
                        MessageBox.Show("It's stopped");
                    }
            }

But I saw that MessageBox appears 5-6 times when I started this.And I dont know why. So I dont feel very safe about use this code.

1- Do you know what's the problem with that timer. Shouldn't this messagebox appear once?

2- Can you help me about the code without timer.Is there anyway to do it?

Aucun commentaire:

Enregistrer un commentaire