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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
NIRMAL KUMAR GNANA SEKARAN4 reputationPosted Aug 4, 2010, 3:49 AM EDT
suppose it is displaying -> RW means your drive has both read and write
Tanmay SarkarRank #1,407 · 1.2K reputationPosted Aug 4, 2010, 3:56 AM EDT
Thanks for your post but it's not.....
Sam HobbsRank #107 · 20.5K reputationPosted Aug 4, 2010, 8:19 AM EDT
Tanmay SarkarRank #1,407 · 1.2K reputationPosted Aug 4, 2010, 8:38 AM EDT
Thank you in advance!
Kirtan PatelRank #292 · 8.6K reputationPosted Aug 4, 2010, 9:55 AM EDT
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 SarkarRank #1,407 · 1.2K reputationPosted Aug 4, 2010, 10:32 AM EDT
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 PatelRank #292 · 8.6K reputationPosted Aug 4, 2010, 10:37 AM EDT
so it occured ! else its working .
Tanmay SarkarRank #1,407 · 1.2K reputationPosted Aug 4, 2010, 11:03 AM EDT
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!
Sam HobbsRank #107 · 20.5K reputationPosted Aug 4, 2010, 6:17 PM EDT
Tanmay SarkarRank #1,407 · 1.2K reputationPosted Aug 4, 2010, 6:52 PM EDT
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!
Kirtan PatelRank #292 · 8.6K reputationPosted Aug 4, 2010, 7:09 PM EDT
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 SarkarRank #1,407 · 1.2K reputationPosted Aug 4, 2010, 8:04 PM EDT
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 :)