Controleren of Visual Studio.NET is gestart via code
Met de volgende methode kan worden gecontoleerd of Visual Studio.NET is gestart. Door kleine aanpassingen kunnen ook andere applicaties worden gecontroleerd.
public static bool IsVSRunning()
{
System.Diagnostics.Process[] processes;
bool IsRunning = false;
processes = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process process in processes)
{
try
{
if ((process != null) && (process.MainModule != null))
{
string fileName = process.MainModule.FileName;
fileName = System.IO.Path.GetFileName(fileName).ToLower();
if (System.String.Compare(fileName, "devenv.exe") == 0) {IsRunning = true; break;}
}
}
catch {}
}
return IsRunning;
}
publ