How i check my CD drive has only read capability or it has also read-right property,
by C#?
Thank you in advance!
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tanmay SarkarPosted Aug 5, 2010, 12:04 AM
It shows only "Random Access" & "Supports Removable Media" both for my logical & virtual drive...
Thanks for your long support :)
But "Supports Writing" are still not showing... please...
Thank you once again :)
Kirtan PatelPosted Aug 4, 2010, 11:09 PM
Dictionary
private void btnGetCapability_Click(object sender, EventArgs e)
{
Dictionary<UInt16, string> list = new Dictionary<UInt16, string>();
list.Add(0, "Unknown");
list.Add(1, "Other");
list.Add(2, "Sequential Access");
list.Add(3, "Random Access");
list.Add(4, "Supports Writing");
list.Add(5, "Encryption");
list.Add(6, "Compression");
list.Add(7, "Supports Removable Media");
list.Add(8, "Manual Cleaning");
list.Add(9, "Automatic Cleaning");
list.Add(10, "SMART Notification");
list.Add(11, "Supports Dual-Sided Media");
list.Add(12, "Ejection Prior to Drive Dismount Not Required");
ManagementObjectSearcher mos;
mos = new ManagementObjectSearcher("Select * from Win32_CDROMDrive where Caption='" + comboBox1.SelectedItem.ToString() + "'");
foreach (ManagementObject mo in mos.Get())
{
UInt16[] x = (UInt16[])mo["Capabilities"];
foreach(UInt16 i in x)
{
listBox1.Items.Add(list[i].ToString());
}
}
}
Tanmay SarkarPosted Aug 4, 2010, 10:52 PM
So I think i first read about this namespace, if you recommended any article ar link will help me & then I properly understand what is my mistake, & what is the way to solve this problem.
I look this article which is written by Kirtan Pattel
http://www.c-sharpcorner.com/UploadFile/kirtan007/2541/
but it is not working in my computer
Is it need any special configuration?
Thank you!
Sam HobbsPosted Aug 4, 2010, 10:17 PM
Tanmay SarkarPosted Aug 4, 2010, 3:03 PM
it mark on this line, in button:
foreach (string s in x)
I enter a disk & check again it give me trouble also.
I have a logical & one virtual drive. and use XP pack 3.
Thank you, I could not under stand where i do the sili but terrible mistake.
plesae help me & mark my mistake...
Thank you once again!
Kirtan PatelPosted Aug 4, 2010, 2:37 PM
so it occured ! else its working .
Tanmay SarkarPosted Aug 4, 2010, 2:32 PM
that is - "object reference not set to an instance of an object".
Defiantly I make a mistake. Please do something...
Thank you in advance.
Kirtan PatelPosted Aug 4, 2010, 1:55 PM
private void Form1_Load(object sender, EventArgs e)
{
ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_CDROMDrive");
foreach (ManagementObject mo in mos.Get())
{
comboBox1.Items.Add(mo["Caption"].ToString());
}
}
private void btnGetCapability_Click(object sender, EventArgs e)
{
ManagementObjectSearcher mos;
mos = new ManagementObjectSearcher("Select * from Win32_CDROMDrive where Caption='" + comboBox1.SelectedItem.ToString() + "'");
foreach (ManagementObject mo in mos.Get())
{
string[] x = (string[])mo["CapabilityDescriptions"];
foreach(string s in x)
{
listBox1.Items.Add(s);
}
}
}
select the answer as accepted if it helps you : )
Tanmay SarkarPosted Aug 4, 2010, 12:38 PM
Thank you in advance!
Sam HobbsPosted Aug 4, 2010, 12:19 PM
Tanmay SarkarPosted Aug 4, 2010, 7:56 AM
Thanks for your post but it's not.....
NIRMAL KUMAR GNANA SEKARANPosted Aug 4, 2010, 7:49 AM
suppose it is displaying -> RW means your drive has both read and write