Код: Выделить всё
namespace Floydziak4
{
public class Payload
{
[DllImport("winmm.dll", EntryPoint = "mciSendString")]
public static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uRetrunLenght, int hwndCallback);
public void takczynie()
{
DialogResult dialog = MessageBox.Show("text1", "text2", MessageBoxButtons.YesNo);
if (dialog == DialogResult.Yes)
{
try
{
int result = mciSendString("set cdaudio door open", null, 0, 0);
Thread.Sleep(7000)
result = mciSendString("set cdaudio door close", null, 0, 0);
}
catch (Exception e)
{
int result = mciSendString("set cdaudio door open", null, 0, 0);
Thread.Sleep(7000)
result = mciSendString("set cdaudio door close", null, 0, 0);
}
}
else
{
{
other process here
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... n-winforms