使用VB获取网上邻居里的计算机名

赵婉如我爱你

赵婉如我爱你

2016-02-19 20:14

每个人都希望每天都是开心的,不要因为一些琐事扰乱了心情还,闲暇的时间怎么打发,关注图老师可以让你学习更多的好东西,下面为大家推荐使用VB获取网上邻居里的计算机名,赶紧看过来吧!
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)
  IflCount0Then
  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
  LoopWhilelLastIndexlMin
  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->

展开更多 50%)
分享

猜你喜欢

使用VB获取网上邻居里的计算机名

编程语言 网络编程
使用VB获取网上邻居里的计算机名

想要Vista网上邻居无法看到其它计算机

电脑入门
想要Vista网上邻居无法看到其它计算机

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

不能访问网上邻居

电脑入门
不能访问网上邻居

网上邻居无法使用怎么办

计算机应用技术
网上邻居无法使用怎么办

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

无法使用网上邻居的解决方法

电脑入门
无法使用网上邻居的解决方法

网上邻居在电脑哪里

电脑
网上邻居在电脑哪里

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

系统教程之给您的XP提速

系统教程之给您的XP提速

VB实用编程两例

VB实用编程两例
下拉加载更多内容 ↓