using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace MCI_PlayCD
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
[DllImport("winmm.dll")]
public static extern int mciSendString(
string lpszCommand,
string lpszReturnString,
uint cchReturn,
IntPtr hwndCallback
);
// MCIERROR mciSendString(
// LPCTSTR lpszCommand,
// LPTSTR lpszReturnString,
// UINT cchReturn,
// HANDLE hwndCallback
// );
private System.Windows.Forms.Button buttonPlay;
private System.Windows.Forms.Button buttonStop;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonPlay = new System.Windows.Forms.Button();
this.buttonStop = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// buttonPlay
//
this.buttonPlay.Location = new System.Drawing.Point(40, 48);
this.buttonPlay.Name = "buttonPlay";
this.buttonPlay.TabIndex = 0;
this.buttonPlay.Text = "Play";
this.buttonPlay.Click += new System.EventHandler(this.buttonPlay_Click);
//
// buttonStop
//
this.buttonStop.Location = new System.Drawing.Point(168, 48);
this.buttonStop.Name = "buttonStop";
this.buttonStop.TabIndex = 1;
this.buttonStop.Text = "Stop";
this.buttonStop.Click += new System.EventHandler(this.buttonStop_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(296, 125);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.buttonStop,
this.buttonPlay});
this.Name = "Form1";
this.Text = "CD Player";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void buttonPlay_Click(object sender, System.EventArgs e)
{
mciSendString("open cdaudio", null, 0, IntPtr.Zero);
mciSendString("play cdaudio", null, 0, IntPtr.Zero);
}
private void buttonStop_Click(object sender, System.EventArgs e)
{
mciSendString("stop cdaudio", null, 0, IntPtr.Zero);
mciSendString("close cdaudio", null, 0, IntPtr.Zero);
}
}
}