<?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[Auslesen der Computer im Netzwerk mit NetServerEnum()]]></title><description><![CDATA[<p>Im folgendem Code werden alle Benutzer im Netzwerk angezeigt.<br />
Wie kann ich neben den einzelnen Computern noch die dazugehörige IP-Adresse anhängen?</p>
<pre><code class="language-cpp">#include &lt;winsock.h&gt;
#include &lt;lm.h&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

#pragma comment(lib, &quot;Netapi32.lib&quot;)

void list() 
{
	LPSERVER_INFO_101 pBuf = NULL;
   LPSERVER_INFO_101 pTmpBuf;
   DWORD dwLevel = 101;
   DWORD dwPrefMaxLen = -1;
   DWORD dwEntriesRead = 0;
   DWORD dwTotalEntries = 0;
   DWORD dwTotalCount = 0;
   DWORD dwServerType = SV_TYPE_SERVER; // all servers
   DWORD dwResumeHandle = 0;
   NET_API_STATUS nStatus;
   LPTSTR pszServerName = NULL; //LPCWSTR
   DWORD i;

   string str;

   nStatus = NetServerEnum(NULL,
							dwLevel,
                           (LPBYTE *) &amp;pBuf,
                           dwPrefMaxLen,
                           &amp;dwEntriesRead,
                           &amp;dwTotalEntries,
                           dwServerType,
                           NULL,
                           &amp;dwResumeHandle);
   //
   // If the call succeeds,
   //

   if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
   {
      if ((pTmpBuf = pBuf) != NULL)
      {
         //
         // Loop through the entries and 
         //  print the data for all server types.
         //

         for (i = 0; i &lt; dwEntriesRead; i++)
         {
            //ASSERT(pTmpBuf != NULL);

            if (pTmpBuf == NULL)
            {
               cout &lt;&lt; &quot;An access violation has occurred&quot; &lt;&lt; endl;
               break;
            }

			else
			{
				char szBuf[MAX_PATH];
				wchar_t buff[100];
				swprintf(buff,L&quot;%s&quot;,pTmpBuf-&gt;sv101_name);

				//convert to byte format

				WideCharToMultiByte(CP_ACP,0,buff,-1,szBuf,
							MAX_PATH+1,NULL,NULL);
				//m_clients.InsertItem(0,szBuf);
				//cout &lt;&lt; szBuf &lt;&lt; endl;

				str += szBuf;
				str += &quot;\n&quot;;

				pTmpBuf++;
				dwTotalCount++;
			}
         }
         // Display a warning if all available entries were
         //  not enumerated, print the number actually 
         //  enumerated, and the total number available.

         if (nStatus == ERROR_MORE_DATA)
         {
            cout &lt;&lt; &quot;More entries available!!!&quot; &lt;&lt; endl;
			fprintf(stderr, &quot;\nMore entries available!!!\n&quot;);
			fprintf(stderr, &quot;Total entries: %d&quot;, dwTotalEntries);
         }

		 char total[20];
		 wsprintf(total,&quot;%d&quot;,dwTotalCount);
         cout &lt;&lt; &quot;Es wurden [&quot; &lt;&lt; total &lt;&lt; &quot;] Computer gefunden:&quot; &lt;&lt; endl;
		 cout &lt;&lt; &quot;--------------------------------&quot; &lt;&lt; endl;
		 cout &lt;&lt; str &lt;&lt; endl;

      }
   }
   else
      cout &lt;&lt; &quot;A system error has occurred 2 &quot; &lt;&lt; endl;
   //
   // Free the allocated buffer.
   //
   if (pBuf != NULL)
      NetApiBufferFree(pBuf);

}

int main()
{
	list();
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/154406/auslesen-der-computer-im-netzwerk-mit-netserverenum</link><generator>RSS for Node</generator><lastBuildDate>Thu, 23 Jul 2026 18:21:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/154406.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 26 Jul 2006 21:52:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Auslesen der Computer im Netzwerk mit NetServerEnum() on Wed, 26 Jul 2006 21:52:44 GMT]]></title><description><![CDATA[<p>Im folgendem Code werden alle Benutzer im Netzwerk angezeigt.<br />
Wie kann ich neben den einzelnen Computern noch die dazugehörige IP-Adresse anhängen?</p>
<pre><code class="language-cpp">#include &lt;winsock.h&gt;
#include &lt;lm.h&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

#pragma comment(lib, &quot;Netapi32.lib&quot;)

void list() 
{
	LPSERVER_INFO_101 pBuf = NULL;
   LPSERVER_INFO_101 pTmpBuf;
   DWORD dwLevel = 101;
   DWORD dwPrefMaxLen = -1;
   DWORD dwEntriesRead = 0;
   DWORD dwTotalEntries = 0;
   DWORD dwTotalCount = 0;
   DWORD dwServerType = SV_TYPE_SERVER; // all servers
   DWORD dwResumeHandle = 0;
   NET_API_STATUS nStatus;
   LPTSTR pszServerName = NULL; //LPCWSTR
   DWORD i;

   string str;

   nStatus = NetServerEnum(NULL,
							dwLevel,
                           (LPBYTE *) &amp;pBuf,
                           dwPrefMaxLen,
                           &amp;dwEntriesRead,
                           &amp;dwTotalEntries,
                           dwServerType,
                           NULL,
                           &amp;dwResumeHandle);
   //
   // If the call succeeds,
   //

   if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
   {
      if ((pTmpBuf = pBuf) != NULL)
      {
         //
         // Loop through the entries and 
         //  print the data for all server types.
         //

         for (i = 0; i &lt; dwEntriesRead; i++)
         {
            //ASSERT(pTmpBuf != NULL);

            if (pTmpBuf == NULL)
            {
               cout &lt;&lt; &quot;An access violation has occurred&quot; &lt;&lt; endl;
               break;
            }

			else
			{
				char szBuf[MAX_PATH];
				wchar_t buff[100];
				swprintf(buff,L&quot;%s&quot;,pTmpBuf-&gt;sv101_name);

				//convert to byte format

				WideCharToMultiByte(CP_ACP,0,buff,-1,szBuf,
							MAX_PATH+1,NULL,NULL);
				//m_clients.InsertItem(0,szBuf);
				//cout &lt;&lt; szBuf &lt;&lt; endl;

				str += szBuf;
				str += &quot;\n&quot;;

				pTmpBuf++;
				dwTotalCount++;
			}
         }
         // Display a warning if all available entries were
         //  not enumerated, print the number actually 
         //  enumerated, and the total number available.

         if (nStatus == ERROR_MORE_DATA)
         {
            cout &lt;&lt; &quot;More entries available!!!&quot; &lt;&lt; endl;
			fprintf(stderr, &quot;\nMore entries available!!!\n&quot;);
			fprintf(stderr, &quot;Total entries: %d&quot;, dwTotalEntries);
         }

		 char total[20];
		 wsprintf(total,&quot;%d&quot;,dwTotalCount);
         cout &lt;&lt; &quot;Es wurden [&quot; &lt;&lt; total &lt;&lt; &quot;] Computer gefunden:&quot; &lt;&lt; endl;
		 cout &lt;&lt; &quot;--------------------------------&quot; &lt;&lt; endl;
		 cout &lt;&lt; str &lt;&lt; endl;

      }
   }
   else
      cout &lt;&lt; &quot;A system error has occurred 2 &quot; &lt;&lt; endl;
   //
   // Free the allocated buffer.
   //
   if (pBuf != NULL)
      NetApiBufferFree(pBuf);

}

int main()
{
	list();
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1104966</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1104966</guid><dc:creator><![CDATA[kernel64]]></dc:creator><pubDate>Wed, 26 Jul 2006 21:52:44 GMT</pubDate></item><item><title><![CDATA[Reply to Auslesen der Computer im Netzwerk mit NetServerEnum() on Wed, 26 Jul 2006 22:41:23 GMT]]></title><description><![CDATA[<p>habs hinbekommen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1104986</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1104986</guid><dc:creator><![CDATA[kernel64]]></dc:creator><pubDate>Wed, 26 Jul 2006 22:41:23 GMT</pubDate></item><item><title><![CDATA[Reply to Auslesen der Computer im Netzwerk mit NetServerEnum() on Wed, 26 Jul 2006 23:23:21 GMT]]></title><description><![CDATA[<p>Und wie?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1105000</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1105000</guid><dc:creator><![CDATA[datexj]]></dc:creator><pubDate>Wed, 26 Jul 2006 23:23:21 GMT</pubDate></item><item><title><![CDATA[Reply to Auslesen der Computer im Netzwerk mit NetServerEnum() on Thu, 27 Jul 2006 12:42:48 GMT]]></title><description><![CDATA[<p>hab mir eine Funktion HostIP() erstellt, die ein string mit der IP zurückgibt <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/1105356</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1105356</guid><dc:creator><![CDATA[kernel64]]></dc:creator><pubDate>Thu, 27 Jul 2006 12:42:48 GMT</pubDate></item><item><title><![CDATA[Reply to Auslesen der Computer im Netzwerk mit NetServerEnum() on Thu, 27 Jul 2006 17:41:23 GMT]]></title><description><![CDATA[<p>Wow, ich hoffe du bekommst auf deine künftigen Fragen ähnliche Antworten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1105584</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1105584</guid><dc:creator><![CDATA[semiprofi]]></dc:creator><pubDate>Thu, 27 Jul 2006 17:41:23 GMT</pubDate></item><item><title><![CDATA[Reply to Auslesen der Computer im Netzwerk mit NetServerEnum() on Thu, 27 Jul 2006 17:47:28 GMT]]></title><description><![CDATA[<p>Wäare sinnvoll, wenn du die Funktion hier posten könntest, dann könnten auch andere die das gleiche Problem haben, diese verwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1105588</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1105588</guid><dc:creator><![CDATA[Mr. Sinnnvoll]]></dc:creator><pubDate>Thu, 27 Jul 2006 17:47:28 GMT</pubDate></item><item><title><![CDATA[Reply to Auslesen der Computer im Netzwerk mit NetServerEnum() on Thu, 27 Jul 2006 20:02:10 GMT]]></title><description><![CDATA[<p>Da wir wohl keine Antwort erwarten dürfen:</p>
<pre><code class="language-cpp">hostent *hEnt = 0;
    hEnt = gethostbyname( name1 );//bekannter hostname in name1

    CString m_ip;
    m_ip=inet_ntoa( *(LPIN_ADDR)*hEnt-&gt;h_addr_list );
    MessageBox(m_ip);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1105661</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1105661</guid><dc:creator><![CDATA[datexj]]></dc:creator><pubDate>Thu, 27 Jul 2006 20:02:10 GMT</pubDate></item><item><title><![CDATA[Reply to Auslesen der Computer im Netzwerk mit NetServerEnum() on Fri, 28 Jul 2006 12:22:29 GMT]]></title><description><![CDATA[<p>Sorry hier kommt der code:</p>
<pre><code class="language-cpp">string HostIP(string hname)
{
	#define h_addr h_addr_list[0]	//für getHostIP

	WSADATA WsaDat;	
	hostent *myhost;	
	in_addr myaddr;	

    myhost = NULL;

    if (WSAStartup(MAKEWORD(1,1),&amp;WsaDat)==0)
	{			
		myhost = gethostbyname(hname.c_str());	

        if (myhost!=NULL)
		{      			
			myaddr.S_un.S_un_b.s_b1 = myhost-&gt;h_addr[0];
			myaddr.S_un.S_un_b.s_b2 = myhost-&gt;h_addr[1];
			myaddr.S_un.S_un_b.s_b3 = myhost-&gt;h_addr[2];
			myaddr.S_un.S_un_b.s_b4 = myhost-&gt;h_addr[3];

			//printf(&quot;%s - %s\n&quot;,host, inet_ntoa(myaddr));
			return inet_ntoa(myaddr);
		}		

		else
		return &quot;Unbekannter Host&quot;;
		WSACleanup();
	}//if WSAStartup

	else
	return &quot;ERROR&quot;;

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1106119</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1106119</guid><dc:creator><![CDATA[kernel64]]></dc:creator><pubDate>Fri, 28 Jul 2006 12:22:29 GMT</pubDate></item></channel></rss>