Click here to Skip to main content
15,886,519 members
Articles / Programming Languages / C#

CD-Rom DLL for easy access to CD-Rom

Rate me:
Please Sign up or sign in to vote.
4.00/5 (2 votes)
31 Mar 2009CPOL 21.1K   534   14  
Class library for easy access to CD-ROM (CdRom) opening CD-Rom, C, Name of CD-Rom company in a line of code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CdRom;

namespace cd_rom_test
{
    public partial class form1 : Form
    {
        CDRom cd_rom;
        public form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            cd_rom = new CDRom();
            RefresH();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            RefresH();
        }
        void RefresH()
        {
            listBox1.Items.Clear();
            listBox1.Items.Add("Cd-Rom Names : ");
            //all cd-roms in an string array
            foreach(string temp in cd_rom.CDRomName)
                listBox1.Items.Add(temp);

            listBox1.Items.Add("---------------------------------------------------------");
            //all drive name
            listBox1.Items.Add("drives : ");
            foreach (string temp in cd_rom.DriveName)
                listBox1.Items.Add(temp);

            listBox1.Items.Add("----------------------------------------------------------");
            //has inserted cd into drive ? false or true
            listBox1.Items.Add("has inserted cd into drive ? ----> " + cd_rom.CdinCDRom.ToString());

            listBox1.Items.Add("-----------------------------------------------------------");
            //if cd is aviliable what's cd name : 
            listBox1.Items.Add("name of cd inserted (label of cd): " + cd_rom.CdName);

            listBox1.Items.Add("------------------------------------------------------------");
            // drive of cd-rom
            listBox1.Items.Add("CD Drive :    " + cd_rom.CdDriveName)
                ;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            cd_rom.CdRomOpening();
        }

        
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer Abtin CO.
Iran (Islamic Republic of) Iran (Islamic Republic of)
I'm engineer in Computer SCIENCE,i'm Work on indexing & software protection,and working in Abtin Co,

Comments and Discussions