c#Winformマイク音量制御マイク音量サイズを取得(自用メモ未テスト)
1765 ワード
マイクの音量を取得する場合は、GetVolumeInformationメソッドまたは
义齿例:
マイクの音量を彫るなら試してみてください
waveOutSetVolume()メソッド.
http://www.geekpedia.com/tutorial176_Get-and-set-the-wave-sound-volume.html
义齿例:
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
static extern bool GetVolumeInformation(string Volume, StringBuilder VolumeName,
uint VolumeNameSize, out uint SerialNumber, out uint SerialNumberLength,
out uint flags, StringBuilder fs, uint fs_size);
// :
uint serialNum, serialNumLength, flags;
StringBuilder volumename = new StringBuilder(256);
StringBuilder fstype = new StringBuilder(256);
bool ok = = GetVolumeInformation(drives, volumename,
(uint)volumename.Capacity - 1, out serialNum, out serialNumLength,
out flags, fstype, (uint)fstype.Capacity - 1);
if (ok)
{
lblVolume.Text = lblVolume.Text + "
Volume Information of " + drives + "
";
lblVolume.Text = lblVolume.Text + "
SerialNumber of is..... " +
serialNum.ToString() + "
";
if (volumename != null)
{
lblVolume.Text = lblVolume.Text + "VolumeName is..... " +
volumename.ToString() + "
";
}
if (fstype != null)
{
lblVolume.Text = lblVolume.Text + "FileType is..... " + fstype.ToString() + "
";
}
マイクの音量を彫るなら試してみてください
waveOutSetVolume()メソッド.
[DllImport("winmm.dll")]
public static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
//
uint CurrVol = 0;
// At this point, CurrVol gets assigned the volume
waveOutGetVolume(IntPtr.Zero, out CurrVol);
// Calculate the volume
ushort CalcVol = (ushort)(CurrVol & 0x0000ffff);
// Get the volume on a scale of 1 to 10 (to fit the trackbar)
textBox1.Text = (CalcVol / (ushort.MaxValue / 10)).ToString();
リンクを参照してください.http://www.geekpedia.com/tutorial176_Get-and-set-the-wave-sound-volume.html