关于C#调用API
今天在网上看了篇文章关于C#调用API的,感觉挺好的,所以自己也参考写了个C#调用API发声程序。
文中API函数参考MSDN:
Beep函数API原型为详情请见http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/beep.asp
BOOL Beep(
DWORD dwFreq, //声音频率
DWORD dwDuration //持续时间
);
using System;
using System.Runtime.InteropServices;
namespace Beep
{
class Class1
{
[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(1000), 100);
}
}
}
}
本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利
This posting is provided "AS IS" with no warranties, and confers no rights.