K
krupa.p
Hi All,
I am trying to call the waveOutGetVolume() function in winmm.dll from
my VS 2005 C# project using P/Invoke. I copied winmm.dll from
Windows\system32 directory into the root directory of my project. When
I run the solution, I get an error: Can't find PInvoke DLL 'winmm.dll'.
I have my code below. Could someone please help?
<code>
public partial class Form1 : Form
{
private class volAPI
{
[DllImport("winmm.dll" , EntryPoint = "waveOutGetVolume",
SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int waveOutGetVolume(IntPtr hwo, out
uint dwVolume);
[DllImport("winmm.dll", EntryPoint = "waveOutSetVolume",
SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int waveOutSetVolume(IntPtr hwo, uint
dwVolume);
}
public Form1()
{
InitializeComponent();
uint CurrVol = 0;
// At this point, CurrVol gets assigned the volume
volAPI.waveOutGetVolume(IntPtr.Zero, out CurrVol);
// Calculate the volume
ushort CalcVol = (ushort)(CurrVol & 0x0000ffff);
MessageBox.Show("Vol: " + CalcVol.ToString());
}
}
</code>
Regards,
Krupa
I am trying to call the waveOutGetVolume() function in winmm.dll from
my VS 2005 C# project using P/Invoke. I copied winmm.dll from
Windows\system32 directory into the root directory of my project. When
I run the solution, I get an error: Can't find PInvoke DLL 'winmm.dll'.
I have my code below. Could someone please help?
<code>
public partial class Form1 : Form
{
private class volAPI
{
[DllImport("winmm.dll" , EntryPoint = "waveOutGetVolume",
SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int waveOutGetVolume(IntPtr hwo, out
uint dwVolume);
[DllImport("winmm.dll", EntryPoint = "waveOutSetVolume",
SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int waveOutSetVolume(IntPtr hwo, uint
dwVolume);
}
public Form1()
{
InitializeComponent();
uint CurrVol = 0;
// At this point, CurrVol gets assigned the volume
volAPI.waveOutGetVolume(IntPtr.Zero, out CurrVol);
// Calculate the volume
ushort CalcVol = (ushort)(CurrVol & 0x0000ffff);
MessageBox.Show("Vol: " + CalcVol.ToString());
}
}
</code>
Regards,
Krupa