How to check if program is running?

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 1396 Views - Last Post: 22 June 2014 - 08:38 AM Rate Topic: -----

#1 qTeke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-June 14

How to check if program is running?

Posted 15 June 2014 - 06:57 AM

How can i make a "online counter" using database php connection? I want to have a counter and this counter to increase when the program it's at 'x' form, or when press a button to increase the value of counter. Thank you in advance.
Is This A Good Question/Topic? 0
  • +

Replies To: How to check if program is running?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13568
  • View blog
  • Posts: 54,135
  • Joined: 12-June 08

Re: How to check if program is running?

Posted 15 June 2014 - 06:58 AM

That really doesn't make sense. What?
Was This Post Helpful? 0
  • +
  • -

#3 qTeke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-June 14

Re: How to check if program is running?

Posted 15 June 2014 - 07:06 AM

View Postmodi123_1, on 15 June 2014 - 06:58 AM, said:

That really doesn't make sense. What?

I want to make a bot that start only if 5 other bots are opened.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13568
  • View blog
  • Posts: 54,135
  • Joined: 12-June 08

Re: How to check if program is running?

Posted 15 June 2014 - 07:16 AM

Okay... be more specific.. bot for what?
Was This Post Helpful? 0
  • +
  • -

#5 qTeke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-June 14

Re: How to check if program is running?

Posted 15 June 2014 - 07:25 AM

For league of legends. I want to check if all 6 bots have log in and are ready to play.
Was This Post Helpful? 0
  • +
  • -

#6 Sheepings  Icon User is offline

  • D.I.C Addict

Reputation: 73
  • View blog
  • Posts: 571
  • Joined: 05-December 13

Re: How to check if program is running?

Posted 15 June 2014 - 07:32 AM

So you want a form/program to open x amount of times and a counter for that form to populate a database connection similar to how its done in php and you want it counting how many times said form/program has been opened already. That's what I get from how you explained it... Can you elaborate on what it is you are trying to do?

Ok Edit: So its for a game, and what have you tried already?

This post has been edited by Sheepings: 15 June 2014 - 07:33 AM

Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13568
  • View blog
  • Posts: 54,135
  • Joined: 12-June 08

Re: How to check if program is running?

Posted 15 June 2014 - 07:33 AM

I would suggest looking at their apis.

http://www.elophant....egends/api/docs
http://developer.riotgames.com/
Was This Post Helpful? 0
  • +
  • -

#8 Sheepings  Icon User is offline

  • D.I.C Addict

Reputation: 73
  • View blog
  • Posts: 571
  • Joined: 05-December 13

Re: How to check if program is running?

Posted 15 June 2014 - 07:38 AM

If you know the query port of the server, you could make a simple app to query the game server for information.
Was This Post Helpful? 0
  • +
  • -

#9 qTeke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-June 14

Re: How to check if program is running?

Posted 15 June 2014 - 08:43 AM

It doens't have right now any link with the game. I just make a program with a database connected, i make system that allow u to register and login, and after login i want to put a temporary button and if i press it, the counter goes to 1. If another people, have the program and he is logged and press the button, the counter should go to 2. That's what i want to do, and when the counter hit the value of 6 then do another action.
Was This Post Helpful? 0
  • +
  • -

#10 Sheepings  Icon User is offline

  • D.I.C Addict

Reputation: 73
  • View blog
  • Posts: 571
  • Joined: 05-December 13

Re: How to check if program is running?

Posted 15 June 2014 - 09:24 AM

Set some variables first and then go from there. I can show you some variables you might want to use and I will explain their use. But first, lets see what you got so far? Post your code and we can maybe suggest some things depending if you understand the basics involved.
Was This Post Helpful? 0
  • +
  • -

#11 qTeke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-June 14

Re: How to check if program is running?

Posted 21 June 2014 - 08:27 AM

