源代码如下,麻烦帮我详细解释一下代码,谢谢了!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace CallAPIApp
{
public partial class Form1 : Form
{
#region DllImport
[DllImport("user32.dll")]
public static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
[DllImport("user32.dll", EntryPoint = "MessageBox")]
public static extern int MsgBox(IntPtr hWnd, String text, String caption, uint type);
[DllImport("kernel32.dll")]
private static extern int Beep(int dwFreq, int dwDuration);
#endregion
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
AnimateWindow(this.Handle, 5000, 0x00040000);
}
catch(Exception ex) {
MsgBox(this.Handle, ex.ToString(), "错误", 0);
}
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
MsgBox(this.Handle, "扬声器发声!", "提示", 0);
try
{
Beep(Int16.Parse(textBox2.Text), Int16.Parse(textBox1.Text));
}
catch (Exception ex)
{
MsgBox(this.Handle, ex.ToString(), "错误", 0);
}
}
}
}