啊,这么高的分,我怎么都要进来勃一勃 ;)你要的是不是这个东东:通过WnetEnumResource函数获得网络资源
Create a new project and add the following code to the form:
Option ExplicitPrivate Const GMEM_FIXED = &H0
Private Const GMEM_ZEROINIT = &H40
Private Const GPTR = (GMEM_FIXED Or GMEM_ZEROINIT)Private Declare Function GlobalAlloc Lib "KERNEL32" ( _
ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function GlobalFree Lib "KERNEL32" ( _
ByVal hMem As Long) As LongPrivate Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" _
(hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)Private Declare Function CopyPointer2String Lib "KERNEL32" _
Alias "lstrcpyA" ( _
ByVal NewString As String, ByVal OldString As Long) As LongPrivate Sub Form_click()
Dim hEnum As Long, lpBuff As Long, nr As NETRESOURCE
Dim cbBuff As Long, cCount As Long
Dim p As Long, res As Long, i As Long'Setup the NETRESOURCE input structure.
nr.dwUsage = RESOURCEUSAGE_CONTAINER
nr.lpRemoteName = 0
cbBuff = 1000
cCount = &HFFFFFFFF'Open a Net enumeration operation handle: hEnum.
res = WNetOpenEnum(RESOURCE_CONNECTED, RESOURCETYPE_ANY, _
0, nr, hEnum)
If res = 0 Then
'Create a buffer large enough for the results.
'1000 bytes should be sufficient.
lpBuff = GlobalAlloc(GPTR, cbBuff)
'Call the enumeration function.
res = WNetEnumResource(hEnum, cCount, lpBuff, cbBuff)
If res = 0 Then
p = lpBuff
Cls
'WNetEnumResource fills the buffer with an array of
'NETRESOURCE structures. Walk through the list and print
'each local and remote name.
For i = 1 To cCount
CopyMemory nr, ByVal p, LenB(nr)
p = p + LenB(nr)
Print PointerToString(nr.lpLocalName), _
PointerToString(nr.lpRemoteName)
Next i
Else
MsgBox "Error: " & Err.LastDllError, vbOKOnly, _
"WNetEnumResources"
End If
If lpBuff <> 0 Then GlobalFree (lpBuff)
WNetCloseEnum (hEnum) 'Close the enumeration
Else
MsgBox "Error: " & Err.LastDllError, vbOKOnly, "WNetOpenEnum"
End If
End SubPrivate Function PointerToString(p As Long) As String
'The values returned in the NETRESOURCE structures are pointers to
'ANSI strings so they need to be converted to Visual Basic
Strings.
Dim s As String
s = String(255, Chr$(0))
CopyPointer2String s, p
PointerToString = Left(s, InStr(s, Chr$(0)) - 1)
End Function
解决方案 »
- 怎么用字符串的地址获取字符串本身
- 如何限制ActiveX DLL使用限制问题
- 如何控制外部程序
- 怎样用vb自动选择ie对象中类型为radio,select,check的选项并付值?
- 如何能做到判定指定路径的文件夹是否存在,如果不存在就生成此文件夹
- 如何把定义的recordset变量绑定到datagrid,在线等待,谢谢
- 注册.dll 问题?
- 如何给用VB做的软件升级?
- 那位知道采集网页的软件怎么做?特别是采集网页中的flash动画。象超级文档管理器(http://www.emanagersoft.com)、MyBase(http://www.wjjs
- 给分100,关于winxp起机的问题!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- 哪位大侠能不能教我做ACTIVEX DLL,以及调用它,请给个示范?
- 为什么它总是如此顽固
拜托。
先做 1.在component中添加一个组件:shell32.dll
2.在refrence中添加microsoft scripting runtime然后在窗体中添加一个commandbutton和listbox,然后运行,然后点击list1中的对象,就可以啦Private mdctItems As New Dictionary
Private Sub Command1_Click()
Dim shTemp1 As New Shell
Dim fdTemp1 As Folder
Dim fiTemp1 As FolderItem
Dim strTemp As String
Set fdTemp1 = shTemp1.NameSpace(ssfNETWORK)
mdctItems.RemoveAll
For Each fiTemp1 In fdTemp1.Items
strTemp = fdTemp1.GetDetailsOf(fiTemp1, 0)
List1.AddItem strTemp
mdctItems.Add List1.NewIndex, fiTemp1
Next
End SubPrivate Sub List1_Click()
Dim fiTemp As FolderItem
Dim fiTemp2 As FolderItem
Dim fdTemp As Folder
Dim strTemp As String
Set fiTemp = mdctItems(List1.ListIndex)
If fiTemp.IsFolder Then
List1.Clear
mdctItems.RemoveAll
Set fdTemp = fiTemp.GetFolder
For Each fiTemp2 In fdTemp.Items
strTemp = fdTemp.GetDetailsOf(fiTemp2, 0)
List1.AddItem strTemp
mdctItems.Add List1.NewIndex, fiTemp2
Next
End If
End Sub
给分吧!
也想听听您的高见
难道我的代码不符合你的要求么?
“如何用VB实现查找计算机以及其共享资源的?”好像我的代码实现了呀,为什么不给分?
谢谢你的代码,分是会给的,但不是现在,你的代码不错但是不能直接获得共享文件夹,而且不能后退选择。
哦,对了,记得前任斑竹么,叫“一个好人”他帮人很彻底的哦。
看来你还挺着急,我不是不想给你分,而是想留这帖子给大家讨论讨论,你要急着要分
来http://www.csdn.net/expert/topic/369/369759.shtm
能详细点吗?