Removable Drive Types & VB.NET
Hows it going!
In my most recent project, I am working with drives & drive types. I have no problem when it comes to determining whether a drive is fixed, removable, networked, cdrom, or unknown.
What I am wondering though is how to dive into removable drives a little bit deeper. I noticed that they are all placed into this base category, even though there are numerous sub-category types.
I found these articles on MSDN, 115828 (http://support.microsoft.com/?scid=kb;en-US;115828) & 163920 (http://support.microsoft.com/default.aspx?scid=kb;en-us;163920). Both are about getting floppy drive type information, but they are in C.
I am not only interested in getting floppy info, if possible I would like to determine whether the removable is Floppy, MS , SD, SmartMedia, CompactFlash, ect
If anyone has the slightest idea of the best way to accomplishing this in VB.NET, it would be much appreciated!
Thanks ahead of time! :)
Jugg
[1003 byte] By [
Jugg] at [2007-11-11 8:26:41]

# 1 Re: Removable Drive Types & VB.NET
Well after digging around looking for VB .NET examples of DeviceIoControl API being used in this manner, I came up with nothing... :(
One example for VB (http://vbnet.mvps.org/index.html?code/disk/deviodriveinfo.htm) & the rest was all C\C++ & C# examples that required some time converting that I did not want to spend right now.
I did however, start looking into WMI & it turns out that it offers just about the same exact features I was looking for in DeviceIoControl.
Heres a simple C# example from this (http://www.thescripts.com/forum/thread49291.html) thread on TheScripts.com converted to VB .NET of what WMI offers in disk management which probably took a lot less time to convert properly than the DeviceIoControl methods I came across
Public Sub LDisk()
Dim st As StringBuilder = New StringBuilder
Dim servername As String = "somesystem"
Dim oq As ObjectQuery = New ObjectQuery("select * from Win32_Logicaldisk")
Dim scope As ManagementScope = New ManagementScope("\\" + servername + "\root\cimv2")
scope.Connect()
Dim sea As ManagementObjectSearcher = New ManagementObjectSearcher(scope, oq)
For Each proc As ManagementObject In sea.Get
st.AppendFormat("Desc = {0}, ID={1}, Volname={2}", proc("Description"), proc("Deviceid"), proc("VolumeName"))
st.AppendFormat("" & Microsoft.VisualBasic.Chr(10) & "")
Next
MessageBox.Show(st.ToString)
End Sub
I just ended up deciding if I can at least determine the floppy I am doing good!
My app uses the sytem icons so I will just set it up to use the generic removable drive icon & as an alternative, to look for an autorun file on the removable drives other than floppy & use a specified icon from it.
Now off to get more complex with WMI & maybe try to dig up something about DeviceIoControl in VB .NET or convert up one of the various projects I came across cuz now Im interested :D
Jugg
Jugg at 2007-11-11 21:47:22 >
