Jump to content
Welcome, welcome! Come in and register, and have some developer coffee. 👨‍💻 ×

Windows DLL function to eject CD tray


Recommended Posts

Example output of C# program:

CDTRAY.png.84a464f63ab1ce1f2887a95cc83a3c5e.png

Example C# code:

(Please note that the CDTRAY.DLL can be used by any programming language that support P/Invoke)

Quote

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace CD
{
    public partial class Form1 : Form
    {
        [DllImport(@"C:\FASM\DLL\CDTRAY\CDTRAY.DLL")]
        private static extern void Eject();

        [DllImport(@"C:\FASM\DLL\CDTRAY\CDTRAY.DLL")]
        private static extern void Play();

        [DllImport(@"C:\FASM\DLL\CDTRAY\CDTRAY.DLL")]
        private static extern void Stop();

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Eject();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Play();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Stop();
        }
    }
}
 

CDTRAY.ASM (source code) is included for your modification.

CDTRAY.zip

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...