Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Controlling cd-rom motor

Hey, can someone tell me if its possible to control (change speed, start/stop) the cd-rom motor?
Thanks in advance :P
(Aug 10, 2016 10:13 AM)Mudzay Wrote:  Hey, can someone tell me if its possible to control (change speed, start/stop) the cd-rom motor?
Thanks in advance :P

lol i asked my teacher about that, he told me that it is not possible with .NET
(Aug 10, 2016 10:29 AM)i-manuel Wrote:  lol i asked my teacher about that, he told me that it is not possible with .NET

Everything is possible.
I'm sure there's a dll out there somewhere or something.
(Aug 10, 2016 10:29 AM)i-manuel Wrote:  lol i asked my teacher about that, he told me that it is not possible with .NET
U can always make c++ etc. dll and call it from c# xD (I think its possible, windows dlls like wimm.dll are c or c++)
You can open/close the tray from within c# easily. Not so sure about the speed, though.
riperino animefanerino
(Sep 12, 2016 04:11 PM){Nexus} Wrote:  If the FBI come knocking I'm gonna spew information out my ass about Aeon.

They'd have to tell me to stop giving them information.

Code
public bool IsDiscAvailable(int driveNumber)
{
    MsftDiscMaster2Class discMaster = new MsftDiscMaster2Class();
    string id = discMaster[driveNumber];

    MsftDiscRecorder2Class recorder = new MsftDiscRecorder2Class();
    recorder.InitializeDiscRecorder(id);

    MsftDiscFormat2DataClass dataWriter = new MsftDiscFormat2DataClass();
    if (dataWriter.IsRecorderSupported(recorder))
    {
        dataWriter.Recorder = recorder;
    }
    else
    {
        Console.WriteLine("Recorder not supported");
        return false;
    }
    if (dataWriter.IsCurrentMediaSupported(recorder))
    {
        var media = dataWriter.CurrentPhysicalMediaType;
        if (media == IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_UNKNOWN)
        {
            Console.WriteLine("Unknown media or no disc");
        }
        else
        {
            Console.WriteLine("Found disc type {0}", media);
            return true;
        }
    }
    else
    {
        Console.WriteLine("Disc absent or invalid.");
    }
    return false;
}

or

Code
using System;
using System.Management;

class Application
{
    public static void Main()
    {
        SelectQuery query =
            new SelectQuery( "select * from win32_logicaldisk where drivetype=5" );
        ManagementObjectSearcher searcher =
            new ManagementObjectSearcher(query);

        foreach( ManagementObject mo in searcher.Get() )
        {
            // If both properties are null I suppose there's no CD
            if(( mo["volumename"] != null) || (mo["volumeserialnumber"] != null))
            {
                Console.WriteLine("CD is named: {0}", mo["volumename"]);
                Console.WriteLine("CD Serial Number: {0}", mo["volumeserialnumber"]);
            }
            else
            {
                Console.WriteLine("No CD in Unit");
            }
        }

        // Here to stop app from closing
        Console.WriteLine("\nPress Return to exit.");
        Console.Read();
    }
}

The snippets above checks for a disk, causing the motor to run.

source:
http://stackoverflow.com/questions/11420...-dvd-drive
You would need to use IOCTL's for this. IOCTL_CDROM_SET_SPEED more specifically as the control code that you'd have to send to the CD-ROM class driver as a request of type CdromSetSpeed (from the CDROM_SPEED_REQUEST enum) in the RequestType memer of the CDROM_SET_SPEED struct. The buffer at Irp->AssociatedIrp.SystemBuffer would contain the CDROM_SET_SPEED structure. You wouldn't need to keep track of the previous speed either because when media is changed it will revert to it's default speed. From a user-mode application you would have to call DeviceIoControl() to send these requests.

(Aug 10, 2016 07:33 PM)еlixir Wrote:  ...

Yeah wonderful -- Not at ALL what OP asked for...
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by SIM-1517404Sep 19, 2017 11:33 PM 2 101 Sep 19, 2017 11:33 PM
Last Post: SIM-1517404
[Python] by SIM-1517404Aug 17, 2017 08:24 AM 7 341 Aug 17, 2017 08:24 AM
Last Post: SIM-1517404
[Python] by FolksMay 19, 2017 02:44 PM 3 126 May 19, 2017 02:44 PM
Last Post: hunter24957