Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Runtime.InteropServices;
- using System.Text;
- namespace koronawirus
- {
- class Program
- {
- static void Main(string[] args)
- {
- ConsoleKey key;
- while (true)
- {
- key = Console.ReadKey().Key;
- switch (key)
- {
- case ConsoleKey.O:
- open();
- break;
- case ConsoleKey.C:
- close();
- break;
- default:
- return;
- }
- }
- }
- private static void open()
- {
- int ret = mciSendString("set cdaudio door open", null, 0, IntPtr.Zero);
- }
- private static void close()
- {
- int ret = mciSendString("set cdaudio door closed", null, 0, IntPtr.Zero);
- }
- [DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi)]
- protected static extern int mciSendString(string lpstrCommand,
- StringBuilder lpstrReturnString,
- int uReturnLength,
- IntPtr hwndCallback);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment