<?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[Komischer Linkererror]]></title><description><![CDATA[<p>Hi Leute,<br />
vorweg der Quelltext:</p>
<pre><code>#define _WIN32_WINNT 0x501
#include &lt;windows.h&gt;
#include &lt;psapi.h&gt;
#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;sstream&gt;
#include &lt;fstream&gt;
using namespace std;

class ProcessInfo {
public:
   ProcessInfo(HANDLE handle, DWORD id, string name) {
      this-&gt;handle = handle;
      this-&gt;id = id;
      this-&gt;name = name;
   }

   BOOL WINAPI GetProcessHandleCount(
   HANDLE hProcess,
   PDWORD pdwHandleCount
   );

   HANDLE getProcessHandle() {return handle;}
   DWORD getProcessId() {return id;}
   string getProcessName() {return name;}
   void terminate() {
      if (!handle) return;
      DWORD exitCode;
      if (GetExitCodeProcess(handle, &amp;exitCode)) {
         TerminateProcess(handle, exitCode);
      }
      handle = 0;
   }
   void closeHandle() {
      if (!handle) return;
      CloseHandle(handle);
      handle = 0;
   }
   bool isRunning() {
      if (!handle) return false;
      DWORD handleCount;
      if (GetProcessHandleCount(handle, &amp;handleCount)) {
         if (handleCount) return true;
      }
      handle = 0;
      return false;
   }
   static vector &lt;ProcessInfo&gt; getProcessInfos() {
      int arraySize = 128;
      DWORD *ids = new DWORD[arraySize];
      DWORD idByteCount;
      vector &lt;ProcessInfo&gt; processInfos;
      while(EnumProcesses(ids, arraySize*sizeof(DWORD), &amp;idByteCount)) {
         if (idByteCount &lt; arraySize*sizeof(DWORD)) {
            for (int i = 0; i &lt; idByteCount/sizeof(DWORD); i++) {
               HANDLE handle;
               if (handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ids[i])) {
                  char buf[256];
                  if (!GetModuleBaseName(handle, 0, buf, sizeof(buf))) strcpy(buf, &quot;&lt;unknown&gt;&quot;);
                  processInfos.push_back(ProcessInfo(handle, ids[i], buf));
               }
            }
            break;
         } else {
            delete [] ids;
            arraySize *= 2;
            ids = new DWORD[arraySize];
         }
      }
      delete [] ids;
      return processInfos;
   }
   static string makeProcessInfosString(vector &lt;ProcessInfo&gt; processInfos) {
      stringstream ss;
      ss &lt;&lt; processInfos.size() &lt;&lt; &quot; processes:\n&quot; &lt;&lt; endl;
      for (int i = 0; i &lt; processInfos.size(); i++) {
         ss &lt;&lt; (processInfos[i].isRunning()?&quot;running, &quot;:&quot;         &quot;)
            &lt;&lt; &quot;id=&quot; &lt;&lt; processInfos[i].getProcessId()
            &lt;&lt; &quot;, handle=&quot; &lt;&lt; (DWORD)processInfos[i].getProcessHandle()
            &lt;&lt; &quot;, name=\&quot;&quot; &lt;&lt; processInfos[i].getProcessName() &lt;&lt; &quot;\&quot;&quot;
            &lt;&lt; endl;
      }
      return ss.str();
   }
private:
   string name;
   HANDLE handle;
   DWORD id;
};

string getLocalTimeString() {
   SYSTEMTIME sysTime;
   GetLocalTime(&amp;sysTime);
   stringstream ss;
   ss &lt;&lt; (sysTime.wHour&gt;=10?&quot;&quot;:&quot;0&quot;) &lt;&lt; sysTime.wHour
      &lt;&lt; ':' &lt;&lt; (sysTime.wMinute&gt;=10?&quot;&quot;:&quot;0&quot;) &lt;&lt; sysTime.wMinute
      &lt;&lt; ':' &lt;&lt; (sysTime.wSecond&gt;=10?&quot;&quot;:&quot;0&quot;) &lt;&lt; sysTime.wSecond
      &lt;&lt; &quot;, &quot; &lt;&lt; sysTime.wDay
      &lt;&lt; '.' &lt;&lt; sysTime.wMonth
      &lt;&lt; '.' &lt;&lt; sysTime.wYear;
   return ss.str();
}

int main() {
   fstream fs;
   fs.open(&quot;c:\\processes.txt&quot;, ios_base::out | ios_base::trunc);
   if (!fs.is_open()) return 0;
   fs &lt;&lt; getLocalTimeString() &lt;&lt; endl;
   fs &lt;&lt; ProcessInfo::makeProcessInfosString(ProcessInfo::getProcessInfos());
   fs.close();
   return 0;
}
</code></pre>
<p>Fehler:<br />
C:\DOKUME<sub>1\x\LOKALE</sub>1\Temp\ccKYaaaa.o(.text\_ZN11ProcessInfo9isRunningEv\[ProcessInfo::isRunning()\]+0x30) In function `ZNSt24\_\_copy\_backward\_dispatchIP11ProcessInfoS1\_12\_\_false\_typeE4copyES1\_S1\_S1\_':  
\[Linker error\] undefined reference to `_ZN11ProcessInfo21GetProcessHandleCountEPvPm@12'  
C:\\DOKUME~1\\x\\LOKALE~1\\Temp\\ccKYaaaa.o(.text_ZN11ProcessInfo9isRunningEv[ProcessInfo::isRunning()]+0x30) ld returned 1 exit status</p>
<p>Ich benutzte Dev-C++ Compiler(4.9.9.2 Neuste Version), -lpsapi habe ich bei Compileroptionen eingebunden. Nun wüsste ich gerne wie ich diesen Fehler beheben könnte!<br />
Arbeite unter Windows XP Home SP 2</p>
<p>Danke an Alle für die Hilfe!<br />
Gruß Twitch</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/165639/komischer-linkererror</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 03:00:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/165639.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Nov 2006 19:54:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Komischer Linkererror on Tue, 21 Nov 2006 19:54:15 GMT]]></title><description><![CDATA[<p>Hi Leute,<br />
vorweg der Quelltext:</p>
<pre><code>#define _WIN32_WINNT 0x501
#include &lt;windows.h&gt;
#include &lt;psapi.h&gt;
#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;sstream&gt;
#include &lt;fstream&gt;
using namespace std;

class ProcessInfo {
public:
   ProcessInfo(HANDLE handle, DWORD id, string name) {
      this-&gt;handle = handle;
      this-&gt;id = id;
      this-&gt;name = name;
   }

   BOOL WINAPI GetProcessHandleCount(
   HANDLE hProcess,
   PDWORD pdwHandleCount
   );

   HANDLE getProcessHandle() {return handle;}
   DWORD getProcessId() {return id;}
   string getProcessName() {return name;}
   void terminate() {
      if (!handle) return;
      DWORD exitCode;
      if (GetExitCodeProcess(handle, &amp;exitCode)) {
         TerminateProcess(handle, exitCode);
      }
      handle = 0;
   }
   void closeHandle() {
      if (!handle) return;
      CloseHandle(handle);
      handle = 0;
   }
   bool isRunning() {
      if (!handle) return false;
      DWORD handleCount;
      if (GetProcessHandleCount(handle, &amp;handleCount)) {
         if (handleCount) return true;
      }
      handle = 0;
      return false;
   }
   static vector &lt;ProcessInfo&gt; getProcessInfos() {
      int arraySize = 128;
      DWORD *ids = new DWORD[arraySize];
      DWORD idByteCount;
      vector &lt;ProcessInfo&gt; processInfos;
      while(EnumProcesses(ids, arraySize*sizeof(DWORD), &amp;idByteCount)) {
         if (idByteCount &lt; arraySize*sizeof(DWORD)) {
            for (int i = 0; i &lt; idByteCount/sizeof(DWORD); i++) {
               HANDLE handle;
               if (handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ids[i])) {
                  char buf[256];
                  if (!GetModuleBaseName(handle, 0, buf, sizeof(buf))) strcpy(buf, &quot;&lt;unknown&gt;&quot;);
                  processInfos.push_back(ProcessInfo(handle, ids[i], buf));
               }
            }
            break;
         } else {
            delete [] ids;
            arraySize *= 2;
            ids = new DWORD[arraySize];
         }
      }
      delete [] ids;
      return processInfos;
   }
   static string makeProcessInfosString(vector &lt;ProcessInfo&gt; processInfos) {
      stringstream ss;
      ss &lt;&lt; processInfos.size() &lt;&lt; &quot; processes:\n&quot; &lt;&lt; endl;
      for (int i = 0; i &lt; processInfos.size(); i++) {
         ss &lt;&lt; (processInfos[i].isRunning()?&quot;running, &quot;:&quot;         &quot;)
            &lt;&lt; &quot;id=&quot; &lt;&lt; processInfos[i].getProcessId()
            &lt;&lt; &quot;, handle=&quot; &lt;&lt; (DWORD)processInfos[i].getProcessHandle()
            &lt;&lt; &quot;, name=\&quot;&quot; &lt;&lt; processInfos[i].getProcessName() &lt;&lt; &quot;\&quot;&quot;
            &lt;&lt; endl;
      }
      return ss.str();
   }
private:
   string name;
   HANDLE handle;
   DWORD id;
};

string getLocalTimeString() {
   SYSTEMTIME sysTime;
   GetLocalTime(&amp;sysTime);
   stringstream ss;
   ss &lt;&lt; (sysTime.wHour&gt;=10?&quot;&quot;:&quot;0&quot;) &lt;&lt; sysTime.wHour
      &lt;&lt; ':' &lt;&lt; (sysTime.wMinute&gt;=10?&quot;&quot;:&quot;0&quot;) &lt;&lt; sysTime.wMinute
      &lt;&lt; ':' &lt;&lt; (sysTime.wSecond&gt;=10?&quot;&quot;:&quot;0&quot;) &lt;&lt; sysTime.wSecond
      &lt;&lt; &quot;, &quot; &lt;&lt; sysTime.wDay
      &lt;&lt; '.' &lt;&lt; sysTime.wMonth
      &lt;&lt; '.' &lt;&lt; sysTime.wYear;
   return ss.str();
}

int main() {
   fstream fs;
   fs.open(&quot;c:\\processes.txt&quot;, ios_base::out | ios_base::trunc);
   if (!fs.is_open()) return 0;
   fs &lt;&lt; getLocalTimeString() &lt;&lt; endl;
   fs &lt;&lt; ProcessInfo::makeProcessInfosString(ProcessInfo::getProcessInfos());
   fs.close();
   return 0;
}
</code></pre>
<p>Fehler:<br />
C:\DOKUME<sub>1\x\LOKALE</sub>1\Temp\ccKYaaaa.o(.text\_ZN11ProcessInfo9isRunningEv\[ProcessInfo::isRunning()\]+0x30) In function `ZNSt24\_\_copy\_backward\_dispatchIP11ProcessInfoS1\_12\_\_false\_typeE4copyES1\_S1\_S1\_':  
\[Linker error\] undefined reference to `_ZN11ProcessInfo21GetProcessHandleCountEPvPm@12'  
C:\\DOKUME~1\\x\\LOKALE~1\\Temp\\ccKYaaaa.o(.text_ZN11ProcessInfo9isRunningEv[ProcessInfo::isRunning()]+0x30) ld returned 1 exit status</p>
<p>Ich benutzte Dev-C++ Compiler(4.9.9.2 Neuste Version), -lpsapi habe ich bei Compileroptionen eingebunden. Nun wüsste ich gerne wie ich diesen Fehler beheben könnte!<br />
Arbeite unter Windows XP Home SP 2</p>
<p>Danke an Alle für die Hilfe!<br />
Gruß Twitch</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1178775</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1178775</guid><dc:creator><![CDATA[Twitch]]></dc:creator><pubDate>Tue, 21 Nov 2006 19:54:15 GMT</pubDate></item><item><title><![CDATA[Reply to Komischer Linkererror on Thu, 23 Nov 2006 14:07:08 GMT]]></title><description><![CDATA[<p>Du hast die Funktion 'GetProcessHandleCount' als Klassenmember deklariert.<br />
Da du aber die WinAPI-Funktion aufrufen möchtest, laß die Deklaration einfach weg (da du ja schon &lt;windows.h&gt; inkludierst hast).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1180018</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1180018</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Thu, 23 Nov 2006 14:07:08 GMT</pubDate></item></channel></rss>