Thursday, May 24, 2007

PInvoke (Platform Invoke)

using System;
using System.Runtime.InteropServices;

namespace TestPInvoke
{
///
/// Summary description for Class1.
///

class WrapK32
{
[DllImport("kernel32.dll")]
public static extern bool Beep(int frequency, int duration);

///
/// The main entry point for the application.
///

[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
Random random = new Random();

for (int i = 0; i < 10000; i++)
{
Beep(random.Next(10000), 100);
}
}
}
}

No comments: