# Re: 如何用VB得知区域网路所有线上电脑的IP和Name

Posted by Smith on September 08, 1999 at 09:47:09:

In Reply to: Re: 如何用VB得知区域网路所有线上电脑的IP和Name posted by 琏琏 on September 07, 1999 at 12:28:30:

首先谢谢您的指导!!!
我是这么作的，当我读到第一个群组时，即进入递回呼叫,
但我为了避免麻烦我另外开了个sub ，内容如下
Dim nr1 As NETRESOURCE //避免和Form_Load 的重复
Dim hEnum As Long
Dim lpBuff As Long
Dim cbBuff As Long, cCount As Long
Dim p As Long, res As Long, i As Long
nr1.dwUsage = RESOURCEUSAGE_CONTAINER //我想群组应还是 收纳器
nr1.lpRemoteName = nr.lpRemoteName //这个很奇怪在*.bas 宣告为String而在api 中却是pointer 传回
res = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_DISK, 0, nr1, hEnum) //nr1 中的lpRemoteName 应是群组名
If res = 0 Then
lpBuff = GlobalAlloc(GPTR, cbBuff)
res = WNetEnumResource(hEnum, cCount, lpBuff, cbBuff) //这里的cCount 却仍是0"null"传回
If res = 0 Then
p = lpBuff
For i = 1 To cCount
CopyMemory nr, ByVal p, LenB(nr)
p = p + LenB(nr)
Next i
End If
End If

而我的想法递回呼叫应是重新执行WNetOpenEnum,WNetEnumResource
这两个函数，所传的参数在递回呼叫应会重新refresh，不知这个想
法是那里有错，请您多多指教!!!谢谢!!!

Follow Ups:

- 如何用VB得知区域网路所有线上电脑的IP和Name!!己找到问题了!!! smith 08:36:48 9/09/99 (0)