首页 > 编程知识 正文

VBA 搜索共享资源

时间:2023-05-04 07:02:58 阅读:224813 作者:4184

'添加引用 Windows Script Host Object Model

Sub SearchShared()

   Dim a As WshNetwork
   Dim oPrinter As zqdylbr>   Set a = New WshNetwork
   Set oPrinter = a.EnumPrinterConnections
   Debug.Print "Network printer mappings:"
   For i = 0 To oPrinter.Count - 1 Step 2
       Debug.Print "Port" & oPrinter.Item(i) & oPrinter.Item(i + 1)
   Next
 
   Dim colDrives As zqdylbr>   Set colDrives = a.EnumNetworkDrives
   If colDrives.Count = 0 Then   Else
   MsgBox colDrives.Count
      strmsg = "当前网络驱动器连接:" & crlf
   
      For i = 0 To colDrives.Count - 1 Step 1
   
         Debug.Print colDrives(i)
      Next
  
   End If
   
End bhdlf/p>

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。