No navigation frame on the left?  Click here.

NetServerEnum

What can I tell you about the NetServerEnum() sample? It is about as simple as they come.

Update [7 May 00]: Stuart Leeks points out that NetServerEnum() may fail to enumerate all servers if it is executed on a remote computer (i.e., if the first argument is not NULL).  In this case, NSE() will only return computers, which are reachable over the same protocol that your computer and the remote are using to communicate.  In a twisted sort of way, this even makes sense:  If your computer has, say, NetBEUI and TCP/IP, and the remote has TCP/IP and IPX/SPX, then the two are using the only protocol they have in common -- TCP/IP.  In that case, the remote will not tell you about the machines with which it talks over IPX/SPX, because the information is probably useless to you.  There are more complex scenarios which make this behaviour of NSE() undesirable, but in any case, we have to live with it.

Aaron Margosis has, eons ago, pointed out that I forgot to mention a bug in the implementation of NetServerEnum(), and it's only now that I find the time to point it out (sorry!): the resume_handle doesn't work. Your best bet is to use -1 as the value of prefmaxlen, to get whatever will fit; or use the undocumented NetServerEnumEx(), which does not have this problem. Aaron even provides a sample for NSEE().

nse.c, 3 KB