1. 程式人生 > >c# Winform 獲取麥克風音量 控制麥克風音量大小 (自用筆記未測試)

c# Winform 獲取麥克風音量 控制麥克風音量大小 (自用筆記未測試)

[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 + "\n Volume Information of " + drives + "\n";
 lblVolume.Text = lblVolume.Text + "\nSerialNumber of is..... " + 
	serialNum.ToString() + " \n";
  if (volumename != null)
  {
  lblVolume.Text = lblVolume.Text + "VolumeName is..... " + 
	volumename.ToString() + " \n";
  }
if (fstype != null)
 {
 lblVolume.Text = lblVolume.Text + "FileType is..... " + fstype.ToString() + " \n";
 }