waveOutSetVolume (winmm)
Last changed: -179.218.123.19

.
Summary
Set the volume of the specified device.

C# Signature:

[DllImport("winmm.dll", SetLastError=true, CallingConvention=CallingConvention.Winapi)]
public static extern uint waveOutSetVolume(int uDeviceID, uint dwVolume);

[DllImport("winmm.dll", SetLastError=true, CallingConvention=CallingConvention.Winapi)]
public static extern uint waveOutSetVolume(IntPtr uDeviceID, uint dwVolume);

VB Signature:

Declare Auto Function waveOutSetVolume Lib "winmm.dll" (ByVal uDeviceID As IntPtr, ByVal dwVolume As UInteger) As UInteger

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

VB - Use "Auto" in the Declare statement to have VB automatically marshal strings using the proper coding. ANSI is default.

Tips & Tricks:

Please add some!

Sample Code:

    // Each volume setting must be in the range between &H0 (silence) and &HFFFF (maximum volume).
    // ' Set the volume for all channels to &H7FFF (50%)
    // retval = waveOutSetVolume(0, &H7FFF7FFF)  ' for both channels, if needed
    public void SetVolume(uint volume)
    {
        if (m_WaveOut != IntPtr.Zero)
        WaveNative.waveOutSetVolume(m_WaveOut,volume);
    }

Documentation