请帮助,尽管系统中的音量发生变化,为什么该函数总是返回最大数字 4294967295?我究竟做错了什么?
我的系统是 Windows XP SP3 x86。
class Program
{
[DllImport("winmm.dll")]
private static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);
static void Main(string[] args)
{
uint currVol;
int result = waveOutGetVolume(IntPtr.Zero, out currVol);
if (result != 0)
{
Console.WriteLine("Some error occured...");
Console.ReadKey();
}
Console.WriteLine("currVol = {0}", currVol); //always = 4294967295
ushort left_channel_volume = (ushort)(currVol & 0xffff);
Console.WriteLine("left_channel_volume = {0}", left_channel_volume); //always = 65535
Console.ReadKey();
}
}