OptionExplicit
PrivateConstRESOURCE_CONNECTEDAsLong=&H1&
PrivateConstRESOURCE_GLOBALNETAsLong=&H2&
PrivateConstRESOURCE_REMEMBEREDAsLong=&H3&
PrivateConstRESOURCEDISPLAYTYPE_DIRECTORY&=&H9
PrivateConstRESOURCEDISPLAYTYPE_DOMAIN&=&H1
PrivateConstRESOURCEDISPLAYTYPE_FILE&=&H4
PrivateConstRESOURCEDISPLAYTYPE_GENERIC&=&H0
PrivateConstRESOURCEDISPLAYTYPE_GROUP&=&H5
PrivateConstRESOURCEDISPLAYTYPE_NETWORK&=&H6
PrivateConstRESOURCEDISPLAYTYPE_ROOT&=&H7
PrivateConstRESOURCEDISPLAYTYPE_SERVER&=&H2
PrivateConstRESOURCEDISPLAYTYPE_SHARE&=&H3
PrivateConstRESOURCEDISPLAYTYPE_SHAREADMIN&=&H8
PrivateConstRESOURCETYPE_ANYAsLong=&H0&
PrivateConstRESOURCETYPE_DISKAsLong=&H1&
PrivateConstRESOURCETYPE_PRINTAsLong=&H2&
PrivateConstRESOURCETYPE_UNKNOWNAsLong=&HFFFF&
PrivateConstRESOURCEUSAGE_ALLAsLong=&H0&
PrivateConstRESOURCEUSAGE_CONNECTABLEAsLong=&H1&
PrivateConstRESOURCEUSAGE_CONTAINERAsLong=&H2&
PrivateConstRESOURCEUSAGE_RESERVEDAsLong=&H80000000
PrivateConstNO_ERROR=0
PrivateConstERROR_MORE_DATA=234'L//dderror
PrivateConstRESOURCE_ENUM_ALLAsLong=&HFFFF
PrivateTypeNETRESOURCE
dwScopeAsLong
dwTypeAsLong
dwDisplayTypeAsLong
dwUsageAsLong
pLocalNameAsLong
pRemoteNameAsLong
pCommentAsLong
pProviderAsLong
EndType
PrivateTypeNETRESOURCE_REAL
dwScopeAsLong
dwTypeAsLong
dwDisplayTypeAsLong
dwUsageAsLong
sLocalNameAsString
sRemoteNameAsString
sCommentAsString
sProviderAsString
EndType
PrivateDeclareFunctionWNetAddConnection2Lib"mpr.dll"Alias"WNetAddConnection2A"(lpNetResourceAsNETRESOURCE,ByVallpPasswordAsString,ByVallpUserNameAsString,ByValdwFlagsAsLong)AsLong
PrivateDeclareFunctionWNetOpenEnumLib"mpr.dll"Alias"WNetOpenEnumA"(ByValdwScopeAsLong,ByValdwTypeAsLong,ByValdwUsageAsLong,lpNetResourceAsAny,lphEnumAsLong)AsLong
PrivateDeclareFunctionWNetEnumResourceLib"mpr.dll"Alias"WNetEnumResourceA"(ByValhEnumAsLong,lpcCountAsLong,lpBufferAsNETRESOURCE,lpBufferSizeAsLong)AsLong
PrivateDeclareFunctionWNetCloseEnumLib"mpr.dll"(ByValhEnumAsLong)AsLong
PrivateDeclareFunctionVarPtrAnyLib"vb40032.dll"Alias"VarPtr"(lpObjectAsAny)AsLong
PrivateDeclareSubCopyMemLib"kernel32"Alias"RtlMoveMemory"(lpToAsAny,lpFromAsAny,ByVallLenAsLong)
PrivateDeclareSubCopyMemByPtrLib"kernel32"Alias"RtlMoveMemory"(ByVallpToAsLong,ByVallpFromAsLong,ByVallLenAsLong)
PrivateDeclareFunctionlstrcpyLib"kernel32"Alias"lstrcpyA"(ByVallpString1AsString,ByVallpString2AsAny)AsLong
PrivateDeclareFunctionlstrlenLib"kernel32"Alias"lstrlenA"(ByVallpStringAsAny)AsLong
Submain()
ConstMAX_RESOURCES=256
ConstNOT_A_CONTAINER=-1
DimbFirstTimeAsBoolean
DimlReturnAsLong
DimhEnumAsLong
DimlCountAsLong
DimlMinAsLong
DimlLengthAsLong
DimlAsLong
DimlBufferSizeAsLong
DimlLastIndexAsLong
DimuNetApi(0ToMAX_RESOURCES)AsNETRESOURCE
DimuNet()AsNETRESOURCE_REAL
bFirstTime=True
Do
IfbFirstTimeThen
lReturn=WNetOpenEnum(RESOURCE_GLOBALNET,RESOURCETYPE_ANY,RESOURCEUSAGE_ALL,ByVal0&,hEnum)
bFirstTime=False
Else
IfuNet(lLastIndex).dwUsageAndRESOURCEUSAGE_CONTAINERThen
lReturn=WNetOpenEnum(RESOURCE_GLOBALNET,RESOURCETYPE_ANY,RESOURCEUSAGE_ALL,uNet(lLastIndex),hEnum)
Else
lReturn=NOT_A_CONTAINER
hEnum=0
EndIf
lLastIndex=lLastIndex 1
EndIf
IflReturn=NO_ERRORThen
lCount=RESOURCE_ENUM_ALL
Do
lBufferSize=UBound(uNetApi)*Len(uNetApi(0))/2
lReturn=WNetEnumResource(hEnum,lCount,uNetApi(0),lBufferSize)
IflCount>0Then
ReDimPreserveuNet(0TolMin lCount-1)AsNETRESOURCE_REAL
Forl=0TolCount-1
'EachResourcewillappearhereasuNet(i)
uNet(lMin l).dwScope=uNetApi(l).dwScope
uNet(lMin l).dwType=uNetApi(l).dwType
uNet(lMin l).dwDisplayType=uNetApi(l).dwDisplayType
uNet(lMin l).dwUsage=uNetApi(l).dwUsage
IfuNetApi(l).pLocalNameThen
lLength=lstrlen(uNetApi(l).pLocalName)
uNet(lMin l).sLocalName=Space$(lLength)
CopyMemByValuNet(lMin l).sLocalName,ByValuNetApi(l).pLocalName,lLength
EndIf
IfuNetApi(l).pRemoteNameThen
lLength=lstrlen(uNetApi(l).pRemoteName)
uNet(lMin l).sRemoteName=Space$(lLength)
CopyMemByValuNet(lMin l).sRemoteName,ByValuNetApi(l).pRemoteName,lLength
EndIf
IfuNetApi(l).pCommentThen
lLength=lstrlen(uNetApi(l).pComment)
uNet(lMin l).sComment=Space$(lLength)
CopyMemByValuNet(lMin l).sComment,ByValuNetApi(l).pComment,lLength
EndIf
IfuNetApi(l).pProviderThen
lLength=lstrlen(uNetApi(l).pProvider)
uNet(lMin l).sProvider=Space$(lLength)
CopyMemByValuNet(lMin l).sProvider,ByValuNetApi(l).pProvider,lLength
EndIf
Nextl
EndIf
lMin=lMin lCount
LoopWhilelReturn=ERROR_MORE_DATA
EndIf
IfhEnumThen
l=WNetCloseEnum(hEnum)
EndIf
LoopWhilelLastIndex<lMin
IfUBound(uNet)>0Then
Forl=0ToUBound(uNet)
SelectCaseuNet(l).dwDisplayType
CaseRESOURCEDISPLAYTYPE_DIRECTORY&
Debug.Print"Directory...",
CaseRESOURCEDISPLAYTYPE_DOMAIN
Debug.Print"Domain...",
CaseRESOURCEDISPLAYTYPE_FILE
Debug.Print"File...",
CaseRESOURCEDISPLAYTYPE_GENERIC
Debug.Print"Generic...",
CaseRESOURCEDISPLAYTYPE_GROUP
Debug.Print"Group...",
CaseRESOURCEDISPLAYTYPE_NETWORK&
Debug.Print"Network...",
CaseRESOURCEDISPLAYTYPE_ROOT&
Debug.Print"Root...",
CaseRESOURCEDISPLAYTYPE_SERVER
Debug.Print"Server...",
CaseRESOURCEDISPLAYTYPE_SHARE
Debug.Print"Share...",
CaseRESOURCEDISPLAYTYPE_SHAREADMIN&
Debug.Print"ShareAdmin...",
EndSelect
Debug.PrintuNet(l).sRemoteName,uNet(l).sComment
Nextl
EndIf
EndSub->