<?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[dynamische DLL wiedergabe]]></title><description><![CDATA[<p>Hallo erstmal.</p>
<p>Ich wollte eigentlich eine kleine DLL schreiben oder ein kleines Programm (wohl eher ne DLL ^^ ) die mir von der aktuellen *.exe diverse Informationen ausgibt. Im folgenden ist ein Textauszug, wie er mir die Informationen vom Pfad, der Größe, der Version und dem Zeitpunkt wieder gibt.</p>
<p>Hier hätte ich mal meine 1. kleinere Frage. Ist das die aktuelle Zeit im System oder wwirklich die Zeit als die *.exe erstellt wurde. Weil bis jetzt macht er mir ja immer beim Kompilieren eine neue Infobox.exe.</p>
<p>Recht schönen Dank wer sich damit kurz befassen könnte.</p>
<p><strong>Das eigentliche Problem.</strong></p>
<p>Ihr kennt ja vielleicht den Prozess-Explorer. Dieser zeigt ja an welche DLL's die Anwendung gerade alles benutzt. Das wollte ich auch gern haben und diese wieder geben. Allerdings bin ich im Netz nur auf LoadLibrary gekommen und das ist nicht dynamisch, da ich das ja bei verschiedenen *.exe Dateien nutzen will.</p>
<p>Ich wäre wirklich sehr dankbar, wenn mir jemand da einen Ansatz nennen könnte oder gar ein paar Code Fragmente übermitteln könnte. Ich danke jetzt schon mal für die Mühe sich das überhaupt durch gelesen zu haben.<br />
Über Antworten wäre ich natürlich dankbarer <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<pre><code class="language-cpp">#include &lt;afx.h&gt;
#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include &lt;conio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string&gt;

#define BUFSIZE 8192

int main(int argc, char* argv[])
{

//////////////////////////////////////////////////////////////////////////////////
//	LPTSTR lpszSystemInfo;		// Pointer auf den System Informations String   //
//	DWORD cchBuff = BUFSIZE;	// Größe für den Namen                          //
//	TCHAR tchBuffer[BUFSIZE];	// Buffer für den String                        //
//	DWORD fehler;                                                               //
//	CString	csFileVersion;                                                      //
//	CString csFileTime;                                                         //
//	CString csFileSize;                                                         //
//	lpszSystemInfo = tchBuffer;                                                 //
//                                                                              //
//                                                                              //
// erstellt Nutzernamen und Computernamen                                       //
//                                                                              //
//	if( GetComputerName(lpszSystemInfo, &amp;cchBuff) )                             //
//	printf(&quot;Computer Name: %s\n &quot;, lpszSystemInfo);                             //
//                                                                              //
//	cchBuff = BUFSIZE;                                                          //
//                                                                              //
//		if( GetUserName(lpszSystemInfo, &amp;cchBuff) )                             //
//		printf(&quot;User name: %s\n &quot;, lpszSystemInfo);                             //
//		else                                                                    //
//		{                                                                       //
//			fehler = GetLastError();                                            //
//			printf(&quot;Fehler : %d\n&quot;,fehler);                                     //
//		}                                                                       //
//////////////////////////////////////////////////////////////////////////////////

			CString	csFileVersion;                                                      
			CString csFileTime;                                                         
			CString csFileSize; 

			//////////////////////////////////////////////////////////////////////
			//------------------------------------------------------------------//
			// Get file name                                                    //
			//------------------------------------------------------------------//
			//////////////////////////////////////////////////////////////////////

			char appPath[MAX_PATH];    
			::GetModuleFileName(NULL, appPath, MAX_PATH); // der Programmpfad mit programm.exe namen    
			std::string Path(appPath);    
			Path = Path.substr(0, Path.rfind('\\')); // ohne programm.exe namen

			//////////////////////////////////////////////////////////////////////
			//------------------------------------------------------------------//
			// Get file version                                                 //
			//------------------------------------------------------------------//
			//////////////////////////////////////////////////////////////////////
			DWORD	dwLen = 0;
			LPVOID	plVerBuffer = NULL;
			UINT	uiVerBufferLen = 0;
			BOOL	bRetCode = FALSE;
			DWORD	dwDummy = 0;
			PBYTE	pData = NULL;
			VS_FIXEDFILEINFO uFileInfo;
			BOOL	bRet = FALSE;

			dwLen = GetFileVersionInfoSize(appPath, &amp;dwDummy);
			if ( dwLen &gt; 0 )
			{
				pData = new BYTE[dwLen];
				if ( pData )
				{
					bRetCode = GetFileVersionInfo(appPath, 0, dwLen, pData);
					bRetCode = VerQueryValue(pData, &quot;\\&quot;, &amp;plVerBuffer, &amp;uiVerBufferLen);

					RtlMoveMemory(&amp;uFileInfo, plVerBuffer, uiVerBufferLen);

					csFileVersion.Format(&quot;%d.%d.%d.%d&quot;,
						((uFileInfo.dwProductVersionMS &gt;&gt; 16) &amp; 0xFF),
						(uFileInfo.dwProductVersionMS &amp; 0xFF),
						((uFileInfo.dwProductVersionLS &gt;&gt; 16) &amp; 0xFF),
						(uFileInfo.dwProductVersionLS &amp; 0xFF) );

					delete [] pData;
					bRet = true;
				}
			}

			//////////////////////////////////////////////////////////////////////
			//------------------------------------------------------------------//
			// Get file time                                                    //
			//------------------------------------------------------------------//
			//////////////////////////////////////////////////////////////////////

				HANDLE hFile = CreateFile(appPath, GENERIC_READ, FILE_SHARE_READ, NULL,
				OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
			if ( (hFile != 0) &amp;&amp; (hFile != INVALID_HANDLE_VALUE) )
			{
				SYSTEMTIME tSystemTime;
				FILETIME tLastWriteTime;

				if ( GetFileTime(hFile, NULL, NULL, &amp;tLastWriteTime) )
				{
					if ( FileTimeToSystemTime(&amp;tLastWriteTime, &amp;tSystemTime) )
					{
						tSystemTime.wHour++;
						if ( _daylight == 1 )
						{
							tSystemTime.wHour++;
						}
						csFileTime.Format(&quot;%02d.%02d.%04d %02d:%02d:%02d&quot;,
							tSystemTime.wDay,
							tSystemTime.wMonth,
							tSystemTime.wYear,
							tSystemTime.wHour,
							tSystemTime.wMinute,
							tSystemTime.wSecond);
					}
				}
			}

			//////////////////////////////////////////////////////////////////////
			//------------------------------------------------------------------//
			// Get file size                                                    //
			//------------------------------------------------------------------//
			//////////////////////////////////////////////////////////////////////

			DWORD dwSize = 0;
			if ( (hFile != 0) &amp;&amp; (hFile != INVALID_HANDLE_VALUE) )
			{
				dwSize = GetFileSize(hFile, NULL);
				if ( dwSize != INVALID_FILE_SIZE )
				{
					csFileSize.Format(&quot;%ld&quot;, dwSize);

					int iConvTemp;
					iConvTemp = csFileSize.GetLength();
					if (iConvTemp &gt; 3)
						csFileSize = csFileSize.Left(iConvTemp-3) + &quot;.&quot; + csFileSize.Right(3);
					iConvTemp = csFileSize.GetLength();
					if (iConvTemp &gt; 7)
						csFileSize = csFileSize.Left(iConvTemp-7) + &quot;.&quot; + csFileSize.Right(7);
					iConvTemp = csFileSize.GetLength();
					if (iConvTemp &gt; 11)
						csFileSize = csFileSize.Left(iConvTemp-11) + &quot;.&quot; + csFileSize.Right(11);
				}
			}

			//////////////////////////////////////////////////////////////////////
			//------------------------------------------------------------------//
			// Close file handle                                                //
			//------------------------------------------------------------------//
			//////////////////////////////////////////////////////////////////////

			if ( (hFile != 0) &amp;&amp; (hFile != INVALID_HANDLE_VALUE) )
			{
				CloseHandle(hFile);
			}

//			WriteInfo((CString) &quot;      Modul:		&quot; + szFileName);
//			WriteInfo((CString) &quot;      Größe:		&quot; + csFileSize + &quot; Bytes&quot;);
//			WriteInfo((CString) &quot;      Datum:		&quot; + csFileTime);
//			WriteInfo((CString) &quot;      Version:		&quot; + csFileVersion);

				printf(appPath); 
				printf(&quot;\n&quot;);
				printf(csFileSize + &quot; Bytes&quot;);
				printf(&quot;\n&quot;);
				printf(csFileTime);
				printf(&quot;\n&quot;);
				printf(csFileVersion);

				return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/202176/dynamische-dll-wiedergabe</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 18:21:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/202176.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 08 Jan 2008 15:35:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to dynamische DLL wiedergabe on Tue, 08 Jan 2008 15:35:02 GMT]]></title><description><![CDATA[<p>Hallo erstmal.</p>
<p>Ich wollte eigentlich eine kleine DLL schreiben oder ein kleines Programm (wohl eher ne DLL ^^ ) die mir von der aktuellen *.exe diverse Informationen ausgibt. Im folgenden ist ein Textauszug, wie er mir die Informationen vom Pfad, der Größe, der Version und dem Zeitpunkt wieder gibt.</p>
<p>Hier hätte ich mal meine 1. kleinere Frage. Ist das die aktuelle Zeit im System oder wwirklich die Zeit als die *.exe erstellt wurde. Weil bis jetzt macht er mir ja immer beim Kompilieren eine neue Infobox.exe.</p>
<p>Recht schönen Dank wer sich damit kurz befassen könnte.</p>
<p><strong>Das eigentliche Problem.</strong></p>
<p>Ihr kennt ja vielleicht den Prozess-Explorer. Dieser zeigt ja an welche DLL's die Anwendung gerade alles benutzt. Das wollte ich auch gern haben und diese wieder geben. Allerdings bin ich im Netz nur auf LoadLibrary gekommen und das ist nicht dynamisch, da ich das ja bei verschiedenen *.exe Dateien nutzen will.</p>
<p>Ich wäre wirklich sehr dankbar, wenn mir jemand da einen Ansatz nennen könnte oder gar ein paar Code Fragmente übermitteln könnte. Ich danke jetzt schon mal für die Mühe sich das überhaupt durch gelesen zu haben.<br />
Über Antworten wäre ich natürlich dankbarer <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<pre><code class="language-cpp">#include &lt;afx.h&gt;
#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include &lt;conio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string&gt;

#define BUFSIZE 8192

int main(int argc, char* argv[])
{

//////////////////////////////////////////////////////////////////////////////////
//	LPTSTR lpszSystemInfo;		// Pointer auf den System Informations String   //
//	DWORD cchBuff = BUFSIZE;	// Größe für den Namen                          //
//	TCHAR tchBuffer[BUFSIZE];	// Buffer für den String                        //
//	DWORD fehler;                                                               //
//	CString	csFileVersion;                                                      //
//	CString csFileTime;                                                         //
//	CString csFileSize;                                                         //
//	lpszSystemInfo = tchBuffer;                                                 //
//                                                                              //
//                                                                              //
// erstellt Nutzernamen und Computernamen                                       //
//                                                                              //
//	if( GetComputerName(lpszSystemInfo, &amp;cchBuff) )                             //
//	printf(&quot;Computer Name: %s\n &quot;, lpszSystemInfo);                             //
//                                                                              //
//	cchBuff = BUFSIZE;                                                          //
//                                                                              //
//		if( GetUserName(lpszSystemInfo, &amp;cchBuff) )                             //
//		printf(&quot;User name: %s\n &quot;, lpszSystemInfo);                             //
//		else                                                                    //
//		{                                                                       //
//			fehler = GetLastError();                                            //
//			printf(&quot;Fehler : %d\n&quot;,fehler);                                     //
//		}                                                                       //
//////////////////////////////////////////////////////////////////////////////////

			CString	csFileVersion;                                                      
			CString csFileTime;                                                         
			CString csFileSize; 

			//////////////////////////////////////////////////////////////////////
			//------------------------------------------------------------------//
			// Get file name                                                    //
			//------------------------------------------------------------------//
			//////////////////////////////////////////////////////////////////////

			char appPath[MAX_PATH];    
			::GetModuleFileName(NULL, appPath, MAX_PATH); // der Programmpfad mit programm.exe namen    
			std::string Path(appPath);    
			Path = Path.substr(0, Path.rfind('\\')); // ohne programm.exe namen

			//////////////////////////////////////////////////////////////////////
			//------------------------------------------------------------------//
			// Get file version                                                 //
			//------------------------------------------------------------------//
			//////////////////////////////////////////////////////////////////////
			DWORD	dwLen = 0;
			LPVOID	plVerBuffer = NULL;
			UINT	uiVerBufferLen = 0;
			BOOL	bRetCode = FALSE;
			DWORD	dwDummy = 0;
			PBYTE	pData = NULL;
			VS_FIXEDFILEINFO uFileInfo;
			BOOL	bRet = FALSE;

			dwLen = GetFileVersionInfoSize(appPath, &amp;dwDummy);
			if ( dwLen &gt; 0 )
			{
				pData = new BYTE[dwLen];
				if ( pData )
				{
					bRetCode = GetFileVersionInfo(appPath, 0, dwLen, pData);
					bRetCode = VerQueryValue(pData, &quot;\\&quot;, &amp;plVerBuffer, &amp;uiVerBufferLen);

					RtlMoveMemory(&amp;uFileInfo, plVerBuffer, uiVerBufferLen);

					csFileVersion.Format(&quot;%d.%d.%d.%d&quot;,
						((uFileInfo.dwProductVersionMS &gt;&gt; 16) &amp; 0xFF),
						(uFileInfo.dwProductVersionMS &amp; 0xFF),
						((uFileInfo.dwProductVersionLS &gt;&gt; 16) &amp; 0xFF),
						(uFileInfo.dwProductVersionLS &amp; 0xFF) );

					delete [] pData;
					bRet = true;
				}
			}

			//////////////////////////////////////////////////////////////////////
			//------------------------------------------------------------------//
			// Get file time                                                    //
			//------------------------------------------------------------------//
			//////////////////////////////////////////////////////////////////////

				HANDLE hFile = CreateFile(appPath, GENERIC_READ, FILE_SHARE_READ, NULL,
				OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
			if ( (hFile != 0) &amp;&amp; (hFile != INVALID_HANDLE_VALUE) )
			{
				SYSTEMTIME tSystemTime;
				FILETIME tLastWriteTime;

				if ( GetFileTime(hFile, NULL, NULL, &amp;tLastWriteTime) )
				{
					if ( FileTimeToSystemTime(&amp;tLastWriteTime, &amp;tSystemTime) )
					{
						tSystemTime.wHour++;
						if ( _daylight == 1 )
						{
							tSystemTime.wHour++;
						}
						csFileTime.Format(&quot;%02d.%02d.%04d %02d:%02d:%02d&quot;,
							tSystemTime.wDay,
							tSystemTime.wMonth,
							tSystemTime.wYear,
							tSystemTime.wHour,
							tSystemTime.wMinute,
							tSystemTime.wSecond);
					}
				}
			}

			//////////////////////////////////////////////////////////////////////
			//------------------------------------------------------------------//
			// Get file size                                                    //
			//------------------------------------------------------------------//
			//////////////////////////////////////////////////////////////////////

			DWORD dwSize = 0;
			if ( (hFile != 0) &amp;&amp; (hFile != INVALID_HANDLE_VALUE) )
			{
				dwSize = GetFileSize(hFile, NULL);
				if ( dwSize != INVALID_FILE_SIZE )
				{
					csFileSize.Format(&quot;%ld&quot;, dwSize);

					int iConvTemp;
					iConvTemp = csFileSize.GetLength();
					if (iConvTemp &gt; 3)
						csFileSize = csFileSize.Left(iConvTemp-3) + &quot;.&quot; + csFileSize.Right(3);
					iConvTemp = csFileSize.GetLength();
					if (iConvTemp &gt; 7)
						csFileSize = csFileSize.Left(iConvTemp-7) + &quot;.&quot; + csFileSize.Right(7);
					iConvTemp = csFileSize.GetLength();
					if (iConvTemp &gt; 11)
						csFileSize = csFileSize.Left(iConvTemp-11) + &quot;.&quot; + csFileSize.Right(11);
				}
			}

			//////////////////////////////////////////////////////////////////////
			//------------------------------------------------------------------//
			// Close file handle                                                //
			//------------------------------------------------------------------//
			//////////////////////////////////////////////////////////////////////

			if ( (hFile != 0) &amp;&amp; (hFile != INVALID_HANDLE_VALUE) )
			{
				CloseHandle(hFile);
			}

//			WriteInfo((CString) &quot;      Modul:		&quot; + szFileName);
//			WriteInfo((CString) &quot;      Größe:		&quot; + csFileSize + &quot; Bytes&quot;);
//			WriteInfo((CString) &quot;      Datum:		&quot; + csFileTime);
//			WriteInfo((CString) &quot;      Version:		&quot; + csFileVersion);

				printf(appPath); 
				printf(&quot;\n&quot;);
				printf(csFileSize + &quot; Bytes&quot;);
				printf(&quot;\n&quot;);
				printf(csFileTime);
				printf(&quot;\n&quot;);
				printf(csFileVersion);

				return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1433090</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1433090</guid><dc:creator><![CDATA[+Zoidberg+]]></dc:creator><pubDate>Tue, 08 Jan 2008 15:35:02 GMT</pubDate></item><item><title><![CDATA[Reply to dynamische DLL wiedergabe on Tue, 08 Jan 2008 17:29:43 GMT]]></title><description><![CDATA[<p>CreateToolhelp32Snapshot ( <a href="http://msdn2.microsoft.com/en-us/library/ms682489.aspx" rel="nofollow">http://msdn2.microsoft.com/en-us/library/ms682489.aspx</a> ) in Verbindung mit Module32First/Module32Next duerfte wohl das sein was du suchst: <a href="http://msdn2.microsoft.com/en-us/library/ms684218(VS.85).aspx" rel="nofollow">http://msdn2.microsoft.com/en-us/library/ms684218(VS.85).aspx</a> / <a href="http://msdn2.microsoft.com/en-us/library/ms684221(VS.85).aspx" rel="nofollow">http://msdn2.microsoft.com/en-us/library/ms684221(VS.85).aspx</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1433183</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1433183</guid><dc:creator><![CDATA[dmesg]]></dc:creator><pubDate>Tue, 08 Jan 2008 17:29:43 GMT</pubDate></item><item><title><![CDATA[Reply to dynamische DLL wiedergabe on Wed, 09 Jan 2008 09:35:25 GMT]]></title><description><![CDATA[<p>Vielen lieben Dank. Zwar bin ich noch am hin und her testen, wie das alles funktioniert, aber das eröffnet mir auch in der MSDN Library und bei google mehr Such-Möglichkeiten als nach &quot;dynamic dll loading&quot; und was ich alles gesucht habe.</p>
<p>Du hast mir den Tag gerettet <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> oder zerstört. Je nachdem wie ich mich anstelle.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1433477</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1433477</guid><dc:creator><![CDATA[+Zoidberg+]]></dc:creator><pubDate>Wed, 09 Jan 2008 09:35:25 GMT</pubDate></item><item><title><![CDATA[Reply to dynamische DLL wiedergabe on Wed, 09 Jan 2008 10:21:26 GMT]]></title><description><![CDATA[<p>Kleines Problem hat sich doch ergeben und ich weiß nicht so recht warum.</p>
<p>Er gibt mir jetzt zwar die exe aus und die dazugehörigen Module mit ProcessID, Pfad und größe wieder, <strong>aber</strong> er macht das von allen *.exe Dateien die gerade aktiv im System sind.</p>
<p>Ich vermute, dass der Parameter in diesem Code- Fragment geändert werden muss.</p>
<pre><code class="language-cpp">BOOL GetProcessList( )
{
  HANDLE hProcessSnap;
  HANDLE hProcess;
  PROCESSENTRY32 pe32;
  DWORD dwPriorityClass;

  hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
  if( hProcessSnap == INVALID_HANDLE_VALUE )
  {
    printError( TEXT(&quot;CreateToolhelp32Snapshot (of processes)&quot;) );
    return( FALSE );
  }

  pe32.dwSize = sizeof( PROCESSENTRY32 );
</code></pre>
<p>Allerdings ist bei CreateToolhelp32Snapshot die 0. Soweit ich mich entsinne, ist die 0 für den aktuellen Prozess.</p>
<p>Schon mal danke für eventuelle Einfälle. Ansonsten wird das eine üppige Prozessauflistung und das letzte ist dann, die aktuelle Datei <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/1433511</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1433511</guid><dc:creator><![CDATA[+Zoidberg+]]></dc:creator><pubDate>Wed, 09 Jan 2008 10:21:26 GMT</pubDate></item><item><title><![CDATA[Reply to dynamische DLL wiedergabe on Wed, 09 Jan 2008 15:31:11 GMT]]></title><description><![CDATA[<p>Ok. Da oben lässt sich wahrscheinlich nicht viel ändern.</p>
<p>Hier übrigens der Code, falls jemand aus all seinen aktiven *.exe Dateien die zugehörigen Module auslesen will.</p>
<pre><code class="language-cpp">BOOL GetProcessList( )
{
  HANDLE hProcessSnap;
  HANDLE hProcess;
  PROCESSENTRY32 pe32;
  DWORD dwPriorityClass;

  // erstellt &quot;Snapshot&quot; von den Prozessen (*.exe)
  hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
  if( hProcessSnap == INVALID_HANDLE_VALUE )
  {
    printError( TEXT(&quot;CreateToolhelp32Snapshot (of processes)&quot;) );
    return( FALSE );
  }

  // Größe bestimmen
  pe32.dwSize = sizeof( PROCESSENTRY32 );

  // Informationen über den ersten Prozess ermitteln, beim scheitern verlassen
  if( !Process32First( hProcessSnap, &amp;pe32 ) )
  {
    printError( TEXT(&quot;Process32First&quot;) ); // Anzeige bei Fehler
    CloseHandle( hProcessSnap );          // Snapshot Objekt bereinigen
    return( FALSE );
  }

  //bei Erfolg Ausgabe
  do
  {
    printf( &quot;\n\n=====================================================&quot; );
    _tprintf( TEXT(&quot;\nPROCESS NAME:  %s&quot;), pe32.szExeFile );
    printf( &quot;\n-----------------------------------------------------&quot; );

    // Priority Class erhalten
    dwPriorityClass = 0;
    hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID );
    if( hProcess == NULL )
      printError( TEXT(&quot;OpenProcess&quot;) );
    else
    {
      dwPriorityClass = GetPriorityClass( hProcess );
      if( !dwPriorityClass )
        printError( TEXT(&quot;GetPriorityClass&quot;) );
      CloseHandle( hProcess );
    }

    printf( &quot;\n  Process ID        = 0x%08X&quot;, pe32.th32ProcessID );
    printf( &quot;\n  Thread count      = %d&quot;,   pe32.cntThreads );
    printf( &quot;\n  Parent process ID = 0x%08X&quot;, pe32.th32ParentProcessID );
    printf( &quot;\n  Priority base     = %d&quot;, pe32.pcPriClassBase );
    if( dwPriorityClass )
      printf( &quot;\n  Priority class    = %d&quot;, dwPriorityClass );

    // Auflistung der Module und Threads die mit dem Prozess zusammenhängen
    ListProcessModules( pe32.th32ProcessID );
    ListProcessThreads( pe32.th32ProcessID );

  } while( Process32Next( hProcessSnap, &amp;pe32 ) );

  CloseHandle( hProcessSnap );
  return( TRUE );
}

BOOL ListProcessModules( DWORD dwPID )
{
  HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
  MODULEENTRY32 me32;

  // &quot;Snapshot&quot; von den Modulen (Dll) erstellen
  hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwPID );
  if( hModuleSnap == INVALID_HANDLE_VALUE )
  {
    printError( TEXT(&quot;CreateToolhelp32Snapshot (of modules)&quot;) );
    return( FALSE );
  }

  // Größe bestimmen
  me32.dwSize = sizeof( MODULEENTRY32 );

  // Informationen über das 1. Modul 
  if( !Module32First( hModuleSnap, &amp;me32 ) )
  {
    printError( TEXT(&quot;Module32First&quot;) );  // Anzeige beim Fehler
    CloseHandle( hModuleSnap );           // Snapshot Objekt bereinigen
    return( FALSE );
  }

  // verschiedene Informationen der Module wieder geben
  do
  {
    _tprintf( TEXT(&quot;\n\n     MODULE NAME:     %s&quot;),   me32.szModule );
    _tprintf( TEXT(&quot;\n     Executable     = %s&quot;),     me32.szExePath );
    printf( &quot;\n     Process ID     = 0x%08X&quot;,         me32.th32ProcessID );
    printf( &quot;\n     Ref count (g)  = 0x%04X&quot;,     me32.GlblcntUsage );
    printf( &quot;\n     Ref count (p)  = 0x%04X&quot;,     me32.ProccntUsage );
    printf( &quot;\n     Base address   = 0x%08X&quot;, (DWORD) me32.modBaseAddr );
    printf( &quot;\n     Base size      = %d&quot;,             me32.modBaseSize );

  } while( Module32Next( hModuleSnap, &amp;me32 ) );

  CloseHandle( hModuleSnap );
  return( TRUE );
}

BOOL ListProcessThreads( DWORD dwOwnerPID ) 
{ 
  HANDLE hThreadSnap = INVALID_HANDLE_VALUE; 
  THREADENTRY32 te32; 

  // Snapshot von allen laufenden Threads 
  hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 ); 
  if( hThreadSnap == INVALID_HANDLE_VALUE ) 
    return( FALSE ); 

  // Größe ermitteln 
  te32.dwSize = sizeof(THREADENTRY32 ); 

  // Informationen über den 1. Thread 
  if( !Thread32First( hThreadSnap, &amp;te32 ) ) 
  {
    printError( TEXT(&quot;Thread32First&quot;) ); // Anzeige beim Fehler
    CloseHandle( hThreadSnap );          // Snapshot Objekt bereinigen
    return( FALSE );
  }

  // Threadliste des Systems durchgehen und Informationen über jeden thread wiedergeben, der mit dem jeweiligen Prozess zu tun hat
  do 
  { 
    if( te32.th32OwnerProcessID == dwOwnerPID )
    {
      printf( &quot;\n\n     THREAD ID      = 0x%08X&quot;, te32.th32ThreadID ); 
      printf( &quot;\n     Base priority  = %d&quot;, te32.tpBasePri ); 
      printf( &quot;\n     Delta priority = %d&quot;, te32.tpDeltaPri ); 
    }
  } while( Thread32Next(hThreadSnap, &amp;te32 ) ); 

  CloseHandle( hThreadSnap );
  return( TRUE );
}

void printError( TCHAR* msg )
{
  DWORD eNum;
  TCHAR sysMsg[256];
  TCHAR* p;

  eNum = GetLastError( );
  FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
         NULL, eNum,
         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
         sysMsg, 256, NULL );

  // Das Ende der Linie trimmen und mit 0 schließen
  p = sysMsg;
  while( ( *p &gt; 31 ) || ( *p == 9 ) )
    ++p;
  do { *p-- = 0; } while( ( p &gt;= sysMsg ) &amp;&amp;
                          ( ( *p == '.' ) || ( *p &lt; 33 ) ) );

  // Nachricht ausgeben
  _tprintf( TEXT(&quot;\n  WARNING: %s failed with error %d (%s)&quot;), msg, eNum, sysMsg );
}
</code></pre>
<p>Mir ist der Gedanke gekommen, dass ich mit GetCurrentProcessId das irgendwie abfangen könnte. Allerdings bekomme ich das nicht hin. Der gibt mir dann immer noch die ganze Liste aus <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1433748</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1433748</guid><dc:creator><![CDATA[+Zoidberg+]]></dc:creator><pubDate>Wed, 09 Jan 2008 15:31:11 GMT</pubDate></item><item><title><![CDATA[Reply to dynamische DLL wiedergabe on Thu, 10 Jan 2008 09:28:37 GMT]]></title><description><![CDATA[<p>Für Leute die noch über das Problem philosophieren, gibt es hier die Lösung.<br />
Simple. Aber manche Dinge im Leben erscheinen zu einfach um gleich entdeckt zu werden.</p>
<p>Man fügt nur</p>
<pre><code class="language-cpp">if(pe32.th32ProcessID == GetCurrentProcessId())
</code></pre>
<p>hier</p>
<pre><code class="language-cpp">//bei Erfolg Ausgabe
  do
  {
    printf( &quot;\n\n=====================================================&quot; );
    _tprintf( TEXT(&quot;\nPROCESS NAME:  %s&quot;), pe32.szExeFile );
    printf( &quot;\n-----------------------------------------------------&quot; );
</code></pre>
<p>ein.</p>
<p>Sieht dann so</p>
<pre><code class="language-cpp">//bei Erfolg Ausgabe
  do
  if(pe32.th32ProcessID == GetCurrentProcessId())
  {
    printf( &quot;\n\n=====================================================&quot; );
    _tprintf( TEXT(&quot;\nPROCESS NAME:  %s&quot;), pe32.szExeFile );
    printf( &quot;\n-----------------------------------------------------&quot; );
</code></pre>
<p>aus <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/1434147</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434147</guid><dc:creator><![CDATA[+Zoidberg+]]></dc:creator><pubDate>Thu, 10 Jan 2008 09:28:37 GMT</pubDate></item></channel></rss>