Hey guys i need help, what do i have to add to this code below to make a the button that i added to start a program like .exe in the desired path like "C:\Program Files (x86)\Starcraft 2 Beta\Starcraft2.exe".
I'm using Visual Studio 2008 and 2010 but for now for this problem I'll be using 2008.
Here is the code after i add the first button:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WinFormApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
What do i need to add to make it start that desired path file?
Thanks for any help.
9 replies to this topic
#1
Posted 10 July 2010 - 12:57 AM
|
|
|
#2
Posted 10 July 2010 - 10:32 AM
call win32 api functon ShellExecute(). See MSDN (google) for details.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.
#3
Posted 10 July 2010 - 10:10 PM
I would just use Process:Start(filepath) since you are already using Forms.
#4
Posted 29 July 2010 - 12:30 AM
tags help :D
I agree with Sky
I agree with Sky
#5
Posted 29 July 2010 - 11:13 AM
Sky said:
I would just use Process:Start(filepath) since you are already using Forms.
#6
Posted 30 July 2010 - 05:51 AM
Cybertech44 said:
Doesn't work, build failed: 'Start': identifier not found
Sorry, my mistake. It is Process::Start(), not Process:Start(). (Probably, Process.Start() in your case :D)
By the way, do you use intellisense?
EDIT: You can also add process component from toolbox.
#7
Posted 30 July 2010 - 11:53 AM
Process::Start(), Process:Start() and Process.Start() doesn't work, not sure if i have intellisense but i'm using Visual Studio Ultimate.
#8
Posted 30 July 2010 - 03:55 PM
but you should use Process component then.
You probably haven't included some needed name spaces for process.
More info:
You need to include:
Intellisense is microsoft word for Code completion.
Well, If this doesn't work, I would still recommend using process component from toolbox. If you don't really know what I mean, You should see a tool box. Then search for Process and draw it just like you would draw textbox etc. It wouldn't be drawn, however. Instead, It will go to bottom bar. Then, you may edit the property of process component like textbox, label, etc.
Good luck :)
You probably haven't included some needed name spaces for process.
More info:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
You need to include:
#using <System.dll> using namespace System; using namespace System::Diagnostics; using namespace System::ComponentModel
Intellisense is microsoft word for Code completion.
Well, If this doesn't work, I would still recommend using process component from toolbox. If you don't really know what I mean, You should see a tool box. Then search for Process and draw it just like you would draw textbox etc. It wouldn't be drawn, however. Instead, It will go to bottom bar. Then, you may edit the property of process component like textbox, label, etc.
Good luck :)
#9
Posted 01 August 2010 - 02:33 PM
I wrote myself exactly the same program (well, for StarCraft 1)
using System.Diagnostics;
public Process proces = new Process();
private void buttonName_Click(object sender, EventArgs e) //obviously, change to buttonName to name of your button
{
proces.StartInfo.FileName = "path\\to\\your\\program"; //remember to use double slashes if your path contains them
proces.StartInfo.Arguments = ""; // arguments if needed
proces.Start();
}
A conclusion is where you got tired of thinking.
#define class struct // All is public.
#10
Posted 19 July 2011 - 09:47 AM
Actually in the .NET framework, there is a managed class called "Process". This class can be used as a static or instance class. This class is found in the
The "Process" class can start and kill CPU processes and access the active processes information. It also can be use to pass redirect input, output and error input/output information from one process to another.
To make use this class, you have to include at least these name spaces in your project.
Consult MSDN library to find out how you can use "Process" class.
System::Diagnosticsname space.
The "Process" class can start and kill CPU processes and access the active processes information. It also can be use to pass redirect input, output and error input/output information from one process to another.
To make use this class, you have to include at least these name spaces in your project.
using namespace System
using namespace System::Diagnostics
Consult MSDN library to find out how you can use "Process" class.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









