discover if drive is CD-ROM, CD-R, DVD-Rom etc

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

Guest

Hi

Can someone please tell me how I can go about discovering whether a CD drive
is a ROM, R, RW or DVD-ROM, R, RW?

IMAPI is not possible for me because some of the PC's will be WindowsME
systems.

regards
 
Steve,

See this sample

\\\Supplied to these newsgroups by Herfried K. Wagner
Set a reference to System.Management.dll
Imports System.Management
..
..
..
Public Enum DriveType
Unknown = 0
NoRootDirectory = 1
RemoveableDisk = 2
LocalDisk = 3
NetworkDrive = 4
CompactDisk = 5
RamDisk = 6
End Enum

Public Function GetDriveType(ByVal strDrive As String) As DriveType
strDrive = "Win32_LogicalDisk='" & strDrive.Substring(0, 2) & "'"
Dim moDisk As ManagementObject = New ManagementObject(strDrive)
Return _
DirectCast( _
[Enum].Parse(GetType(DriveType),
moDisk("DriveType").ToString()), _
DriveType _
)
End Function
..
..
..
Dim astrDrives() As String = Environment.GetLogicalDrives()
Dim strDrive As String
For Each strDrive In astrDrives
MessageBox.Show( _
"Drive: " & strDrive & ControlChars.NewLine & _
"Type: " & GetDriveType(strDrive).ToString() _
)
Next strDrive
///
I hope this helps a little bit?

Cor
 
Hi Steve,

As far as I know, it's hard to detect if a CD Drive is a ROM, R, RW without
using IMAPI. In this case we have to use DeviceIoControl API to get these
information from the device driver directly. For more information about
this function, please check the following link.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/
deviceiocontrol.asp

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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