Почему я получаю имя процесса с .vhost в конце концов, а не только имя? [дублировать]C#

Место общения программистов C#
Anonymous
Почему я получаю имя процесса с .vhost в конце концов, а не только имя? [дублировать]

Сообщение Anonymous »

Например, мое приложение названо Hardwaremonitoring
, поэтому имя процесса должно быть Hardwaremonitoring.exe < /p>
Но то, что я вижу, это Hardwaremonitoring.vshost
Как я могу сделать, это покажет только имена без vshost в конце?void PopulateApplications()
{
int rcount = dataGridView1.Rows.Count;
int rcurIndex = 0;
foreach (Process p in Process.GetProcesses())
{

try
{
if (File.Exists(p.MainModule.FileName))
{
if (p.MainModule.FileName.Contains("HardwareMonitoring"))
{
MessageBox.Show("hi");
}
var icon = Icon.ExtractAssociatedIcon(p.MainModule.FileName);
Image ima = icon.ToBitmap();
ima = resizeImage(ima, new Size(25, 25));
ima = (Image)(new Bitmap(ima, new Size(25, 25)));

String status = p.Responding ? "Running" : "Not Responding";

if (rcurIndex < rcount - 1)
{
dataGridView1.Rows[rcurIndex].Cells[0].Value = ima;
dataGridView1.Rows[rcurIndex].Cells[1].Value = p.ProcessName;
dataGridView1.Rows[rcurIndex].Cells[2].Value = status;
}
else
{
dataGridView1.Rows.Add(ima, p.ProcessName, status);
}
rcurIndex++;

}
}
catch ( Exception e)
{
//string t = "error";
}
}

if (rcurIndex < rcount - 1)
{
for (int i = rcurIndex; i < rcount - 1; i++)
{
dataGridView1.Rows.RemoveAt(rcurIndex);
}
}

int f = dataGridView1.Rows.GetRowsHeight(System.Windows.Forms.DataGridViewElementStates.None);
firsttime += 1;
if (firsttime == 1)
{
NumberOfRows = dataGridView1.Rows.Count;
}
if (NumberOfRows != dataGridView1.Rows.Count)
{
int diff = dataGridView1.Rows.Count - NumberOfRows;

NumberOfRows = dataGridView1.Rows.Count;
}
}
< /code>
Это добавляет процессы в ячейки строк, но он добавляет vshost, а не обычное имя файла Exe.
вместо этого добавление hardwaremonitoring.vshost. Он должен добавить только жесткое демориторинг < /p>
Как это исправить?>

Подробнее здесь: https://stackoverflow.com/questions/240 ... nly-the-na

Вернуться в «C#»