- Application.StartupPath //如何获取当前进程所属程序的文件夹位置 (窗体中使用)
- ( label16.Text=Application.StartupPath;)
- Environment.SystemDirectory; //获取系统目录
- Environment.CurrentDirectory; //获取当前目录 (类中使用)
- //获取进程数组==模块信息
- Process[] allProcesses = Process.GetProcesses();
- foreach(Process p in allProcesses)
- {
- if(p.ProcessName.Equals("Idle"))
- {
- continue;
- }
- labelPN.Text = theNode.processInfo.ProcessName; //进程名称
- labelPID.Text = theNode.processInfo.Id.ToString();//进程ID
- labelSO.Text = theNode.processInfo.StartTime.Date.ToString();//进程开始时间
- labelNOT.Text = theNode.processInfo.Threads.Count.ToString(); //线程数目
- ProcessModuleCollection allModules = null;
- try
- {
- allModules = p.Modules;
- }
- catch
- {
- continue;
- }
- ProcessModule[] modules = new ProcessModule[allModules.Count];
- int i = 0;
- foreach(ProcessModule m in allModules)
- {
- modules.SetValue(m, i++);
- }
- labelMN.Text = theNode.moduleInfo.ModuleName;
- labelCN.Text = theNode.moduleInfo.FileVersionInfo.CompanyName;
- labelLFF.Text = theNode.moduleInfo.FileVersionInfo.FileName;
- labelFV.Text = theNode.moduleInfo.FileVersionInfo.FileVersion;
- if(!theNode.moduleInfo.FileVersionInfo.FileDescription.Equals(""))
- labelFD.Text = theNode.moduleInfo.FileVersionInfo.FileDescription;
- else
- labelFD.Text = "<None>";
- DateTime timestamp = File.GetCreationTime(theNode.moduleInfo.FileVersionInfo.FileName);
- labelFT.Text = timestamp.ToString();
- FileInfo fileInfo = new FileInfo(theNode.moduleInfo.FileVersionInfo.FileName);
- labelFS.Text = fileInfo.Length.ToString();
- }