Laufende Programme



  • Hallo zusammen,

    ich müsste herausfinden, welche Programme gerade in der Taskleiste offen sind und jeweils den Pfad zur .exe bekommen. Könnte mir jemand sagen, wie man das hinbekommt?

    Bei MSDN habe ich nichts gefunden, aber es ist bestimmt irgendwo da...

    Vielen Dank!


  • Mod

    Fenster enummerieren, Prozesse ermitteln, EnumProcessModules verwenden bzw. GetModuleFileNameEx verwenden



  • Martin Richter schrieb:

    Fenster enummerieren, Prozesse ermitteln, EnumProcessModules verwenden bzw. GetModuleFileNameEx verwenden

    Danke, das ist schon mal ein Anfang!



  • Hallo,

    ich habe es jetzt so gelöst:

    Aufruf:

    EnumWindows((WNDENUMPROC)bcGetWindows, 0);
    

    Methode:

    //Ermittelt den Fensternamen.
    	if (GetWindowText(hwnd, cFenstername, 1023))
    	{
    		//Ausgabe des Fensternamens
    		if (IsWindowVisible(hwnd)) 
    		{
    			cout << "fenster: " << cFenstername << "\n";
    		}
    	}
    }
    

  • Mod

    GetWindowText ist die falsche Methode für Fenster in einem anderen Prozess, Siehe Doku zu GetWindowText
    http://msdn.microsoft.com/en-us/library/ms633520(VS.85).aspx

    If the target window is owned by the current process, GetWindowText causes a WM_GETTEXT message to be sent to the specified window or control. If the target window is owned by another process and has a caption, GetWindowText retrieves the window caption text. If the window does not have a caption, the return value is a null string. This behavior is by design. It allows applications to call GetWindowText without becoming unresponsive if the process that owns the target window is not responding. However, if the target window is not responding and it belongs to the calling application, GetWindowText will cause the calling application to become unresponsive.

    To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.



  • To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.

    Wie geht denn das?


  • Mod

    Google? Kennst Du schon? Such mal nach SendMessage und WM_GETTEXT.
    MSDN? Kennst Du auch? Den Link habe ich Dir gegeben.



  • Warum bleibt lpdwProcessId immer bei 0 ?

    LPDWORD lpdwProcessId = NULL;
    GetWindowThreadProcessId(hwnd, lpdwProcessId); 
    cout << "win proc id " << lpdwProcessId << "\n";
    

    Der Handle zum Fenster ist auf jeden Fall richtig, da

    GetWindowText(hwnd, cFenstername, 1023);
    

    funktioniert

    ?


  • Mod

    filth schrieb:

    Warum bleibt lpdwProcessId immer bei 0 ?

    LPDWORD lpdwProcessId = NULL;
    GetWindowThreadProcessId(hwnd, lpdwProcessId); 
    cout << "win proc id " << lpdwProcessId << "\n";
    

    Evtl. solltest Du mal C++ Grundlagen lernen. Du musst einen Zeiger übergeben und zwar einen gültigen.

    DWORD dwProcessId;
    GetWindowThreadProcessId(hwnd, &dwProcessId); 
    cout << "win proc id " << dwProcessId << "\n";
    


  • Jo bin ich dabei 🙄
    Kannst du auch normal antworten? Ansonsten lass es einfach sein, wenn es dich so reizt



  • filth schrieb:

    Jo bin ich dabei 🙄
    Kannst du auch normal antworten? Ansonsten lass es einfach sein, wenn es dich so reizt

    Jetzt machst die Wahl Deines Nicknames richtig Sinn. Jedenfalls für mich. 😮


Anmelden zum Antworten