468,535 Members | 1,660 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,535 developers. It's quick & easy.

CreateObject("WScript.Network")

I use the below code to get the Network Places items. However, this requires
"Late Binding". I read that you can avoid late binding by adding a reference
to the Com Types in your application. Does anyone know what reference to add
and what to import?

Dim drives() As String
Dim ob As Object = CreateObject("WScript.Network")
Dim odrives As Object = ob.EnumNetworkDrives
dim k as integer
If odrives.count > 0 Then
ReDim drives(CInt(odrives.Count / 2))
For i = 0 To odrives.Count - 1 Step 2
k = k + 1
drives(k) = odrives.Item(i + 1).ToString.ToLower
Next
End If
--
Dennis in Houston
Nov 21 '05 #1
1 19421
Never mind...I've got it figured out:

Imports IWshRuntimeLibrary

Dim drives() As String
Dim o As IWshNetwork2 = CType(CreateObject("WScript.Network"), IWshNetwork2)
Dim odrives As WshCollection = CType(o.EnumNetworkDrives, WshCollection)
If odrives.count > 0 Then
ReDim drives(CInt(odrives.Count / 2))
For i = 0 To odrives.Count - 1 Step 2
k = k + 1
drives(k) = odrives.Item(i + 1).ToString.ToLower
Next
End If

"Dennis" wrote:
I use the below code to get the Network Places items. However, this requires
"Late Binding". I read that you can avoid late binding by adding a reference
to the Com Types in your application. Does anyone know what reference to add
and what to import?

Dim drives() As String
Dim ob As Object = CreateObject("WScript.Network")
Dim odrives As Object = ob.EnumNetworkDrives
dim k as integer
If odrives.count > 0 Then
ReDim drives(CInt(odrives.Count / 2))
For i = 0 To odrives.Count - 1 Step 2
k = k + 1
drives(k) = odrives.Item(i + 1).ToString.ToLower
Next
End If
--
Dennis in Houston

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Nick Gilbert | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.