日期:2014-05-20  浏览次数:20852 次

c#如何获取进程程序路径
c#如何获取进程程序路径,有知道如何获取的帮忙了

------解决方案--------------------
MSDN

Process类.自已仔细看一下.
------解决方案--------------------
查一下MSDN

Process类
------解决方案--------------------
Process.MainModule. FileName { get; }


Process myProcess = new Process();
// Get the process start information of notepad.
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo( "notepad.exe ");
// Assign 'StartInfo ' of notepad to 'StartInfo ' of 'myProcess ' object.
myProcess.StartInfo = myProcessStartInfo;
// Create a notepad.
myProcess.Start();
System.Threading.Thread.Sleep(1000);
ProcessModule myProcessModule;
// Get all the modules associated with 'myProcess '.
ProcessModuleCollection myProcessModuleCollection = myProcess.Modules;
Console.WriteLine( "File names of the modules associated "
+ "with 'notepad ' are: ");
// Display the 'FileName ' of each of the modules.
for( int i = 0;i < myProcessModuleCollection.Count; i++)
{
myProcessModule = myProcessModuleCollection[i];
Console.WriteLine(myProcessModule.ModuleName+ " : "
+myProcessModule.FileName);
}
// Get the main module associated with 'myProcess '.
myProcessModule = myProcess.MainModule;
// Display the 'FileName ' of the main module.
Console.WriteLine( "The process 's main module 's FileName is: "
+myProcessModule.FileName);
myProcess.CloseMainWindow();