C#中调用Windows API

来源:互联网 发布:cpu性能 知乎 编辑:程序博客网 时间:2024/05/16 10:16

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace BeepTest
{
    class Program
    {
        [DllImport("kernel32.dll")]
        public static extern bool Beep(int frequency, int duration);
        static void Main(string[] args)
        {
            Random random = new Random();
            for (int i=0; i < 10000; i++)
            {
                Beep(random.Next(10000), 100);
            }
        }
    }
}

还是不会用,c#调用WindowsAPI,怎样才算会,怎样才算懂