Files
wj32 7bd28e4357 moved branches, tags, trunk to 1.x branch
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@2304 21ef857c-d57f-4fe0-8362-d861dc6d29cd
2009-10-25 02:22:46 +00:00

48 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using ProcessHacker.Native.Api;
using ProcessHacker.Native.Objects;
using ProcessHacker.Native.Security;
namespace ProcessHacker.Native.Io
{
public static class BeepDevice
{
public struct BeepSetParameters
{
public int Frequency;
public int Duration;
}
public const int BeepFrequencyMinimum = 0x25;
public const int BeepFrequencyMaximum = 0x7fff;
public static readonly int IoCtlSet = Win32.CtlCode(DeviceType.Beep, 0, DeviceControlMethod.Buffered, DeviceControlAccess.Any);
public static void Beep(int frequency, int duration)
{
unsafe
{
BeepSetParameters p;
p.Frequency = frequency;
p.Duration = duration;
using (var fhandle = OpenBeep(FileAccess.GenericRead))
fhandle.IoControl(IoCtlSet, &p, Marshal.SizeOf(typeof(BeepSetParameters)), null, 0);
}
}
private static FileHandle OpenBeep(FileAccess access)
{
return new FileHandle(
Win32.BeepDeviceName,
FileShareMode.ReadWrite,
access
);
}
}
}