controling cd-rom through c#

Hi everybody

I want to control cd-rom (as ejecting disk and so on) through C#.
I'll join a code i wrote for it:


ServiceController[] scDevices;
scDevices = ServiceController.GetDevices();
i = 0;

while (i < scDevices.Length)
{
if(scDevices[i].DisplayName == "CD-ROM Driver")
{
if(scDevices[i].CanStop)
{
scDevices[i].Stop();
}
}
}

there is no problems with compiler but there is an exception during it running "System.InvalidOperationException: Cannot stop Mouclass
service on computer '.'."
how can i make it run ???

Comments

  • : Hi everybody
    :
    : I want to control cd-rom (as ejecting disk and so on) through C#.
    : I'll join a code i wrote for it:
    :
    :
    : ServiceController[] scDevices;
    : scDevices = ServiceController.GetDevices();
    : i = 0;
    :
    : while (i < scDevices.Length)
    : {
    : if(scDevices[i].DisplayName == "CD-ROM Driver")
    : {
    : if(scDevices[i].CanStop)
    : {
    : scDevices[i].Stop();
    : }
    : }
    : }
    :
    : there is no problems with compiler but there is an exception during it running "System.InvalidOperationException: Cannot stop Mouclass
    : service on computer '.'."
    : how can i make it run ???
    :
    :

    I want to update my massage

    microsoft gives free object to control burnner in winXP and win2003 at "http://msdn.microsoft.com/vcsharp/team/code/xpburn/default.aspx".
    it works but i can't burn with it.
    i wrote following code

    using System;
    using XPBurn;

    class burnCD
    {
    public static void Main()
    {
    XPBurnCD comp = new XPBurnCD();
    comp.AddFile("D:/Yossi/TestFile.txt","TestFile.txt");
    comp.RecordDisc(false,true);
    }
    }

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion