Ich habe eine Anwendung, die ich im Hintergrund ausführen möchte. Ich möchte den ausführbaren Namen erhalten, für ein Beispiel IExplorer.exe. Ich habe mit folgendem Code herumgespielt:C# Informationen über das aktuelle aktive Fenster
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
private static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
public static void Main()
{
int chars = 256;
StringBuilder buff = new StringBuilder(chars);
while (true)
{
// Obtain the handle of the active window.
IntPtr handle = GetForegroundWindow();
// Update the controls.
if (GetWindowText(handle, buff, chars) > 0)
{
Console.WriteLine(buff.ToString());
Console.WriteLine(handle.ToString());
}
Thread.Sleep(1000);
}
}
Das bringt mir nur den Fenstertitel und die Handle ID. Ich möchte den ausführbaren Namen (und vielleicht mehr Informationen) erhalten.
Wie erreiche ich das?
Blick auf die letzten Antwort auf diese Frage auf Stackoverflow: http://stackoverflow.com/questions/7268302/get-the-titles-of-all-open-windows/31517889#31517889 – Godvicien