<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Prozessname des Aktiven Fensters herausbekommen]]></title><description><![CDATA[<p>Hi,</p>
<p>2 Tage versuche ich jetzt schon verzweifelt den Prozessnamen eines Aktiven Fensters herauszubekommen. Die Windowcaption des Fensters herauszubekommen war ja kein Problem,aber den Rest...</p>
<p>Dann hab ich mit dem Fensterhandle (HWND) welches ich für die Windowcaption gemacht habe per GetWindowThreadProcessId() die PID rausbekommen.<br />
Ich kann auch schon alle laufenden Prozesse und ihre ProzessIDs ausgeben.<br />
Und da ist mir aufgefallen das bei GetWindowThreadProcessId() eine andere PID raus kommt wie wenn ich alle Prozesse und ihre PIDs aufliste mit CreateToolhelp32Snapshot() ( siehe <a href="http://CreateToolhelp32Snapshot()" rel="nofollow">CreateToolhelp32Snapshot()</a> ) Wenn die PID richtig wäre, könnte ich ja einfach mit dem Ergebnis von CreateToolhelp32Snapshot() die PIDs vergleichen und dann den zugehörigen Prozessnamen ausgeben. Doch leider sind sie nicht gleich, was dann wohl bedeutet, dass eine Funktion die falsche PID herausgibt...</p>
<p>Ein weiteres Problem war (ich habe viele Funktionen ausprobiert) das ich das PSDK nicht verwenden will und viele Funktionen funktionieren nur damit (z.B. alle die PSAPI.H benötigen)!</p>
<p>Was gibt es denn noch für Möglichkeiten den Prozessnamen eines aktiven Fensters herauszubekommen?? Ich bin mir sicher, ich mach das mal wieder viel zu kompliziert!</p>
<p>Ich hab auch schon GetProcessById() ausprobiert doch leider kennt das Visual C++ nicht bei mir. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Ich benutze Visual C++ 6.</p>
<p>Versuch mit Fensterhandle auf die PID zu kommen:</p>
<pre><code class="language-cpp">HWND hFocus = GetForegroundWindow();     // Retrieve The Active Windows's Focus
 if (hFocus != PreviousFocus)    // The Active Windows Has Change
 {
    PreviousFocus = hFocus;      // Save The Old Active Windos Focus
    int WinLeng = GetWindowTextLength(hFocus);    // Get The Active Windows's Caption's Length
    char *WindowCaption = (char*) malloc(sizeof(char) * (WinLeng + 2));    // Allocate Memory For The Caption
    GetWindowText(hFocus,WindowCaption,(WinLeng + 1));      // Retrieve The Active Windows's Caption

	DWORD idAttach = GetWindowThreadProcessId(hFocus, NULL);		// Process ID durch Fensterhandle herausbekommen

	cout &lt;&lt; &quot;Process ID: &quot; &lt;&lt; idAttach &lt;&lt; endl;
</code></pre>
<p>Ich hoffe ich konnte mich einigermaßen klar ausdrücken <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/147526/prozessname-des-aktiven-fensters-herausbekommen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Jul 2026 21:25:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/147526.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 17 May 2006 17:51:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Prozessname des Aktiven Fensters herausbekommen on Wed, 17 May 2006 17:51:18 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>2 Tage versuche ich jetzt schon verzweifelt den Prozessnamen eines Aktiven Fensters herauszubekommen. Die Windowcaption des Fensters herauszubekommen war ja kein Problem,aber den Rest...</p>
<p>Dann hab ich mit dem Fensterhandle (HWND) welches ich für die Windowcaption gemacht habe per GetWindowThreadProcessId() die PID rausbekommen.<br />
Ich kann auch schon alle laufenden Prozesse und ihre ProzessIDs ausgeben.<br />
Und da ist mir aufgefallen das bei GetWindowThreadProcessId() eine andere PID raus kommt wie wenn ich alle Prozesse und ihre PIDs aufliste mit CreateToolhelp32Snapshot() ( siehe <a href="http://CreateToolhelp32Snapshot()" rel="nofollow">CreateToolhelp32Snapshot()</a> ) Wenn die PID richtig wäre, könnte ich ja einfach mit dem Ergebnis von CreateToolhelp32Snapshot() die PIDs vergleichen und dann den zugehörigen Prozessnamen ausgeben. Doch leider sind sie nicht gleich, was dann wohl bedeutet, dass eine Funktion die falsche PID herausgibt...</p>
<p>Ein weiteres Problem war (ich habe viele Funktionen ausprobiert) das ich das PSDK nicht verwenden will und viele Funktionen funktionieren nur damit (z.B. alle die PSAPI.H benötigen)!</p>
<p>Was gibt es denn noch für Möglichkeiten den Prozessnamen eines aktiven Fensters herauszubekommen?? Ich bin mir sicher, ich mach das mal wieder viel zu kompliziert!</p>
<p>Ich hab auch schon GetProcessById() ausprobiert doch leider kennt das Visual C++ nicht bei mir. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Ich benutze Visual C++ 6.</p>
<p>Versuch mit Fensterhandle auf die PID zu kommen:</p>
<pre><code class="language-cpp">HWND hFocus = GetForegroundWindow();     // Retrieve The Active Windows's Focus
 if (hFocus != PreviousFocus)    // The Active Windows Has Change
 {
    PreviousFocus = hFocus;      // Save The Old Active Windos Focus
    int WinLeng = GetWindowTextLength(hFocus);    // Get The Active Windows's Caption's Length
    char *WindowCaption = (char*) malloc(sizeof(char) * (WinLeng + 2));    // Allocate Memory For The Caption
    GetWindowText(hFocus,WindowCaption,(WinLeng + 1));      // Retrieve The Active Windows's Caption

	DWORD idAttach = GetWindowThreadProcessId(hFocus, NULL);		// Process ID durch Fensterhandle herausbekommen

	cout &lt;&lt; &quot;Process ID: &quot; &lt;&lt; idAttach &lt;&lt; endl;
</code></pre>
<p>Ich hoffe ich konnte mich einigermaßen klar ausdrücken <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059753</guid><dc:creator><![CDATA[MaN0258]]></dc:creator><pubDate>Wed, 17 May 2006 17:51:18 GMT</pubDate></item><item><title><![CDATA[Reply to Prozessname des Aktiven Fensters herausbekommen on Wed, 17 May 2006 18:23:56 GMT]]></title><description><![CDATA[<p>Wenn Du schon die Prozess-ID hast, brauchst Du doch bloss noch &quot;OpenProcess&quot; und &quot;GetModuleFileNameEx&quot; aufzurufen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059772</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059772</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Wed, 17 May 2006 18:23:56 GMT</pubDate></item><item><title><![CDATA[Reply to Prozessname des Aktiven Fensters herausbekommen on Wed, 17 May 2006 18:31:55 GMT]]></title><description><![CDATA[<p>braucht man dafür keine psapi.h? weil die gibt es bei mir nicht. Und ich würde halt gerne auf das PSDK verzichten!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059778</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059778</guid><dc:creator><![CDATA[MaN0258]]></dc:creator><pubDate>Wed, 17 May 2006 18:31:55 GMT</pubDate></item><item><title><![CDATA[Reply to Prozessname des Aktiven Fensters herausbekommen on Wed, 17 May 2006 18:35:23 GMT]]></title><description><![CDATA[<p>MaN0258 schrieb:</p>
<blockquote>
<p>braucht man dafür keine psapi.h? weil die gibt es bei mir nicht.</p>
</blockquote>
<p>Für OpenProcess nicht... für GetModuleFileNameEx bzw. GetModuleBaseName schon.<br />
Was hast Du denn für eine IDE, da Du diese nicht hast?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059782</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059782</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Wed, 17 May 2006 18:35:23 GMT</pubDate></item><item><title><![CDATA[Reply to Prozessname des Aktiven Fensters herausbekommen on Wed, 17 May 2006 18:42:59 GMT]]></title><description><![CDATA[<p>Visual c++ 6</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059789</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059789</guid><dc:creator><![CDATA[MaN0258]]></dc:creator><pubDate>Wed, 17 May 2006 18:42:59 GMT</pubDate></item><item><title><![CDATA[Reply to Prozessname des Aktiven Fensters herausbekommen on Wed, 17 May 2006 18:44:39 GMT]]></title><description><![CDATA[<p>Nimm doch das letzte für VC6 gültige PSDK...<br />
<a href="http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm" rel="nofollow">http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm</a><br />
Du kannst theoretisch auch LoadLibrary/GetProcAddress verwenden; dann brauchst Du kein aktuelleres PSDK...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059791</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059791</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Wed, 17 May 2006 18:44:39 GMT</pubDate></item><item><title><![CDATA[Reply to Prozessname des Aktiven Fensters herausbekommen on Wed, 17 May 2006 18:48:51 GMT]]></title><description><![CDATA[<p>brauchen dann nicht alle die das programm verwenden wollen auch das PSDK??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059794</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059794</guid><dc:creator><![CDATA[MaN0258]]></dc:creator><pubDate>Wed, 17 May 2006 18:48:51 GMT</pubDate></item><item><title><![CDATA[Reply to Prozessname des Aktiven Fensters herausbekommen on Wed, 17 May 2006 18:59:14 GMT]]></title><description><![CDATA[<p>Nein. Alle brauchen nur die &quot;Psapi.dll&quot;, für NT findest Du diese hier:<br />
<a href="http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=3d1fbaed-d122-45cf-9d46-1cae384097ac&amp;displaylang=en" rel="nofollow">http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=3d1fbaed-d122-45cf-9d46-1cae384097ac&amp;displaylang=en</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059799</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059799</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Wed, 17 May 2006 18:59:14 GMT</pubDate></item><item><title><![CDATA[Reply to Prozessname des Aktiven Fensters herausbekommen on Wed, 17 May 2006 19:05:44 GMT]]></title><description><![CDATA[<p>na wenn das so ist...</p>
<p>ich hab gesehen das die bei mir schon im windows ordner war! Kommt die dann von VC6 oder ist die standart in Win XP?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059804</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059804</guid><dc:creator><![CDATA[MaN0258]]></dc:creator><pubDate>Wed, 17 May 2006 19:05:44 GMT</pubDate></item><item><title><![CDATA[Reply to Prozessname des Aktiven Fensters herausbekommen on Wed, 17 May 2006 19:47:27 GMT]]></title><description><![CDATA[<p>Ab W2k ist sie immer dabei...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059831</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059831</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Wed, 17 May 2006 19:47:27 GMT</pubDate></item><item><title><![CDATA[Reply to Prozessname des Aktiven Fensters herausbekommen on Wed, 17 May 2006 20:47:12 GMT]]></title><description><![CDATA[<p>ok, dann mal vielen dank für die hilfe.<br />
und morgen werd ich das mal ausprobieren: <a href="http://www.codeguru.com/cpp/w-p/system/processesmodules/article.php/c2865/" rel="nofollow">http://www.codeguru.com/cpp/w-p/system/processesmodules/article.php/c2865/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059860</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059860</guid><dc:creator><![CDATA[MaN0258]]></dc:creator><pubDate>Wed, 17 May 2006 20:47:12 GMT</pubDate></item></channel></rss>