IWSHRuntimeLibrary

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to use the DriveClass to get the information for a drive but
can't seem to get the syntax, etc. correct.

I tried:

dim drives as DrivesClass = ??????????? tried NEW but it's private
dim d as drive
for each d in drives

next
 
Hi,

To get a list of drives you can use the wmi or the environment class.
The environment class only returns the drive letters use the wmi to get info
about the drive.

Environment class

For Each strDrive As String In Environment.GetLogicalDrives

Trace.WriteLine(strDrive)

Next



WMI

Add a reference to system.management to your app

' Add a Reference to System.Management

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_LogicalDisk")

moReturn = moSearch.Get

For Each mo In moReturn

Dim strOut As String

strOut = String.Format("Drive {0} - Drive Type {1}", mo("Name"),
mo("DriveType"))

Trace.WriteLine(strOut)

Next



http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_logicaldisk.asp



Ken

----------------------------------

I am trying to use the DriveClass to get the information for a drive but
can't seem to get the syntax, etc. correct.

I tried:

dim drives as DrivesClass = ??????????? tried NEW but it's private
dim d as drive
for each d in drives

next
 
Yes, I know there are several ways to get the drives but I was playing around
with Iwshruntimelibrary. With it, you can enumerate the shared drives and
folders. The Win32Logical Class only enumerates the drives and mapped
network drives, not the shared network places.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top