Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 118,658 C# Programmers for FREE! Ask your question and get quick answers from experts. There are 893 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Manupulate running programs

 
Reply to this topicStart new topic

Manupulate running programs, Run program with Single Instance

sarvarbek
post 26 Jun, 2008 - 06:46 AM
Post #1


New D.I.C Head

*
Joined: 26 Jun, 2008
Posts: 2

Hi Programmers. I must write program which it can start other *.exe programs. Problem with single instance. I use for run application Process.Start (Path). How can i, if the starting program is already running, and if it is started again, make this running program active otherwise if it is not running start it.
CODE

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
        }
        private void StartProgram(string prg)
        {
           myprc =  Process.Start(prg);

          
            
        }

        private void listBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char) Keys.Enter)
            {
                    StartProgram(AllProgs.IniReadValue("Path", "path" + (listBox1.SelectedIndex+1).ToString()));
            }
            
        }

        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
           // Process[] prc = Process.GetProcessesByName(listBox1.SelectedIndex.ToString());
            
            StartProgram(AllProgs.IniReadValue("Path", "path" + (listBox1.SelectedIndex + 1).ToString()));


This post has been edited by sarvarbek: 26 Jun, 2008 - 11:19 PM
User is offlineProfile CardPM

Go to the top of the page


tody4me
post 27 Jun, 2008 - 09:49 AM
Post #2


Only Jenny Craig makes thin clients...

Group Icon
Joined: 12 Apr, 2006
Posts: 1,074



Thanked 3 times

Dream Kudos: 100
My Contributions


If the program is a single instance program, and is running, it will activate by calling the Process.Start(path) function properly. If it is not a single instance, you will need to check to see if the process is currently running, then activate.

This post has been edited by tody4me: 27 Jun, 2008 - 09:49 AM
User is offlineProfile CardPM

Go to the top of the page

sarvarbek
post 1 Jul, 2008 - 07:28 AM
Post #3


New D.I.C Head

*
Joined: 26 Jun, 2008
Posts: 2

Thanks for your answer.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/12/08 03:34AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month