啊,这么高的分,我怎么都要进来勃一勃 ;)你要的是不是这个东东:通过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

解决方案 »

  1.   

    我的E文不好的,VB也是刚入门,麻烦 ByTheWay(&#157;到此一游) 大侠用中文将程序注释一下
    拜托。
      

  2.   

       看我来拿!!!   给你推荐一个好东东
    先做 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
        给分吧!
      

  3.   

    uguess(uguess)的方法不错,但是不能直接获得共享文件夹,而且不能后退选择,能不能改进一下,我也给200分
      

  4.   

    谢谢fraser01(wang)的参与
    也想听听您的高见 
      

  5.   

     to  ChinaSunFire(什么的什么还是什么)
        难道我的代码不符合你的要求么?
        “如何用VB实现查找计算机以及其共享资源的?”好像我的代码实现了呀,为什么不给分?
      

  6.   

    to : uguess(uguess) 
    谢谢你的代码,分是会给的,但不是现在,你的代码不错但是不能直接获得共享文件夹,而且不能后退选择。
      

  7.   

    to uguess(uguess): 呵呵,你就好人做到底嘛!:)
    哦,对了,记得前任斑竹么,叫“一个好人”他帮人很彻底的哦。
      

  8.   

    to : uguess(uguess) 
    看来你还挺着急,我不是不想给你分,而是想留这帖子给大家讨论讨论,你要急着要分
    来http://www.csdn.net/expert/topic/369/369759.shtm
      

  9.   

    to : rushing(勇敢的心) 
    能详细点吗?