how to launch other program in WPF like windows form process.start
i used process.start in windows 开发者_开发知识库form to launch other program but now i want to use wpf to launch it and i dont know how and what is equivalent to it ?
<Button Margin="0,362,-432,-88" Name="activation" Click="button1_Click"
Foreground="Blue" HorizontalAlignment="Right" Width="134" Grid.Column="1">
activate virtual mouse
</Button>
You can still use Process.Start
from the C# code behind with WPF.
In your button click handler have:
private void button1_Click(object sender, RoutedEventArgs e)
{
Process virtualMouse = new Process();
virtualMouse.StartInfo.FileName = "VirtualMouse.exe"; // Needs to be full path
virtualMouse.StartInfo.Arguments = ""; // If you have any arguments
bool result = virtualMouse.Start();
}
The Process
class in the System.Diagnostics
namespace MSDN. You need to have a reference to that in your code and project.
Add:
using System.Diagnostics;
to the .cs file. There's no need to add a reference as this namespace is in "system.dll" which you will have in your project.
精彩评论