Home > Software engineering >  For help, this passage for all IP address code in the local area network (LAN) where there is a mist
For help, this passage for all IP address code in the local area network (LAN) where there is a mist

Time:09-20

After I am in accordance with the http://book.51cto.com/art/200806/78505.htm create controls, copying code, run
Always show user-defined types undefined,


 Private Sub Form_Load () 
On the Error Resume Next
Const MAX_RESOURCES=256
Const NOT_A_CONTAINER=1
Dim bFirstTime As Boolean
Dim lReturn As Long
Dim hEnum As Long
Dim lCount As Long
Dim lMin As Long
Dim lLength As Long
Dim As Long l
Dim lBufferSize As Long
Dim lLastIndex As Long
Dim uNetApi (0 To MAX_RESOURCES) As Netresource_BUf
Dim uNet () As Netresource
BFirstTime=True
Do
If bFirstTime Then
LReturn=WNetOpenEnum (resource_globalnet resourcetype_any, resourceusage_all, ByVal 0 & amp; , hEnum)
BFirstTime=False
The Else
If uNet (lLastIndex). The dwUsage And resourceusage_container Then
LReturn=WNetOpenEnum (resource_globalnet resourcetype_any, resourceusage_all, uNet (lLastIndex), hEnum)
The Else
LReturn=NOT_A_CONTAINER
HEnum=0
End the If
LLastIndex=lLastIndex + 1
End the If
If lReturn=no_error Then
LCount=resource_enum_all
Do
Len lBufferSize=UBound (uNetApi) * (uNetApi (0))/2
LReturn=WNetEnumResource (hEnum, lCount, uNetApi (0), lBufferSize)
If lCount & gt; 0 Then
ReDim Preserve uNet (0 To lMin lCount + 1) As Netresource
For l=0 To lCount - 1
UNet (lMin + l). DwScope=uNetApi (l). The dwScope
UNet (lMin + l). DwType=uNetApi (l). DwType
UNet (lMin + l). Dwdisplaytype=uNetApi (l). Dwdisplaytype
UNet (lMin + l). The dwUsage=uNetApi (l). The dwUsage
If uNetApi (l). Plocalname Then
LLength=lstrlen (uNetApi (l). Plocalname)
UNet (lMin + l). Slocalname=Space $(lLength)
Copymem ByVal uNet (lMin + l). Slocalname, ByVal uNetApi (l). Plocalname, lLength
End the If
If uNetApi (l). Premotename Then
LLength=lstrlen (uNetApi (l). Premotename)
UNet (lMin + l). Sremotename=Space $(lLength)
Copymem ByVal uNet (lMin + l). Sremotename, ByVal uNetApi (l). Premotename, lLength
End the If
Next l
End the If
LMin=lMin + lCount
Loop While lReturn=ERROR_MORE_DATA
End the If
If hEnum Then l=WNetCloseEnum (hEnum)
Loop While lLastIndex & lt; LMin
If UBound (uNet) & gt; 0 Then
For l=0 To UBound (uNet)
If uNet (l). Dwdisplaytype=resourcedisplaytype_server Then List1. AddItem uNet (l). Sremotename
Next l
End the If
End Sub

CodePudding user response:

The great god, help me!

CodePudding user response:

Dim uNetApi (0 To MAX_RESOURCES) As Netresource_BUf
Dim uNet () As Netresource

These two sentences, the data type declaration in advance
  • Related