I have coded 2 form till now, here's the code:
*This is the login form:
private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string myConnection = "datasource=*****;port=3306;username=root";
                MySqlConnection myConn = new MySqlConnection(myConnection);

                MySqlCommand SelectCommand = new MySqlCommand("select * from test_database.inregistrati where Username='" + this.username_txt.Text + "' and Password='" + this.password_txt.Text + "' ;", myConn);
                MySqlDataReader myReader;
                myConn.Open();
                myReader = SelectCommand.ExecuteReader();
                int count = 0;
                while (myReader.Read())
                {
                    count = count + 1;
                }
                if (count == 1)
                {
                    MessageBox.Show("SuccesMsg1");
                    this.Hide();
                    Form2 f2 = new Form2();
                    f2.ShowDialog();
                }
                else if (count > 1)
                {
                    MessageBox.Show("ErrorMsg1");
                }
                else
                {
                    MessageBox.Show("ErrorMsg2");
                }
                myConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }




*This is the register form:
private void Register_Click(object sender, EventArgs e)
        {
            string constring="datasource=*******;port=3306;username=root";
            string Query = "insert into test_database.inregistrati (Nr,Username,EMail,Password) values('" + this.nr_txt.Text + "','" + this.username_txt.Text + "','" + this.email_txt.Text + "','" + this.password_txt.Text + "') ;";
            MySqlConnection conDataBase = new MySqlConnection(constring);
            MySqlCommand cmdDatabase = new MySqlCommand(Query, conDataBase);
            MySqlDataReader myReader;
            try
            {
                conDataBase.Open();
                myReader=cmdDatabase.ExecuteReader();
                    MessageBox.Show("Inregistrat cu succes");
                while(myReader.Read())
                {

                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }


Was This Post Helpful? 0
  • +
  • -

#12 Sheepings  Icon User is offline

  • D.I.C Addict

Reputation: 73
  • View blog
  • Posts: 571
  • Joined: 05-December 13

Re: How to check if program is running?

Posted 21 June 2014 - 10:28 AM

So what is the problem with your code? Why are you not using parameters? When you don't use parameters, you are open to SQL injection attacks, and its better practice to use them. Example:
//Opp being your table. @ is your target value parameter. MySqlConn is your connection. 
{
	MySqlCommand cmdcom = new MySqlCommand("Insert Into Opp (app_a1, app_B2)  VALUES (@app_a1, @app_B2) ;", MysqlConn);
	cmdcom.Parameters.AddWithValue("@app_a1", "A String");
	cmdcom.Parameters.AddWithValue("@app_b2", "B String");
}

You also should be using ' Dispose ' and ' Close ' after you're done reading. Close the connection and then dispose of it once its cycle is completed and no longer needed. If you want to be lazy, use ' Using Blocks ' in side your ' Try Block ' for your datareader.

You also have this posted in the wrong section, this belongs in C# forum, I've asked a mod to move it.
Was This Post Helpful? 1
  • +
  • -

#13 qTeke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-June 14

Re: How to check if program is running?

Posted 21 June 2014 - 11:50 AM

Ok, and how i can read the data, increase by 1, and sending it back?
Was This Post Helpful? 0
  • +
  • -

#14 Sheepings  Icon User is offline

  • D.I.C Addict

Reputation: 73
  • View blog
  • Posts: 571
  • Joined: 05-December 13

Re: How to check if program is running?

Posted 21 June 2014 - 03:11 PM

For get about incrementing and reading. You first need to set this up properly. For that, I recommend that you start with the Register form and start by implementing parameters into your query string. Which is not hard to do. Then once you've made that edition to your code, we will look at rewriting the rest of it for executing the insert commands.

There is no point doing the login yet, since your database wont have anything to read. So building the reader at this point is pointless. This link will get you started in the right direction. Post back when you get stuck.

Re-reading your topic, and I was a little lost as to what it was you want to do here, anyway; you may have missed this

View Postmodi123_1, on 15 June 2014 - 03:33 PM, said:


Why don't you use the API that was previously linked? It's designed to work with the game. If you continue going with a custom method its going to be a lot more work, just so you know. Either way, whatever you decide, lets know when you get stuck.
Was This Post Helpful? 0
  • +
  • -

#15 Michael26  Icon User is offline

  • Futurama: Insert funny joke here
  • member icon

Reputation: 414
  • View blog
  • Posts: 1,664
  • Joined: 08-April 09

Re: How to check if program is running?

Posted 22 June 2014 - 02:39 AM

Game developer put this APIs so they can prevent execution of the malicious code, so yeah use their own don't chaet.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2