string sPath = getPath(@"firefox");
private string getPath(string sProName, string lpWindowName = null)
{
string strPath="";
Process[] pro;
try
{
pro = Process.GetProcessesByName(sProName); //通过进程名找
if (pro.Length == 0)
{
return "";
}
else
{
strPath = pro[0].MainModule.FileName;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK);
}
return strPath;
}