<?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[hWnd eines selbst gestarteten Prozesses bekommen]]></title><description><![CDATA[<p>Hallo,<br />
ich möchte eine exe-Datei starten, die ein Fenster erstellt.<br />
Mit welchen Funktionen muss ich die Datei starten, um das hWnd zu bekommen?<br />
MfG,<br />
Max</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/239245/hwnd-eines-selbst-gestarteten-prozesses-bekommen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Apr 2026 14:31:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/239245.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Apr 2009 11:18:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to hWnd eines selbst gestarteten Prozesses bekommen on Tue, 21 Apr 2009 11:18:16 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich möchte eine exe-Datei starten, die ein Fenster erstellt.<br />
Mit welchen Funktionen muss ich die Datei starten, um das hWnd zu bekommen?<br />
MfG,<br />
Max</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1699076</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1699076</guid><dc:creator><![CDATA[ripmav]]></dc:creator><pubDate>Tue, 21 Apr 2009 11:18:16 GMT</pubDate></item><item><title><![CDATA[Reply to hWnd eines selbst gestarteten Prozesses bekommen on Tue, 21 Apr 2009 12:21:46 GMT]]></title><description><![CDATA[<p>Etwas missverständlich aus gedrückt. Startest du die *.exe per Doppelclick oder per eintippen oder ist es so gemeint, daß du ein eigense Programm gecodet hast, das dir einen andere *.exe startet?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1699115</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1699115</guid><dc:creator><![CDATA[hÄÄÄÄÄÄ]]></dc:creator><pubDate>Tue, 21 Apr 2009 12:21:46 GMT</pubDate></item><item><title><![CDATA[Reply to hWnd eines selbst gestarteten Prozesses bekommen on Tue, 21 Apr 2009 13:43:29 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;windows.h&gt;

BOOL __stdcall FindThreadWindowCb(HWND hwnd, HWND *pHwnd)
{
	DWORD style = GetWindowLong(hwnd, GWL_STYLE);
	if ((style &amp; WS_OVERLAPPEDWINDOW) == WS_OVERLAPPEDWINDOW)
	{
		*pHwnd = hwnd;
	}
	return !*pHwnd;
}

int APIENTRY _tWinMain(HINSTANCE,HINSTANCE,LPTSTR,int)
{
	PROCESS_INFORMATION pi;
	STARTUPINFO si = {0};
	si.cb = sizeof(si);
	TCHAR cmd[] = TEXT(&quot;notepad.exe&quot;); // für UNICODE bug

	if (CreateProcess(0,cmd,0,0,0,0,0,0,&amp;si,&amp;pi))
	{
		DWORD dwStartTime = GetTickCount();
		WaitForInputIdle(pi.hProcess, 2000);

		HWND hwnd = 0;
		while (!hwnd)
		{
			DWORD dwTime = GetTickCount() - dwStartTime;
			if (dwTime &gt; 10000) break; // 10s timeout

			EnumThreadWindows(pi.dwThreadId, (WNDENUMPROC)FindThreadWindowCb, (LPARAM)&amp;hwnd);
			if (!hwnd) Sleep(100);
		}
		if (hwnd)
		{
			SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)TEXT(&quot;************&quot;));
			HWND hwndEdit = GetWindow(hwnd, GW_CHILD);
			SendMessage(hwndEdit, WM_SETTEXT, 0, (LPARAM)TEXT(&quot;hello world&quot;));
			SendMessage(hwndEdit, EM_SETMODIFY, 1, 0);
			PostMessage(hwnd, WM_CLOSE, 0, 0);
		}
		CloseHandle(pi.hProcess);
		CloseHandle(pi.hThread);
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1699161</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1699161</guid><dc:creator><![CDATA[sapero]]></dc:creator><pubDate>Tue, 21 Apr 2009 13:43:29 GMT</pubDate></item><item><title><![CDATA[Reply to hWnd eines selbst gestarteten Prozesses bekommen on Fri, 24 Apr 2009 11:20:09 GMT]]></title><description><![CDATA[<p>Genau das was sapero gepostet hat, habe ich gemeint!<br />
Es funktioniert auch super, allerdings nicht bei Konsolenanwendungen.<br />
Bei Konsolenanwendungen wird nicht einmal FindThreadWindowCb aufgerufen..<br />
Wie kann ich trotzdem das Fensterhandle bekommen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1700670</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1700670</guid><dc:creator><![CDATA[ripmav]]></dc:creator><pubDate>Fri, 24 Apr 2009 11:20:09 GMT</pubDate></item><item><title><![CDATA[Reply to hWnd eines selbst gestarteten Prozesses bekommen on Fri, 24 Apr 2009 14:49:55 GMT]]></title><description><![CDATA[<p>Naja, konsole Fenster gehört zu csrss.exe.</p>
<pre><code class="language-cpp">if (!AttachConsole(pi.dwProcessId) &amp;&amp; (GetLastError() == ERROR_ACCESS_DENIED))
{
   // If the calling process is already attached to a console[...]
   FreeConsole();
   AttachConsole(pi.dwProcessId);
}
hwnd = GetConsoleWindow();
FreeConsole();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1700773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1700773</guid><dc:creator><![CDATA[sapero]]></dc:creator><pubDate>Fri, 24 Apr 2009 14:49:55 GMT</pubDate></item><item><title><![CDATA[Reply to hWnd eines selbst gestarteten Prozesses bekommen on Sat, 25 Apr 2009 13:37:12 GMT]]></title><description><![CDATA[<p>Danke! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1701125</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1701125</guid><dc:creator><![CDATA[ripmav]]></dc:creator><pubDate>Sat, 25 Apr 2009 13:37:12 GMT</pubDate></item></channel></rss>